[pypy-svn] r79511 - in pypy/trunk/pypy: jit/codewriter jit/metainterp/test module/pypyjit

arigo at codespeak.net arigo at codespeak.net
Thu Nov 25 13:48:38 CET 2010


Author: arigo
Date: Thu Nov 25 13:48:36 2010
New Revision: 79511

Modified:
   pypy/trunk/pypy/jit/codewriter/jtransform.py
   pypy/trunk/pypy/jit/codewriter/support.py
   pypy/trunk/pypy/jit/metainterp/test/test_basic.py
   pypy/trunk/pypy/module/pypyjit/policy.py
Log:
"Support" for gc_id in the JIT.

Modified: pypy/trunk/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/trunk/pypy/jit/codewriter/jtransform.py	(original)
+++ pypy/trunk/pypy/jit/codewriter/jtransform.py	Thu Nov 25 13:48:36 2010
@@ -398,6 +398,7 @@
     rewrite_op_int_lshift_ovf  = _do_builtin_call
     rewrite_op_int_abs         = _do_builtin_call
     rewrite_op_gc_identityhash = _do_builtin_call
+    rewrite_op_gc_id           = _do_builtin_call
 
     # ----------
     # getfield/setfield/mallocs etc.

Modified: pypy/trunk/pypy/jit/codewriter/support.py
==============================================================================
--- pypy/trunk/pypy/jit/codewriter/support.py	(original)
+++ pypy/trunk/pypy/jit/codewriter/support.py	Thu Nov 25 13:48:36 2010
@@ -168,6 +168,9 @@
 def _ll_1_gc_identityhash(x):
     return lltype.identityhash(x)
 
+def _ll_1_gc_id(ptr):
+    return llop.gc_id(lltype.Signed, ptr)
+
 def _ll_1_jit_force_virtual(inst):
     return llop.jit_force_virtual(lltype.typeOf(inst), inst)
 
@@ -548,6 +551,9 @@
 def get_identityhash_oopspec(op):
     return 'gc_identityhash', op.args
 
+def get_gcid_oopspec(op):
+    return 'gc_id', op.args
+
 
 RENAMED_ADT_NAME = {
     'list': {
@@ -578,6 +584,8 @@
         return get_oostring_oopspec(op)
     elif op.opname == 'gc_identityhash':
         return get_identityhash_oopspec(op)
+    elif op.opname == 'gc_id':
+        return get_gcid_oopspec(op)
     else:
         raise ValueError(op.opname)
 

Modified: pypy/trunk/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_basic.py	Thu Nov 25 13:48:36 2010
@@ -1701,6 +1701,29 @@
         res = self.meta_interp(f, [5, 2])
         assert 4 < res < 14
 
+    def test_compute_identity_hash(self):
+        from pypy.rlib.objectmodel import compute_identity_hash
+        class A(object):
+            pass
+        def f():
+            a = A()
+            return compute_identity_hash(a) == compute_identity_hash(a)
+        res = self.interp_operations(f, [])
+        assert res
+        # a "did not crash" kind of test
+
+    def test_compute_unique_id(self):
+        from pypy.rlib.objectmodel import compute_unique_id
+        class A(object):
+            pass
+        def f():
+            a1 = A()
+            a2 = A()
+            return (compute_unique_id(a1) == compute_unique_id(a1) and
+                    compute_unique_id(a1) != compute_unique_id(a2))
+        res = self.interp_operations(f, [])
+        assert res
+
 
 class TestOOtype(BasicTests, OOJitMixin):
 

Modified: pypy/trunk/pypy/module/pypyjit/policy.py
==============================================================================
--- pypy/trunk/pypy/module/pypyjit/policy.py	(original)
+++ pypy/trunk/pypy/module/pypyjit/policy.py	Thu Nov 25 13:48:36 2010
@@ -19,10 +19,6 @@
     def look_inside_function(self, func):
         mod = func.__module__ or '?'
 
-        if mod.startswith('pypy.objspace.'):
-            # gc_id operation
-            if func.__name__ == 'id__ANY':
-                return False
         if mod == 'pypy.rlib.rbigint' or mod == 'pypy.rlib.rlocale':
             return False
         if '_geninterp_' in func.func_globals: # skip all geninterped stuff



More information about the Pypy-commit mailing list