<br><br><div class="gmail_quote">On Tue, Sep 28, 2010 at 11:11 AM, Henrik Johansen <span dir="ltr">&lt;<a href="mailto:henrik.s.johansen@veloxit.no">henrik.s.johansen@veloxit.no</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><div style="word-wrap: break-word;"><br><div><div>On Sep 28, 2010, at 9:36 27AM, Mariano Martinez Peck wrote:</div><br><blockquote type="cite"><br><br><div class="gmail_quote">On Tue, Sep 28, 2010 at 6:46 AM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</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>
2010/9/27 Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;:<br>
<div>&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Sep 27, 2010 at 12:20 PM, Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Sep 22, 2010 at 12:34 PM, Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Wed, Sep 22, 2010 at 12:12 PM, Henrik Johansen &lt;<a href="mailto:henrik.s.johansen@veloxit.no" target="_blank">henrik.s.johansen@veloxit.no</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On Sep 22, 2010, at 9:59 40AM, Adrian Lienhard wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &gt; Some notes:<br>
&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt; &gt; - What should be answered for small ints? 1 sizeInMemory --&gt;8. That&#39;s wrong. Shouldn&#39;t this answer 0?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Philosophical question really, imo both 4 (Again, in 32bit images at least) and 0 would be &quot;correct&quot; answers in their own ways. 8 is definitely wrong though :)<br>
&gt;&gt;&gt;&gt; The method comment should probably highlight which definition is used.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; So....what should we consider for SmallInteger ?   4 bytes or 0 bytes?<br>
&gt;<br>
</div>&gt; 0 bytes, obviously.  The only space occupied by a SmallInteger is the space of the slot containing it.  There is no SmallInteger object beyond the slot.<br>
&gt;<br>
<br>
Or from another POV, it&#39;s 4, the size of the slot. But we don&#39;t count<br>
the size of the slots, they are already counted in the containing<br>
object, that&#39;s why it should answer 0.<br></blockquote><div><br><br>Thanks for the answers. I finally let this:<br><br>sizeInMemory<br>    &quot;Answer the number of bytes consumed by this instance including object header.&quot;<br>

    | isCompact headerBytes contentBytes |<br><br>    &quot;SmallInteger occupy 0 bytes since the only space occupied by a SmallInteger is the space of the slot containing it.  There is no SmallInteger object beyond the slot. From another POV, it could be 4, the size of the slot. But we don&#39;t count the size of the slots, they are already counted in the containing object, that&#39;s why it should answer 0.&quot;<br>

    (self isMemberOf: SmallInteger) ifTrue: [^0]. <br><br>     contentBytes := self class instSize * Smalltalk wordSize. &quot;inst vars&quot;<br><br>     self class isVariable ifTrue:[ |bytesPerElement|<br>            bytesPerElement := self class isBytes ifTrue: [1] ifFalse: [4].<br>

            contentBytes := contentBytes + (self basicSize * bytesPerElement)].<br><br>     isCompact := self class indexIfCompact &gt; 0.<br>      headerBytes :=<br>                    contentBytes &gt; 255<br>                        ifTrue: [ 3 * Smalltalk wordSize ] <br>

                        ifFalse: [isCompact ifTrue: [Smalltalk wordSize] ifFalse: [2 * Smalltalk wordSize]].<br>            ^ headerBytes + contentBytes<br><br><br>Now I wonder...maybe instead of doing this it is easier to have a primitive that just calls #internalByteSize: ?<br>

The problem of course is that it needs changes in the vm...<br><br>cheers<br><br>Mariano<br> </div></div></blockquote>isMemberOf: is so quaint...</div><div><br></div><div>Why not </div><div>SmallInteger&gt;&gt;sizeInMemory</div>
<div><span style="white-space: pre-wrap;">        </span>    &quot;SmallInteger occupy 0 bytes since the only space occupied by a SmallInteger is the space of the slot containing it.  </div><div><span style="white-space: pre-wrap;">                </span>There is no SmallInteger object beyond the slot. </div>
<div><span style="white-space: pre-wrap;">                </span>From another POV, it could be 4, the size of the slot. But we don&#39;t count the size of the slots, they are already counted in the containing object, that&#39;s why it should answer 0.&quot;</div>
<div><span style="white-space: pre-wrap;">        </span>^0</div><div><br></div><div>and remove that part from the Object implementation.</div><div><br></div></div></blockquote><div><br>Uffff thanks Henrik for enlight me and teach me. Shame on me. I think that too much paper writting, ppt and admin tasks are killing me :(<br>
But don&#39;t worry, now I will come to code again! Hope to recover... :)<br><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 style="word-wrap: break-word;">
<div></div><div>Cheers,</div><div>Henry</div></div><br></blockquote></div><br>