<br><br><div class="gmail_quote">On Fri, Sep 16, 2011 at 12:08 PM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@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;">
2011/9/16 Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt;:<br>
<div class="im">&gt; 2011/9/16 Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt;:<br>
&gt;&gt; I don&#39;t really know. I have implemented what Eliot say in the first option<br>
&gt;&gt; and it is working for me.<br>
&gt;&gt; Do you (Henry/Lukas/Nicolas/Eliot) agree to have this first solution and<br>
&gt;&gt; then improve it if necessary ?<br>
&gt;&gt;<br>
&gt;&gt; thanks<br>
&gt;&gt;<br>
&gt;<br>
&gt; I agree on Mariano/Eliot solution. It is a good pragmatic short term workaround.<br>
&gt; In the long term, I wish I can say goodbye to my new super power, it&#39;s<br>
&gt; a too dangerous power.<br>
&gt; So I wish the VM would change (along with ClassBuilder and Tools).<br></div></blockquote><div><br></div><div>Yes, I agree.  It just takes time to get there.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">
&gt;<br>
&gt; Nicolas<br>
&gt;<br>
<br>
</div>Or maybe after reading:<br>
<div class="im"><br>
    literal1 := self literalAt: numLits.<br>
    literal2 := method literalAt: numLits.<br>
</div>    ^ (literal1 == literal2) or: [literal1 key isNil == literal2 key<br>
isNil and: [literal1 value == literal2 value]].<br>
<br>
I we are sure that the last literal is always an Association<br></blockquote><div><br></div><div>If it&#39;s not then one is playing fast and loose with the system.  But if the method doesn&#39;t contain a super send then as far as the VM is concerned it doesn&#39;t need an association, and that might be the case with, for example, shared inst var accessors in Newspeak.  So instead of assuming its an association write it something like</div>
<div><br></div><div>    ^literal1 class == literal2 class</div><div>     and: [literal1 isVariableBinding</div><div>                ifTrue: [literal1 key = literal2 key and: [literal1 value = literal2 value]]</div><div>                ifFalse: [literal1 = literal2]]</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
Nicolas<br>
<br>
&gt;&gt; On Fri, Sep 16, 2011 at 8:12 PM, Stéphane Ducasse<br>
&gt;&gt; &lt;<a href="mailto:stephane.ducasse@inria.fr">stephane.ducasse@inria.fr</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Mariano<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; So should we intgerate a fix?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Stef<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Sep 15, 2011, at 11:27 PM, Mariano Martinez Peck wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; BUT, it doesn&#39;t mean that Association is always used for globals.<br>
&gt;&gt;&gt; &gt; CompiledMethod equality is failing because of the last literal, the one that<br>
&gt;&gt;&gt; &gt; maps class name (symbol) and point to the real class. So...when I<br>
&gt;&gt;&gt; &gt; materialize, both CMs have non-identical associations for the last literal,<br>
&gt;&gt;&gt; &gt; but equal.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; As Henrik says the last literals are ideally #== to each other.<br>
&gt;&gt;&gt; &gt;  However, no Squeak dialect makes any attempt to keep the class0side<br>
&gt;&gt;&gt; &gt; associations equal. Look at a class-side method and you&#39;ll see it&#39;s last<br>
&gt;&gt;&gt; &gt; literal is nil-&gt;SomeClass class.  Now since this association doesn&#39;t exist<br>
&gt;&gt;&gt; &gt; in Smalltalk (unlike last literals on the instance side) the compiler merely<br>
&gt;&gt;&gt; &gt; creates distinct ones for each class-side method.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Thanks Eliot for that point. In fact, I have just checked and you are<br>
&gt;&gt;&gt; &gt; right. The tests that are failing for me is those where class side methods<br>
&gt;&gt;&gt; &gt; are involded. In this case, the last literal of the original CM and the<br>
&gt;&gt;&gt; &gt; materialized, gives false in #literalEqual:   hence,  originalCM =<br>
&gt;&gt;&gt; &gt; materializedCM is false :(<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Personally I don&#39;t think one can defend the position where method<br>
&gt;&gt;&gt; &gt; equality is different for instance-side or class-side methods so there must<br>
&gt;&gt;&gt; &gt; be some solutions:<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; 1. special case comparison of the last literal (the methodClass<br>
&gt;&gt;&gt; &gt; literal), comparing keys and insisting that the keys be #== and the values<br>
&gt;&gt;&gt; &gt; be #== (can&#39;t just define it as keys #== since all similar class-side<br>
&gt;&gt;&gt; &gt; methods will be equal irrespective of their actual class).<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; This one seems the easier and fixes my problem :)<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; sameLiteralsAs: method<br>
&gt;&gt;&gt; &gt;     &quot;Compare my literals to those of method. This is needed to compare<br>
&gt;&gt;&gt; &gt; compiled methods.&quot;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;     | numLits literal1 literal2 |<br>
&gt;&gt;&gt; &gt;     (numLits := self numLiterals) ~= method numLiterals<br>
&gt;&gt;&gt; &gt;         ifTrue: [ ^ false ].<br>
&gt;&gt;&gt; &gt;     &quot;The last literal requires special checking instead of using<br>
&gt;&gt;&gt; &gt; #literalEqual:&quot;<br>
&gt;&gt;&gt; &gt;     1 to: numLits - 1 do: [ :index |<br>
&gt;&gt;&gt; &gt;         literal1 := self literalAt: index.<br>
&gt;&gt;&gt; &gt;         literal2 := method literalAt: index.<br>
&gt;&gt;&gt; &gt;         (literal1 == literal2 or: [ literal1 literalEqual: literal2 ])<br>
&gt;&gt;&gt; &gt;             ifFalse: [<br>
&gt;&gt;&gt; &gt;                 (index = 1 and: [ #(117 120) includes: self primitive ])<br>
&gt;&gt;&gt; &gt;                     ifTrue: [<br>
&gt;&gt;&gt; &gt;                         literal1 isArray<br>
&gt;&gt;&gt; &gt;                             ifTrue: [<br>
&gt;&gt;&gt; &gt;                                 (literal2 isArray and: [ literal1<br>
&gt;&gt;&gt; &gt; allButLast = literal2 allButLast ])<br>
&gt;&gt;&gt; &gt;                                     ifFalse: [ self halt. ^ false ] ]<br>
&gt;&gt;&gt; &gt;                             ifFalse: [<br>
&gt;&gt;&gt; &gt;                                 &quot;ExternalLibraryFunction&quot;<br>
&gt;&gt;&gt; &gt;                                 (literal1 analogousCodeTo: literal2)<br>
&gt;&gt;&gt; &gt;                                     ifFalse: [ self halt. ^ false ] ] ]<br>
&gt;&gt;&gt; &gt;                     ifFalse: [<br>
&gt;&gt;&gt; &gt;                         index = (numLits - 1)<br>
&gt;&gt;&gt; &gt;                             ifTrue: [<br>
&gt;&gt;&gt; &gt;                                 &quot;properties&quot;<br>
&gt;&gt;&gt; &gt;                                 (self properties analogousCodeTo: method<br>
&gt;&gt;&gt; &gt; properties)<br>
&gt;&gt;&gt; &gt;                                     ifFalse: [ self halt. ^ false ] ]<br>
&gt;&gt;&gt; &gt;                             ifFalse: [ self halt. ^ false ] ] ] ].<br>
&gt;&gt;&gt; &gt;     literal1 := self literalAt: numLits.<br>
&gt;&gt;&gt; &gt;     literal2 := method literalAt: numLits.<br>
&gt;&gt;&gt; &gt;     ^ ((literal1 key == literal2 key) and: [literal1 value == literal2<br>
&gt;&gt;&gt; &gt; value]).<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; 2. special case comparison of the last literal (the methodClass<br>
&gt;&gt;&gt; &gt; literal), insisting only that the class of the literal be the same if it<br>
&gt;&gt;&gt; &gt; isVariableBinding.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; 3. make the compile unique class-side methodClass literals.  i.e. if a<br>
&gt;&gt;&gt; &gt; class already has a class-side method then the compiler or method dictionary<br>
&gt;&gt;&gt; &gt; insertion code must find that existing association and reuse it<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Other ideas?<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt;From my point of view, that literal, the last one does not need to be<br>
&gt;&gt;&gt; &gt; identical to assume 2 CMs are equal. They just need to be equal.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; --<br>
&gt;&gt;&gt; &gt; Mariano<br>
&gt;&gt;&gt; &gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; --<br>
&gt;&gt;&gt; &gt; best,<br>
&gt;&gt;&gt; &gt; Eliot<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; --<br>
&gt;&gt;&gt; &gt; Mariano<br>
&gt;&gt;&gt; &gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Mariano<br>
&gt;&gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>