[pypy-svn] r73970 - in pypy/branch/blackhole-improvement/pypy/jit/codewriter: . test

arigo at codespeak.net arigo at codespeak.net
Thu Apr 22 14:10:56 CEST 2010


Author: arigo
Date: Thu Apr 22 14:10:54 2010
New Revision: 73970

Modified:
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_jitter.py
Log:
Also encode the result type in the operation name.


Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py	Thu Apr 22 14:10:54 2010
@@ -46,9 +46,9 @@
         return op
 
 def rewrite_op_direct_call(op):
-    """Turn direct_call(fn, i1, i2, ref1, ref2)
-       into residual_call_ir(fn, [i1, i2], [ref1, ref2])
-       (or residual_call_r or residual_call_irf)."""
+    """Turn 'i0 = direct_call(fn, i1, i2, ref1, ref2)'
+       into e.g. 'i0 = residual_call_ir_i(fn, [i1, i2], [ref1, ref2])'.
+       The name is one of 'residual_call_{r,ir,irf}_{i,r,f,v}'."""
     args_i = []
     args_r = []
     args_f = []
@@ -61,7 +61,8 @@
     if 'i' in kinds: sublists.append(args_i)
     if 'r' in kinds: sublists.append(args_r)
     if 'f' in kinds: sublists.append(args_f)
-    return SpaceOperation('residual_call_' + kinds,
+    reskind = getkind(op.result.concretetype)[0]
+    return SpaceOperation('residual_call_%s_%s' % (kinds, reskind),
                           [op.args[0]] + sublists,
                           op.result)
 

Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_jitter.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_jitter.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_jitter.py	Thu Apr 22 14:10:54 2010
@@ -52,28 +52,32 @@
     assert not jitter.optimize_goto_if_not(block)
 
 def test_residual_call():
-    for with_i in [False, True]:
-        for with_r in [False, True]:
-            for with_f in [False, True]:
-                args = []
-                if with_i: args += [lltype.Signed, lltype.Char]
-                if with_r: args += [rclass.OBJECTPTR, lltype.Ptr(rstr.STR)]
-                if with_f: args += [lltype.Float, lltype.Float]
-                random.shuffle(args)
-                if with_f: expectedkind = 'irf'    # all kinds
-                elif with_i: expectedkind = 'ir'   # integers and references
-                else: expectedkind = 'r'           # only references
-                yield residual_call_test, args, expectedkind
+    for RESTYPE in [lltype.Signed, rclass.OBJECTPTR,
+                    lltype.Float, lltype.Void]:
+        for with_i in [False, True]:
+            for with_r in [False, True]:
+                for with_f in [False, True]:
+                    ARGS = []
+                    if with_i: ARGS += [lltype.Signed, lltype.Char]
+                    if with_r: ARGS += [rclass.OBJECTPTR, lltype.Ptr(rstr.STR)]
+                    if with_f: ARGS += [lltype.Float, lltype.Float]
+                    random.shuffle(ARGS)
+                    if with_f: expectedkind = 'irf'   # all kinds
+                    elif with_i: expectedkind = 'ir'  # integers and references
+                    else: expectedkind = 'r'          # only references
+                    yield residual_call_test, ARGS, RESTYPE, expectedkind
 
-def residual_call_test(argtypes, expectedkind):
-    FUNC = lltype.FuncType(argtypes, lltype.Signed)
+def residual_call_test(argtypes, restype, expectedkind):
+    FUNC = lltype.FuncType(argtypes, restype)
     fnptr = lltype.functionptr(FUNC, "g")    # no graph
     c_fnptr = Constant(fnptr, concretetype=lltype.typeOf(fnptr))
     vars = [varoftype(TYPE) for TYPE in argtypes]
-    op = SpaceOperation('direct_call', [c_fnptr] + vars,
-                        varoftype(lltype.Signed))
+    v_result = varoftype(restype)
+    op = SpaceOperation('direct_call', [c_fnptr] + vars, v_result)
     op1 = jitter.rewrite_operation(op)
-    assert op1.opname == 'residual_call_' + expectedkind
+    reskind = getkind(restype)[0]
+    assert op1.opname == 'residual_call_%s_%s' % (expectedkind, reskind)
+    assert op1.result == v_result
     assert op1.args[0] == c_fnptr
     assert len(op1.args) == 1 + len(expectedkind)
     for sublist, kind in zip(op1.args[1:], expectedkind):



More information about the Pypy-commit mailing list