<br><br><div class="gmail_quote">On Mon, Jun 6, 2011 at 4:21 AM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

 <br><br><br><div class="gmail_quote">On Mon, Jun 6, 2011 at 6:09 AM, Javier Pimás <span dir="ltr">&lt;<a href="mailto:elpochodelagente@gmail.com" target="_blank">elpochodelagente@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


 <br>Hi, I&#39;m investigating the format of objects in memory. After some time I got this conclusions/questions I&#39;d like to know more about:<div><br></div><div>- Oops must be at least 16 bits aligned, because of SmallIntegers tagging, is that right?</div>


</blockquote><div><br>Aren&#39;t they 31 bits? There is only one tag bit. <br>SmallInteger maxVal = 1073741823<br>(2 raisedTo: 30) - 1 1073741823 <br>30 because there is another bit for the sign I think.</div></div></blockquote>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">




<div>- Raw object sizes are 32 bits aligned, because of size field in header which is in 32 bits words. So that for byte indexed instances there may be at most 3 wasted bytes (format field in that case tell the amount not used of the last 4 bytes).</div>


</blockquote><div><br>Yes, for example &#39;a&#39;, &#39;bb&#39;, &#39;ccc&#39; and &#39;dddd&#39; they all occupy 4 bytes in the VM (we discuss about that recently in the thread of Fuel I think). The VM knows how much are really used by accessing the &quot;size&quot; value in the object header.</div>

</div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div>
 </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div> Is that the way that the VM assures the alignment of the oops?</div>

<div>- And the last one and the most puzzling for me: how does objectAfter: anOop work? I mean, for what I see, it returns the addition of anOop and the size of the object pointed by anOop, but how can it be sure that that is the base header and not the size or class field of the extended header?</div>




<div><br clear="all"></div></blockquote><div><br>I am not sure if I understood. #objectAfter:  uses #sizeBitsOf:<br><br>sizeBitsOf: oop<br>    &quot;Answer the number of bytes in the given object, including its base header, rounded up to an integral number of words.&quot;<br>


    &quot;Note: byte indexable objects need to have low bits subtracted from this size.&quot;<br><br>    | header |<br>    header := self baseHeader: oop.<br>    (header bitAnd: TypeMask) = HeaderTypeSizeAndClass<br>        ifTrue: [ ^ (self sizeHeader: oop) bitAnd: LongSizeMask ]<br>


        ifFalse: [ ^ header bitAnd: SizeMask ].<br><br></div></div></blockquote><div><br></div><div>Then suppose you have a point. Its size is 12 bytes (1 for header, 1 for x and 1 for y). Now after the point there is a not compact class (with 1 int extra header). When you ask objectAfter: thePoint, it will calculate first something like</div>

<div><br></div><div>chunkOop := thePoint + thePoint size</div><div><br></div><div>which is thePoint + 12. That is not the actual oop but the extra header, then it returns:</div><div><br></div><div>^self oopFromChunk: chunkOop.</div>

<div><br></div><div>So that would imply the extra header has also two type bits, right? But then what happens to the penultimate bit of the oop? Finally, can we assume all header fields have this type field? A better question would be, what is the bit format of the extra header?</div>

<div><br></div><div>Thanks again!</div><div>                   Javier.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div>

 </div></div>Cheers<br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Javier Pimás<br>Ciudad de Buenos Aires<br>