[pypy-commit] pypy guard-compatible: support for promote_compatible in the codewriter

cfbolz pypy.commits at gmail.com
Sat Mar 12 17:25:22 EST 2016


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: guard-compatible
Changeset: r83001:889f0fd17c1a
Date: 2016-03-12 22:47 +0100
http://bitbucket.org/pypy/pypy/changeset/889f0fd17c1a/

Log:	support for promote_compatible in the codewriter

diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -591,6 +591,14 @@
         if hints.get('force_no_const'):   # for tests only
             assert getkind(op.args[0].concretetype) == 'int'
             return SpaceOperation('int_same_as', [op.args[0]], op.result)
+        if hints.get('promote_compatible') and op.args[0].concretetype is not lltype.Void:
+            kind = getkind(op.args[0].concretetype)
+            assert kind == "ref" # for now
+            op0 = SpaceOperation('-live-', [], None)
+            op1 = SpaceOperation('%s_guard_compatible' % kind, [op.args[0]], None)
+            # the special return value None forces op.result to be considered
+            # equal to op.args[0]
+            return [op0, op1, None]
         log.WARNING('ignoring hint %r at %r' % (hints, self.graph))
 
     def _rewrite_raw_malloc(self, op, name, args):
diff --git a/rpython/jit/codewriter/test/test_jtransform.py b/rpython/jit/codewriter/test/test_jtransform.py
--- a/rpython/jit/codewriter/test/test_jtransform.py
+++ b/rpython/jit/codewriter/test/test_jtransform.py
@@ -941,6 +941,23 @@
     assert block.operations[1].result is None
     assert block.exits[0].args == [v1]
 
+def test_guard_compatible():
+    S = lltype.GcStruct('S', ('x', lltype.Char)) # some ptr type
+    v1 = varoftype(lltype.Ptr(S))
+    v2 = varoftype(lltype.Ptr(S))
+    op = SpaceOperation('hint',
+                        [v1, Constant({'promote_compatible': True}, lltype.Void)],
+                        v2)
+    oplist = Transformer().rewrite_operation(op)
+    op0, op1, op2 = oplist
+    assert op0.opname == '-live-'
+    assert op0.args == []
+    assert op1.opname == 'ref_guard_compatible'
+    assert op1.args == [v1]
+    assert op1.result is None
+    assert op2 is None
+
+
 def test_jit_merge_point_1():
     class FakeJitDriverSD:
         index = 42


More information about the pypy-commit mailing list