<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks for the answer.<div><br><div>Clement I love your questions :)</div><div>Stef</div><div><br><div><div>On Nov 12, 2013, at 7:33 PM, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Hi&nbsp;Clément,<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 12, 2013 at 3:56 AM, Clément Bera <span dir="ltr">&lt;<a href="mailto:bera.clement@gmail.com" target="_blank">bera.clement@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">&nbsp;<br><div dir="ltr">Hey,<div><br></div><div>By the way as you are talking about Immediate objects tags and Spur's object representation, I read on other VMs reports that it is faster in overall performance to have pointers tagged with the xxx1 and SmallIntegers tagged with xxx0, because SmallIntegers arithmetics is then much faster.</div>
</div></blockquote><div><br></div><div>I'm sure that was true 20 years ago when register operations were about the same speed as memory operations. &nbsp;But now that memory operations are at least an order of magnitude slower I suspect that adjusting the tags (all register operations) are in the noise. &nbsp;But I agree it *would* be interesting to measure.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div> Is it possible to modify that easily in Cog to try ? Do you have to edit only a few methods such as #longAt:, #integerValueOf: and SmallInteger primitives ?</div>
</div></blockquote><div><br></div><div>You'd have to modify the isImmediate:/isNonImmediate:, isIntegerObject:, isNonIntegerObject:, and storePointer:ofObject:withValue:/fetchPointer:ofObject: methods, and then the code generated by the CogObjectRepresentation subclass, and modify the bootstrap to produce an image with the new tagging. &nbsp;The VM is factored so that this isn't horribly difficult. &nbsp;But it's work. &nbsp;Perhaps it would be a good student project?</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">

<div><br></div><div>Another thing, I read in a java VM report that only 1% of objects needs a hash (other objects hash are unused), so their hash implementation took only 2 bits in the header, being:</div><div>01 -&gt; no hash</div>


<div>10 -&gt; hash is the object's address</div><div>11 -&gt; hash is in a header extension</div><div>Therefore, on first access to the hash, hash bits switches from 01 to 10, and the GC on objects with 10 switches the hash bits from 10 to 11 and add a header extension with the old address of the object. But I know I'm not teaching you anything there.</div>
</div></blockquote><div><br></div><div>That's clever.&nbsp;Yes you are :-). &nbsp;Thanks.</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
 What I would like to know is why did you choose in Spur to have a 22bits hash in the header over this implementation, and will the hash in Spur be calculated at each instantiation or lazily ?</div></blockquote><div>
<br></div><div>&nbsp;I chose the 22 bit hash scheme because it is part of the idea of having class indices. &nbsp;Notice that an object's class index is 22 bits also. &nbsp;The point here is that a class's hash is its class index. &nbsp;So to instantiate a class one copies the class's hash into the instance's class index, avoiding searching the class table to find the class's index. &nbsp;Perhaps this isn't the most optimal approach but it is coherent, and worked well for 64-bit VisualWorks.</div>
<div><br></div><div>The hash calculation is lazy. &nbsp;The hash field is 0 when instantiated. &nbsp;Hence</div><div><br></div><div><div>Behavior&gt;&gt;identityHash</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>"Answer a SmallInteger whose value is related to the receiver's identity.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>This method must not be overridden.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Primitive. Fails if the receiver is not a Behavior. Essential.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>See Object documentation whatIsAPrimitive.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Do not override."</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;primitive: 175&gt;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>self primitiveFailed</div></div><div><br></div>
<div><div>InterpreterPrimitives&gt;&gt;primitiveBehaviorHash</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>| hashOrError |</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>self assert: ((objectMemory isNonImmediate: self stackTop)</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span> and: [self addressCouldBeClassObj: self stackTop]).</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>hashOrError := objectMemory ensureBehaviorHash: self stackTop.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>hashOrError &gt;= 0</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ifTrue: [self pop: argumentCount + 1 thenPushInteger: hashOrError]</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>ifFalse: [self primitiveFailFor: hashOrError negated]</div></div><div><br></div><div><div>SpurMemoryManager&gt;&gt;ensureBehaviorHash: aBehavior</div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>| newHash err |</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;inline: true&gt;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>self assert: (coInterpreter addressCouldBeClassObj: aBehavior).</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>(newHash := self rawHashBitsOf: aBehavior) = 0 ifTrue:</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>[(err := self enterIntoClassTable: aBehavior) ~= 0 ifTrue:</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>[^err negated].</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> newHash := self rawHashBitsOf: aBehavior.</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> self assert: (self classAtIndex: newHash) = aBehavior].</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>^newHash</div></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">

<div><br></div><div>Thanks for any answers,</div><div><br></div><div>Regards, Clement</div></div></blockquote><div><br></div><div>cheers!</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/12 Henrik Johansen <span dir="ltr">&lt;<a href="mailto:henrik.s.johansen@veloxit.no" target="_blank">henrik.s.johansen@veloxit.no</a>&gt;</span><br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&nbsp;<br><div style="word-wrap:break-word"><br><div><div>On 12 Nov 2013, at 11:55 , Henrik Johansen &lt;<a href="mailto:henrik.s.johansen@veloxit.no" target="_blank">henrik.s.johansen@veloxit.no</a>&gt; wrote:</div>


<br><blockquote type="cite"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">nterest ~= time and: [skills]<span>&nbsp;</span></span></div>


</blockquote></div><br><div>OT: I swear, missing parenthesis will be the death of me!</div></div><br></blockquote></div><br></div>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div>
</div></div>
</blockquote></div><br></div></div></body></html>