Author: Remi Meier <remi.me...@gmail.com>
Branch: stmgc-c4
Changeset: r66220:e81dca223118
Date: 2013-08-19 17:37 +0200
http://bitbucket.org/pypy/pypy/changeset/e81dca223118/

Log:    remove gcref mess (test_stm_integration runs again)

diff --git a/rpython/jit/backend/llsupport/gc.py 
b/rpython/jit/backend/llsupport/gc.py
--- a/rpython/jit/backend/llsupport/gc.py
+++ b/rpython/jit/backend/llsupport/gc.py
@@ -102,11 +102,10 @@
         for i in range(op.numargs()):
             v = op.getarg(i)
             if isinstance(v, ConstPtr) and bool(v.value):
-                p = rgc.cast_instance_to_gcref(v.value)
-                v.imm_value = rgc._make_sure_does_not_move(p)
+                v.imm_value = rgc._make_sure_does_not_move(v.value)
                 # XXX: fix for stm, record imm_values and unregister
                 # them again (below too):
-                gcrefs_output_list.append(p)
+                gcrefs_output_list.append(v.value)
 
         if self.stm:
             return # for descr, we do it on the fly in assembler.py
diff --git a/rpython/jit/backend/x86/test/test_stm_integration.py 
b/rpython/jit/backend/x86/test/test_stm_integration.py
--- a/rpython/jit/backend/x86/test/test_stm_integration.py
+++ b/rpython/jit/backend/x86/test/test_stm_integration.py
@@ -27,7 +27,10 @@
 import ctypes
 
 def cast_to_int(obj):
-    return rgc.cast_gcref_to_int(rgc.cast_instance_to_gcref(obj))
+    if isinstance(obj, rgc._GcRef):
+        return rgc.cast_gcref_to_int(obj)
+    else:
+        return rffi.cast(lltype.Signed, obj)
 
 CPU = getcpuclass()
 
@@ -170,12 +173,8 @@
                                inevitable, [],
                                RESULT=lltype.Void)
         def ptr_eq(x, y):
-            print "=== ptr_eq", x, y
-            print "=== ptr_eq", hex(rffi.cast(lltype.Signed, x)), 
hex(rffi.cast(lltype.Signed, y))
-                        
-            import pdb;pdb.set_trace()
-            self.ptr_eq_called_on.append((rffi.cast(lltype.Signed, x),
-                                          rffi.cast(lltype.Signed, y)))
+            print "=== ptr_eq", hex(cast_to_int(x)), hex(cast_to_int(y))
+            self.ptr_eq_called_on.append((cast_to_int(x), cast_to_int(y)))
             return x == y
         self.generate_function('stm_ptr_eq', ptr_eq, [llmemory.GCREF] * 2,
                                RESULT=lltype.Bool)
@@ -546,15 +545,13 @@
                     guard_failed = frame_adr != id(finaldescr)
 
                     # CHECK:
-                    a, b = s1, s2
+                    a, b = cast_to_int(s1), cast_to_int(s2)
                     if isinstance(p1, Const):
-                        a = p1.value
+                        a = cast_to_int(p1.value)
                     if isinstance(p2, Const):
-                        b = p2.value
+                        b = cast_to_int(p2.value)
                         
-                    if a == b or \
-                      rffi.cast(lltype.Signed, a) == 0 or \
-                      rffi.cast(lltype.Signed, b) == 0:
+                    if a == b or a == 0 or b == 0:
                         assert (a, b) not in called_on
                     else:
                         assert [(a, b)] == called_on
diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -99,7 +99,11 @@
     on objects that are already a bit old, so have a chance to be
     already non-movable."""
     if not we_are_translated():
-        return cast_gcref_to_int(p)
+        if isinstance(p, _GcRef):
+            return cast_gcref_to_int(p)
+        else:
+            from rpython.rtyper.lltypesystem import rffi
+            return rffi.cast(lltype.Signed, p)
     
     if stm_is_enabled():
         from rpython.rtyper.lltypesystem.lloperation import llop
@@ -392,10 +396,6 @@
     if we_are_translated():
         return lltype.cast_ptr_to_int(gcref)
     else:
-        from rpython.rtyper.lltypesystem.ll2ctypes import _llgcopaque
-        if isinstance(gcref._obj, _llgcopaque):
-            from rpython.rtyper.lltypesystem import rffi
-            return rffi.cast(lltype.Signed, gcref)
         return id(gcref._x)
 
 def dump_rpy_heap(fd):
diff --git a/rpython/rlib/test/test_rgc.py b/rpython/rlib/test/test_rgc.py
--- a/rpython/rlib/test/test_rgc.py
+++ b/rpython/rlib/test/test_rgc.py
@@ -229,7 +229,4 @@
     n = rgc.get_rpy_memory_usage(rgc.cast_instance_to_gcref(x1))
     assert n >= 8 and n <= 64
 
-def test_cast_gcref_to_int():
-    from rpython.rtyper.lltypesystem import rffi
-    x = rffi.cast(llmemory.GCREF, 123456)
-    assert rgc.cast_gcref_to_int(x) == 123456
+
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to