[squeak-dev] The Trunk: Kernel-eem.692.mcz
Nicolas Cellier
nicolas.cellier.aka.nice at gmail.com
Tue May 29 23:43:48 UTC 2012
I recently added a rehashAll in Kernel postscript due to a change in
dataAndTime>>hash
Nicolas
2012/5/30 Eliot Miranda <eliot.miranda at gmail.com>:
>
>
> On Sun, May 27, 2012 at 8:37 PM, Levente Uzonyi <leves at elte.hu> 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, commits at source.squeak.org 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
>
>
>
>
More information about the Squeak-dev
mailing list
|