<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
More than that, since CompiledMethod redefines #=, it is strange that<br>
it's not redefines #hash as well,<br>
because it is one of requirements to make sure they are always in sync.<br>
<br></blockquote><div><br>indeed!<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> Two conclusions:<br>
><br>
> 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.<br>
><br>
Yes, i would just do<br>
<br>
self methodClass hash bitXor: self selector hash<br>
<br></blockquote><div class="h5"><br>that's one possibility. If we want to continue with the previous kind of hash we also could do something like:<br><br>CompiledMethod >> hash<br> "#hash is implemented, because #= is implemented"<br>
<br> ^self class<br> hashBytes: self bytecodes<br> startingWith: self species hash<br> <br><br>CompiledMethod >> bytecodes<br> | initialPC endPC bytecodes |<br> initialPC := self initialPC.<br>
endPC := self endPC.<br> bytecodes := ByteArray new: (endPC - initialPC + 1).<br> initialPC to: endPC do: [:index |<br> bytecodes at: (index - initialPC + 1) put: (self at: index)<br> ].<br> ^ bytecodes<br>
<br><br>I am not a hashing expert. What do you think? which impl should we do?<br> </div></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
<br>