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