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