[pypy-commit] pypy default: Hopefully fix 96e2837af4ec. It was already causing some

arigo noreply at buildbot.pypy.org
Tue Jul 26 14:33:27 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r46003:841f3e129c5b
Date: 2011-07-26 14:33 +0200
http://bitbucket.org/pypy/pypy/changeset/841f3e129c5b/

Log:	Hopefully fix 96e2837af4ec. It was already causing some failures,
	which are now fixed; at least:

	 test_newgc.TestMiniMarkGC.test_hash_preservation
	test_newgc.TestMiniMarkGCMostCompact.test_hash_preservation and
	probably jit.backend.x86.test.test_z*.py.

diff --git a/pypy/rpython/memory/gc/minimark.py b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -1733,7 +1733,7 @@
     # ----------
     # id() and identityhash() support
 
-    def id_or_identityhash(self, gcobj, special_case_prebuilt):
+    def id_or_identityhash(self, gcobj, is_hash):
         """Implement the common logic of id() and identityhash()
         of an object, given as a GCREF.
         """
@@ -1776,7 +1776,7 @@
                 # The answer is the address of the shadow.
                 obj = shadow
                 #
-            elif special_case_prebuilt:
+            elif is_hash:
                 if self.header(obj).tid & GCFLAG_HAS_SHADOW:
                     #
                     # For identityhash(), we need a special case for some
@@ -1786,15 +1786,18 @@
                     # because the stored value might clash with a real one.
                     size = self.get_size(obj)
                     return (obj + size).signed[0]
+                    # Important: the returned value is not mangle_hash()ed!
         #
-        return llmemory.cast_adr_to_int(obj)
-
+        i = llmemory.cast_adr_to_int(obj)
+        if is_hash:
+            i = mangle_hash(i)
+        return i
 
     def id(self, gcobj):
         return self.id_or_identityhash(gcobj, False)
 
     def identityhash(self, gcobj):
-        return mangle_hash(self.id_or_identityhash(gcobj, True))
+        return self.id_or_identityhash(gcobj, True)
 
 
     # ----------
diff --git a/pypy/rpython/memory/gctransform/framework.py b/pypy/rpython/memory/gctransform/framework.py
--- a/pypy/rpython/memory/gctransform/framework.py
+++ b/pypy/rpython/memory/gctransform/framework.py
@@ -932,10 +932,10 @@
     def gct_gc_identityhash(self, hop):
         livevars = self.push_roots(hop)
         [v_ptr] = hop.spaceop.args
-        v_adr = hop.genop("cast_ptr_to_adr", [v_ptr],
-                          resulttype=llmemory.Address)
+        v_ptr = hop.genop("cast_opaque_ptr", [v_ptr],
+                          resulttype=llmemory.GCREF)
         hop.genop("direct_call",
-                  [self.identityhash_ptr, self.c_const_gc, v_adr],
+                  [self.identityhash_ptr, self.c_const_gc, v_ptr],
                   resultvar=hop.spaceop.result)
         self.pop_roots(hop, livevars)
 


More information about the pypy-commit mailing list