[Vm-dev] Re: [Pharo-project] VM problem?
Mariano Martinez Peck
marianopeck at gmail.com
Sun May 27 16:15:51 UTC 2012
> More than that, since CompiledMethod redefines #=, it is strange that
> it's not redefines #hash as well,
> because it is one of requirements to make sure they are always in sync.
>
>
indeed!
>
> > Two conclusions:
> >
> > The solution is to define CompiledMethod>hash such that it does not
> access bytes < initialPC. The hash it is inheriting from ByteArray is fine
> for ByteArray but not at all OK for CompiledMethod.
> >
> Yes, i would just do
>
> self methodClass hash bitXor: self selector hash
>
>
that's one possibility. If we want to continue with the previous kind of
hash we also could do something like:
CompiledMethod >> hash
"#hash is implemented, because #= is implemented"
^self class
hashBytes: self bytecodes
startingWith: self species hash
CompiledMethod >> bytecodes
| initialPC endPC bytecodes |
initialPC := self initialPC.
endPC := self endPC.
bytecodes := ByteArray new: (endPC - initialPC + 1).
initialPC to: endPC do: [:index |
bytecodes at: (index - initialPC + 1) put: (self at: index)
].
^ bytecodes
I am not a hashing expert. What do you think? which impl should we do?
--
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20120527/4c022808/attachment.htm
More information about the Vm-dev
mailing list