<br><br><div class="gmail_quote">On Sun, May 27, 2012 at 8:37 PM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It&#39;s a bit dangerous to change the hash without rehashing the collections which contain CompiledMethods as keys. For example DebuggerMethodMap&#39;s MapCache uses CompiledMethods as keys.</blockquote><div><br></div><div>
<br></div><div>Good point.  I&#39;ll fix this when I fix the methods comment ( <span class="Apple-style-span" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">COmpiledmethod =&gt; </span><span class="Apple-style-span" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">CompiledMethod)</span></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
Levente</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Sun, 27 May 2012, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Eliot Miranda uploaded a new version of Kernel to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Kernel-eem.692.mcz" target="_blank">http://source.squeak.org/<u></u>trunk/Kernel-eem.692.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Kernel-eem.692<br>
Author: eem<br>
Time: 27 May 2012, 3:08:41.389 pm<br>
UUID: 72f75218-3cfc-4575-b159-<u></u>8de0e44aa479<br>
Ancestors: Kernel-nice.691<br>
<br>
Implement CompiledMethod&gt;&gt;#hash, both to accord with<br>
CompiledMethod&gt;&gt;#= and to override ByteArray&gt;&gt;#hash<br>
which looks at all bytes of the receiver and hence may<br>
produce a variable hash if the GC moves literals in a method.<br>
<br>
=============== Diff against Kernel-nice.691 ===============<br>
<br>
Item was added:<br>
+ ----- Method: CompiledMethod&gt;&gt;hash (in category &#39;comparing&#39;) -----<br>
+ hash<br>
+       &quot;CompiledMethod&gt;&gt;#= compares code, i.e. same literals and same bytecode.<br>
+        So we look at the header, methodClass and some bytes between initialPC and endPC,<br>
+        but /not/ the selector because the equal method does not compare selectors.<br>
+        Note that we must override ByteArray&gt;hash which looks at all bytes of the receiver.<br>
+        Using bytes from the pointer part of a COmpiledmethod can lead to a variable hash<br>
+        if and when when the GC moves literals in the receiver.&quot;<br>
+       | initialPC endPC hash |<br>
+       initialPC := self initialPC.<br>
+       endPC := self endPC.<br>
+       hash := self species hash + self header + initialPC + endPC + self methodClass hash bitAnd: 16rFFFFFFF.<br>
+       &quot;sample approximately 20 bytes&quot;<br>
+       initialPC to: endPC by: (endPC - initialPC // 20 max: 1) do:<br>
+               [:i| hash := hash + (self at: i)].<br>
+       ^hash<br>
+<br>
+       &quot;(CompiledMethod&gt;&gt;#hash) hash&quot;!<br>
<br>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>