The Trunk: Kernel-eem.692.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-eem.692.mcz

commits-2
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.692.mcz

==================== Summary ====================

Name: Kernel-eem.692
Author: eem
Time: 27 May 2012, 3:08:41.389 pm
UUID: 72f75218-3cfc-4575-b159-8de0e44aa479
Ancestors: Kernel-nice.691

Implement CompiledMethod>>#hash, both to accord with
CompiledMethod>>#= and to override ByteArray>>#hash
which looks at all bytes of the receiver and hence may
produce a variable hash if the GC moves literals in a method.

=============== Diff against Kernel-nice.691 ===============

Item was added:
+ ----- Method: CompiledMethod>>hash (in category 'comparing') -----
+ hash
+ "CompiledMethod>>#= compares code, i.e. same literals and same bytecode.
+ So we look at the header, methodClass and some bytes between initialPC and endPC,
+ but /not/ the selector because the equal method does not compare selectors.
+ Note that we must override ByteArray>hash which looks at all bytes of the receiver.
+ Using bytes from the pointer part of a COmpiledmethod can lead to a variable hash
+ if and when when the GC moves literals in the receiver."
+ | initialPC endPC hash |
+ initialPC := self initialPC.
+ endPC := self endPC.
+ hash := self species hash + self header + initialPC + endPC + self methodClass hash bitAnd: 16rFFFFFFF.
+ "sample approximately 20 bytes"
+ initialPC to: endPC by: (endPC - initialPC // 20 max: 1) do:
+ [:i| hash := hash + (self at: i)].
+ ^hash
+
+ "(CompiledMethod>>#hash) hash"!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-eem.692.mcz

Levente Uzonyi-2
It's a bit dangerous to change the hash without rehashing the collections
which contain CompiledMethods as keys. For example DebuggerMethodMap's
MapCache uses CompiledMethods as keys.


Levente

On Sun, 27 May 2012, [hidden email] wrote:

> Eliot Miranda uploaded a new version of Kernel to project The Trunk:
> http://source.squeak.org/trunk/Kernel-eem.692.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-eem.692
> Author: eem
> Time: 27 May 2012, 3:08:41.389 pm
> UUID: 72f75218-3cfc-4575-b159-8de0e44aa479
> Ancestors: Kernel-nice.691
>
> Implement CompiledMethod>>#hash, both to accord with
> CompiledMethod>>#= and to override ByteArray>>#hash
> which looks at all bytes of the receiver and hence may
> produce a variable hash if the GC moves literals in a method.
>
> =============== Diff against Kernel-nice.691 ===============
>
> Item was added:
> + ----- Method: CompiledMethod>>hash (in category 'comparing') -----
> + hash
> + "CompiledMethod>>#= compares code, i.e. same literals and same bytecode.
> + So we look at the header, methodClass and some bytes between initialPC and endPC,
> + but /not/ the selector because the equal method does not compare selectors.
> + Note that we must override ByteArray>hash which looks at all bytes of the receiver.
> + Using bytes from the pointer part of a COmpiledmethod can lead to a variable hash
> + if and when when the GC moves literals in the receiver."
> + | initialPC endPC hash |
> + initialPC := self initialPC.
> + endPC := self endPC.
> + hash := self species hash + self header + initialPC + endPC + self methodClass hash bitAnd: 16rFFFFFFF.
> + "sample approximately 20 bytes"
> + initialPC to: endPC by: (endPC - initialPC // 20 max: 1) do:
> + [:i| hash := hash + (self at: i)].
> + ^hash
> +
> + "(CompiledMethod>>#hash) hash"!
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-eem.692.mcz

Eliot Miranda-2


On Sun, May 27, 2012 at 8:37 PM, Levente Uzonyi <[hidden email]> wrote:
It's a bit dangerous to change the hash without rehashing the collections which contain CompiledMethods as keys. For example DebuggerMethodMap's MapCache uses CompiledMethods as keys.


Good point.  I'll fix this when I fix the methods comment ( COmpiledmethod => CompiledMethod)
 



Levente


On Sun, 27 May 2012, [hidden email] wrote:

Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.692.mcz

==================== Summary ====================

Name: Kernel-eem.692
Author: eem
Time: 27 May 2012, 3:08:41.389 pm
UUID: 72f75218-3cfc-4575-b159-8de0e44aa479
Ancestors: Kernel-nice.691

Implement CompiledMethod>>#hash, both to accord with
CompiledMethod>>#= and to override ByteArray>>#hash
which looks at all bytes of the receiver and hence may
produce a variable hash if the GC moves literals in a method.

=============== Diff against Kernel-nice.691 ===============

Item was added:
+ ----- Method: CompiledMethod>>hash (in category 'comparing') -----
+ hash
+       "CompiledMethod>>#= compares code, i.e. same literals and same bytecode.
+        So we look at the header, methodClass and some bytes between initialPC and endPC,
+        but /not/ the selector because the equal method does not compare selectors.
+        Note that we must override ByteArray>hash which looks at all bytes of the receiver.
+        Using bytes from the pointer part of a COmpiledmethod can lead to a variable hash
+        if and when when the GC moves literals in the receiver."
+       | initialPC endPC hash |
+       initialPC := self initialPC.
+       endPC := self endPC.
+       hash := self species hash + self header + initialPC + endPC + self methodClass hash bitAnd: 16rFFFFFFF.
+       "sample approximately 20 bytes"
+       initialPC to: endPC by: (endPC - initialPC // 20 max: 1) do:
+               [:i| hash := hash + (self at: i)].
+       ^hash
+
+       "(CompiledMethod>>#hash) hash"!







--
best,
Eliot



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-eem.692.mcz

Nicolas Cellier
I recently added a rehashAll in Kernel postscript due to a change in
dataAndTime>>hash

Nicolas

2012/5/30 Eliot Miranda <[hidden email]>:

>
>
> On Sun, May 27, 2012 at 8:37 PM, Levente Uzonyi <[hidden email]> wrote:
>>
>> It's a bit dangerous to change the hash without rehashing the collections
>> which contain CompiledMethods as keys. For example DebuggerMethodMap's
>> MapCache uses CompiledMethods as keys.
>
>
>
> Good point.  I'll fix this when I fix the methods comment ( COmpiledmethod
> => CompiledMethod)
>
>>
>>
>>
>>
>> Levente
>>
>>
>> On Sun, 27 May 2012, [hidden email] wrote:
>>
>>> Eliot Miranda uploaded a new version of Kernel to project The Trunk:
>>> http://source.squeak.org/trunk/Kernel-eem.692.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: Kernel-eem.692
>>> Author: eem
>>> Time: 27 May 2012, 3:08:41.389 pm
>>> UUID: 72f75218-3cfc-4575-b159-8de0e44aa479
>>> Ancestors: Kernel-nice.691
>>>
>>> Implement CompiledMethod>>#hash, both to accord with
>>> CompiledMethod>>#= and to override ByteArray>>#hash
>>> which looks at all bytes of the receiver and hence may
>>> produce a variable hash if the GC moves literals in a method.
>>>
>>> =============== Diff against Kernel-nice.691 ===============
>>>
>>> Item was added:
>>> + ----- Method: CompiledMethod>>hash (in category 'comparing') -----
>>> + hash
>>> +       "CompiledMethod>>#= compares code, i.e. same literals and same
>>> bytecode.
>>> +        So we look at the header, methodClass and some bytes between
>>> initialPC and endPC,
>>> +        but /not/ the selector because the equal method does not compare
>>> selectors.
>>> +        Note that we must override ByteArray>hash which looks at all
>>> bytes of the receiver.
>>> +        Using bytes from the pointer part of a COmpiledmethod can lead
>>> to a variable hash
>>> +        if and when when the GC moves literals in the receiver."
>>> +       | initialPC endPC hash |
>>> +       initialPC := self initialPC.
>>> +       endPC := self endPC.
>>> +       hash := self species hash + self header + initialPC + endPC +
>>> self methodClass hash bitAnd: 16rFFFFFFF.
>>> +       "sample approximately 20 bytes"
>>> +       initialPC to: endPC by: (endPC - initialPC // 20 max: 1) do:
>>> +               [:i| hash := hash + (self at: i)].
>>> +       ^hash
>>> +
>>> +       "(CompiledMethod>>#hash) hash"!
>>>
>>>
>>>
>>
>
>
>
> --
> best,
> Eliot
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-eem.692.mcz

Bert Freudenberg
On 30.05.2012, at 01:43, Nicolas Cellier wrote:

> I recently added a rehashAll in Kernel postscript due to a change in
> dataAndTime>>hash
>
> Nicolas


Just keep in mind that like all other MC definitions, postscripts will only be executed if they were modified.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-eem.692.mcz

Nicolas Cellier
2012/5/30 Bert Freudenberg <[hidden email]>:

> On 30.05.2012, at 01:43, Nicolas Cellier wrote:
>
>> I recently added a rehashAll in Kernel postscript due to a change in
>> dataAndTime>>hash
>>
>> Nicolas
>
>
> Just keep in mind that like all other MC definitions, postscripts will only be executed if they were modified.
>
> - Bert -
>
>

Ah thanks, that always bugs me.