[Vm-dev] Re: [squeak-dev] Immediate and heap objects

Chris Cunnington brasspen at gmail.com
Fri Dec 5 15:53:38 UTC 2014


People learn differently, but this description is working for me. And not having to look up what Huffman code means would be a help. 

Chris 

> On Dec 5, 2014, at 7:02 AM, Bert Freudenberg <bert at freudenbergs.de> wrote:
> 
> On 05.12.2014, at 06:44, Eliot Miranda <eliot.miranda at gmail.com <mailto:eliot.miranda at gmail.com>> wrote:
>> 
>> The oop has some "tag bits" and some data bits.
>>  
>> "The tag bits encode the class, and the data bits encode the instance data."
>> 
>> Incorrect.  So perhaps:
>> 
>> "If the object fits in one word and it has a suitable class then the tag bits define the class and the data bits define the instance data.  Since there are very few tag bits, the VM only uses this tagged immediate representation for common objects like integers and characters.
>> 
>> If the object doesn't fit in one word the class is stored on the heap in the object's body along with its data.  This is so called a heap object."
> 
> This is more precise, yes, but I think my wording is not wrong, just simpler. The tag bits are what the VM looks at to determine the class. It’s just that if the tag bits say that this is a heap object, then the VM needs to go to the heap to find the actual class. It’s a sort of Huffman code. And on the heap the class reference is again Huffman-coded, at least in regular 32-bit Squeak: There are 5 bits for “compact" classes, or 32 bits for all other classes. But spelling all this out at that point would obscure the argument, I think ...
> 
> I agree that a word other than “encode” might be more appropriate. Would that help?
> 
>>  
>> One special combination of tag bits is reserved to denote heap objects. The other combinations of tag bits correspond to different classes of immediate objects.
>> 
>> 32-bit oops have 2 tag bits. This allows four combinations of tag bits (00, 01, 10, 11). The tags 01 and 11 are used for immediate "SmallInteger" instances, which represents signed numbers between -1073741824 and 1073741823. The tag 10 will be used in Spur for immediate Characters.
>> 
>> Can we say the tag 10 *is* used for Characters in Spur?  (it is).
> 
> Oops. Sure. To me Spur is still in the future ;)
> 
>> 64-bit oops have 3 tag bits in Spur. Only half of the 8 tags are assigned at the moment, for SmallIntegers, Characters, and SmallFloat64s.
>> 
>> SmallIntegers have the tag 2r001, Characters have the tag 2r010 and SmallFloat64s have the tag 2r011, leaving four unused tag values.
> 
> Well, I didn’t want to go into too many details, but still give an example, which is why I spelled out the tags for 32-bit oops. The exact assignment of tags is not important to understand the basic concept, and Clement’s post has all the details.
> 
> - Bert -
> 
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20141205/4478a7c2/attachment.htm


More information about the Vm-dev mailing list