[pypy-commit] pypy stm-gc: Allow objectmodel.current_object_addr_as_int() to work without

arigo noreply at buildbot.pypy.org
Mon Feb 20 11:44:33 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52667:5c6be7732717
Date: 2012-02-20 11:38 +0100
http://bitbucket.org/pypy/pypy/changeset/5c6be7732717/

Log:	Allow objectmodel.current_object_addr_as_int() to work without
	forcing inevitable transactions.

diff --git a/pypy/rlib/objectmodel.py b/pypy/rlib/objectmodel.py
--- a/pypy/rlib/objectmodel.py
+++ b/pypy/rlib/objectmodel.py
@@ -452,7 +452,7 @@
         if hop.rtyper.type_system.name == 'lltypesystem':
             from pypy.rpython.lltypesystem import lltype
             if isinstance(vobj.concretetype, lltype.Ptr):
-                return hop.genop('cast_ptr_to_int', [vobj],
+                return hop.genop('cast_current_ptr_to_int', [vobj],
                                  resulttype = lltype.Signed)
         elif hop.rtyper.type_system.name == 'ootypesystem':
             from pypy.rpython.ootypesystem import ootype
diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -385,6 +385,7 @@
     'ptr_iszero':           LLOp(canfold=True),
     'cast_ptr_to_int':      LLOp(sideeffects=False),
     'cast_int_to_ptr':      LLOp(sideeffects=False),
+    'cast_current_ptr_to_int': LLOp(sideeffects=False),  # gcptr->int, approx.
     'direct_fieldptr':      LLOp(canfold=True),
     'direct_arrayitems':    LLOp(canfold=True),
     'direct_ptradd':        LLOp(canfold=True),
diff --git a/pypy/translator/c/src/int.h b/pypy/translator/c/src/int.h
--- a/pypy/translator/c/src/int.h
+++ b/pypy/translator/c/src/int.h
@@ -195,7 +195,8 @@
 #define OP_CAST_INT_TO_LONGLONG(x,r) r = (long long)(x)
 #define OP_CAST_CHAR_TO_INT(x,r)    r = (long)((unsigned char)(x))
 #define OP_CAST_INT_TO_CHAR(x,r)    r = (char)(x)
-#define OP_CAST_PTR_TO_INT(x,r)     r = (long)(x)    /* XXX */
+#define OP_CAST_PTR_TO_INT(x,r)     r = (long)(x)
+#define OP_CAST_CURRENT_PTR_TO_INT(x,r)  r = (long)(x)
 
 #define OP_TRUNCATE_LONGLONG_TO_INT(x,r) r = (long)(x)
 
diff --git a/pypy/translator/stm/transform.py b/pypy/translator/stm/transform.py
--- a/pypy/translator/stm/transform.py
+++ b/pypy/translator/stm/transform.py
@@ -11,6 +11,7 @@
     'direct_call', 'force_cast', 'keepalive', 'cast_ptr_to_adr',
     'debug_print', 'debug_assert', 'cast_opaque_ptr', 'hint',
     'indirect_call', 'stack_current', 'gc_stack_bottom',
+    'cast_current_ptr_to_int',   # this variant of 'cast_ptr_to_int' is ok
     ])
 ALWAYS_ALLOW_OPERATIONS |= set(lloperation.enum_tryfold_ops())
 


More information about the pypy-commit mailing list