how many free bits we have in Object Header?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

how many free bits we have in Object Header?

Mariano Martinez Peck
 
Hi folks. I think I am using the last free bit in the object header. For the moment, I am using this:

ObjectMemory >> initializeObjectHeaderConstants

.....

"masks for root and mark bits"
    MarkBit := 1 bitShift: BytesPerWord*8 - 1.  "Top bit"
    RootBit := 1 bitShift: BytesPerWord*8 - 2.  "Next-to-Top bit"
    AllButMarkBit := WordMask - MarkBit.
    AllButRootBit := WordMask - RootBit.

    AllButMarkBitAndTypeMask := AllButTypeMask - MarkBit.
   
    UsedObjectBit := 1 bitShift: BytesPerWord*8 - 3.  "Next-to-Top bit"
    AllButUsedBit := WordMask - UsedObjectBit.
   


Now...the question is, is there another free bit in the object header ? I need another one :(

Thanks

Mariano
Reply | Threaded
Open this post in threaded view
|

Re: how many free bits we have in Object Header?

David T. Lewis
 
On Tue, May 04, 2010 at 11:49:11AM +0200, Mariano Martinez Peck wrote:

>  
> Hi folks. I think I am using the last free bit in the object header. For the
> moment, I am using this:
>
> ObjectMemory >> initializeObjectHeaderConstants
>
> .....
>
> "masks for root and mark bits"
>     MarkBit := 1 bitShift: BytesPerWord*8 - 1.  "Top bit"
>     RootBit := 1 bitShift: BytesPerWord*8 - 2.  "Next-to-Top bit"
>     AllButMarkBit := WordMask - MarkBit.
>     AllButRootBit := WordMask - RootBit.
>
>     AllButMarkBitAndTypeMask := AllButTypeMask - MarkBit.
>
>     UsedObjectBit := 1 bitShift: BytesPerWord*8 - 3.  "Next-to-Top bit"
>     AllButUsedBit := WordMask - UsedObjectBit.
>
>
>
> Now...the question is, is there another free bit in the object header ? I
> need another one :(

Based on the comment at the bottom of Interpreter>>internalIsImmutable:
I suspect that somebody else has their eye on that last available bit
also ;-)

Dave

Reply | Threaded
Open this post in threaded view
|

Re: how many free bits we have in Object Header?

Mariano Martinez Peck
 

>
> Now...the question is, is there another free bit in the object header ? I
> need another one :(

Based on the comment at the bottom of Interpreter>>internalIsImmutable:
I suspect that somebody else has their eye on that last available bit
also ;-)


Yes, I know :(   But for the moment I don't care to "integrate" my stuff.  I just want to play and experiment. And even for that, I need 2 bits :(
Of course, if I once make something good to integrate, I will have double problem :(

So...no solution ?
Reply | Threaded
Open this post in threaded view
|

Re: how many free bits we have in Object Header?

Adrian Lienhard

Hi Mariano,

I see two solutions
- make the identityHash (even) smaller
- remove compact classes

The former would probably not be hard to implement (just change some bit masks and then rehash all sets). I've brought up the idea about the latter some time ago on this mailing list. The idea is to remove compact classes to get a larger identityHash (trading memory against speed). After the removal, only two header types are left and hence you gain a spare bit. I think this shouldn't be too much work either, but I haven't come around to implementing it (yet).

Good luck ;)
Adrian

On May 4, 2010, at 13:13 , Mariano Martinez Peck wrote:

>>>
>>> Now...the question is, is there another free bit in the object header ? I
>>> need another one :(
>>
>> Based on the comment at the bottom of Interpreter>>internalIsImmutable:
>> I suspect that somebody else has their eye on that last available bit
>> also ;-)
>>
>>
> Yes, I know :(   But for the moment I don't care to "integrate" my stuff.  I
> just want to play and experiment. And even for that, I need 2 bits :(
> Of course, if I once make something good to integrate, I will have double
> problem :(
>
> So...no solution ?

Reply | Threaded
Open this post in threaded view
|

Re: how many free bits we have in Object Header?

Mariano Martinez Peck
 


On Tue, May 4, 2010 at 2:12 PM, Adrian Lienhard <[hidden email]> wrote:

Hi Mariano,

I see two solutions
- make the identityHash (even) smaller

Hi Adrian. Thanks for you answer. I am still newbie with the VM and there are a lot of things I don't understand :(

I though that in squeak the hash of an object was the address in memory. Then I though this was in Smalltalk 80 where you had an object table, and thus, there were no problem with the address of an object. In squeak I think that the Object Table doesn't exist anymore, but objects can change address, while the Hash shouldn't be modified. That's why you need 12 bits of hash in the object header ?   so...you always use this 12 bits for hash and not the address of the object at all ?  I ask because in the book "Squeak Open Personal  Computing and Multimedia" that I am reading, it says:

"12 bits object hash (for hashed Set usage)"

But if it is only for hashed Set..what happens with the hash of normal objects?   As I see in the code, it ALSO uses those 12 bits. I am right ? Maybe this changed from the time the book was written.

 
- remove compact classes

The former would probably not be hard to implement (just change some bit masks and then rehash all sets). I've brought up the idea about the latter some time ago on this mailing list. The idea is to remove compact classes to get a larger identityHash (trading memory against speed). After the removal, only two header types are left and hence you gain a spare bit.


Again, I am trying to understand all this. I read about Compact Classes but still I think I don't understand them. They are just one world objects ?

Why you say than removing them we will only use 2 header types instead of 4 ? which ones we will use  and why we wouldn't use the others 2 ?

In addition, in this book it says:

"5 bits compact class index, nonzero if the class is in a group of classes known as "Compact Classes"

I don't understand these 5 bits and neither if they have sense or not if we remove the compact classes.
 
Thank you very much for any help in advance,

Mariano


I think this shouldn't be too much work either, but I haven't come around to implementing it (yet).

Good luck ;)
Adrian

On May 4, 2010, at 13:13 , Mariano Martinez Peck wrote:

>>>
>>> Now...the question is, is there another free bit in the object header ? I
>>> need another one :(
>>
>> Based on the comment at the bottom of Interpreter>>internalIsImmutable:
>> I suspect that somebody else has their eye on that last available bit
>> also ;-)
>>
>>
> Yes, I know :(   But for the moment I don't care to "integrate" my stuff.  I
> just want to play and experiment. And even for that, I need 2 bits :(
> Of course, if I once make something good to integrate, I will have double
> problem :(
>
> So...no solution ?


Reply | Threaded
Open this post in threaded view
|

Re: how many free bits we have in Object Header?

Adrian Lienhard

Hi Mariano,

Yes this is basically right. Hash is not the object address because GC moves objects; no object table. You get the 12bit hash with #identityHash (implemented as a  primitive in ProtoObject). Sets and other data structures depending object hashes use #hash, or directly #identityHash in the case of IdentitySet. The method #hash, if not overridden, falls back to #identityHash.

Cheers,
Adrian


On May 5, 2010, at 11:55 , Mariano Martinez Peck wrote:

> On Tue, May 4, 2010 at 2:12 PM, Adrian Lienhard <[hidden email]> wrote:
>
>>
>> Hi Mariano,
>>
>> I see two solutions
>> - make the identityHash (even) smaller
>>
>
> Hi Adrian. Thanks for you answer. I am still newbie with the VM and there
> are a lot of things I don't understand :(
>
> I though that in squeak the hash of an object was the address in memory.
> Then I though this was in Smalltalk 80 where you had an object table, and
> thus, there were no problem with the address of an object. In squeak I think
> that the Object Table doesn't exist anymore, but objects can change address,
> while the Hash shouldn't be modified. That's why you need 12 bits of hash in
> the object header ?   so...you always use this 12 bits for hash and not the
> address of the object at all ?  I ask because in the book "Squeak Open
> Personal  Computing and Multimedia" that I am reading, it says:
>
> "12 bits object hash (for hashed Set usage)"
>
> But if it is only for hashed Set..what happens with the hash of normal
> objects?   As I see in the code, it ALSO uses those 12 bits. I am right ?
> Maybe this changed from the time the book was written.
>
>
>
>> - remove compact classes
>>
>> The former would probably not be hard to implement (just change some bit
>> masks and then rehash all sets). I've brought up the idea about the latter
>> some time ago on this mailing list. The idea is to remove compact classes to
>> get a larger identityHash (trading memory against speed). After the removal,
>> only two header types are left and hence you gain a spare bit.
>
>
>
> Again, I am trying to understand all this. I read about Compact Classes but
> still I think I don't understand them. They are just one world objects ?
>
> Why you say than removing them we will only use 2 header types instead of 4
> ? which ones we will use  and why we wouldn't use the others 2 ?
>
> In addition, in this book it says:
>
> "5 bits compact class index, nonzero if the class is in a group of classes
> known as "Compact Classes"
>
> I don't understand these 5 bits and neither if they have sense or not if we
> remove the compact classes.
>
> Thank you very much for any help in advance,
>
> Mariano
>
>
> I think this shouldn't be too much work either, but I haven't come around to
>> implementing it (yet).
>>
>> Good luck ;)
>> Adrian
>>
>> On May 4, 2010, at 13:13 , Mariano Martinez Peck wrote:
>>
>>>>>
>>>>> Now...the question is, is there another free bit in the object header ?
>> I
>>>>> need another one :(
>>>>
>>>> Based on the comment at the bottom of Interpreter>>internalIsImmutable:
>>>> I suspect that somebody else has their eye on that last available bit
>>>> also ;-)
>>>>
>>>>
>>> Yes, I know :(   But for the moment I don't care to "integrate" my stuff.
>> I
>>> just want to play and experiment. And even for that, I need 2 bits :(
>>> Of course, if I once make something good to integrate, I will have double
>>> problem :(
>>>
>>> So...no solution ?
>>
>>