<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">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.<br> </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.<br>
 </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>Cheers<br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>