[Vm-dev] Compact class question

Yoshiki Ohshima yoshiki at vpri.org
Mon Dec 6 16:01:44 UTC 2010


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