[Vm-dev] Re: [squeak-dev] Immediate and heap objects
Ben Coman
btc at openInWorld.com
Fri Dec 5 12:49:10 UTC 2014
Bert Freudenberg 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."
>>
How about "For immediate objects, the tag bits encode the class..."
>>
>> 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 think the reference to Huffman coding is distracting. I probably once
knew what it was, but now I had to look it up and the few pages I looked
at did not add any value in the first few paragraphs.
cheers -ben
>
> 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 -
>
>
>
More information about the Vm-dev
mailing list