[Vm-dev] Compact class question

Gabriel Hernán Barbuto gbarbuto at gmail.com
Tue Dec 7 09:53:12 UTC 2010


Hi Yoshiki

Maybe I have not made myself clear about which expression my comment
referred to. Read my mail again, but I will copy it here again:

headerWords :=
       contentsWords > 63
               ifTrue: [3]
               ifFalse: [(cl indexIfCompact > 0) ifTrue: [1] ifFalse: [2]].

Replacing the 63 for a 62 will make the trick and besides if
contentsWords is greater than 62 it should be greater than or equal to
63. So what you propose is the same. But be careful that it's not in
totalWords expression.

I think this object should have a 3-word header. What do you think about this?

With respect to what we are doing. We are porting MicroSqueak to
Pharo. MicroSqueak could be useful for teaching. The next step(we are
also working in parallel on this) is to build kernel images but
different from MicroSqueak. In order to do that, we need to remove all
the bad dependencies on the kernel classes and clean up the Pharo
image. What are you doing with MicroSqueak?

Gabriel

On Mon, Dec 6, 2010 at 5:01 PM, Yoshiki Ohshima <yoshiki at vpri.org> wrote:
>
> At Mon, 6 Dec 2010 16:10:22 +0100,
> Gabriel Hernán Barbuto wrote:
>>
>>
>> Hi Bert
>>
>> Thanks for your response. I am using John's code and I think I am
>> seeing the same bug. But I think the problem is when the object is 63
>> words long.
>>
>> Ben found a method that produced a fail in an assertion. It's a
>> CompiledMethod instance that occupies 63 words. When the code makes
>> the calculation to see how many words it needs. It calculates that it
>> needs 1 word for the header and a total of 64 words for the object in
>> total. Because it needs to also take into account the word for the
>> header.
>>
>> I don't understand how you can encoded this object with a one word
>> header. I don't know about your fix. But I think the problem is that
>> this object cannot have a one word header. Because the size field only
>> allows for values up to 63 words and this value has to take the base
>> header word into account.
>>
>> The problem is that John's code calculate the total words that an
>> object requires in two different places, and does it slightly
>> different in each one.
>>
>> In MicroSqueakImageBuilder>>#headerAndTotalWords he calculates the
>> size of the object like this(CompiledMethod is variable and is bytes):
>>
>> contents = instSize + (basicSize + 3 // 4) + extraWords
>>
>> basicSize + 3 // 4 is called indexableWords in the other method.
>>
>> I think the problem is in the following expression:
>>
>> headerWords :=
>>       contentsWords > 63
>>               ifTrue: [3]
>>               ifFalse: [(cl indexIfCompact > 0) ifTrue: [1] ifFalse: [2]].
>>
>> It should check against 62, because if the object has 63 words of
>> content, it cannot have a one word header.
>
>  That would make it a two-off bug^^;  It should check against 63,
> with >=.
>
>> In MicroSqueakImageBuilder>>#writeObjHeaderFor:map:on:
>>
>> totalWords := instSize + indexableWords + extraWords + 1.
>>
>> The extra +1 in the last part of the expression make this particular
>> object to have a totalWords of 64, and so I think it cannot have a one
>> word header.
>>
>> totalWords > 63
>>       ifTrue: [  "3-word header"
>>       ifFalse: [
>>               cl indexIfCompact = 0
>>                       ifTrue: [  "2-word header"
>>                       ifFalse: [  "1-word header"]]
>>
>> I think the object should have a 3 word header. Can you explain me how
>> to encode the size of this object in a one word header. Because I
>> don't understand how to do this. Thanks in advance.
>
>  63 fits within the basic header's size field.
>
>  (We're having some fun with MicroSqueak.  It would be very
> interesting to hear what you guys are up to..)
>
> -- Yoshiki
>


More information about the Vm-dev mailing list