[pypy-svn] r67353 - in pypy/branch/pyjitpl5-llmodel/pypy/jit/backend: . llgraph test

arigo at codespeak.net arigo at codespeak.net
Mon Aug 31 14:06:04 CEST 2009


Author: arigo
Date: Mon Aug 31 14:06:02 2009
New Revision: 67353

Modified:
   pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/model.py
   pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/test/runner_test.py
Log:
Write test_cond_call_gc_wb and make it pass on the llgraph backend.


Modified: pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/llgraph/llimpl.py	Mon Aug 31 14:06:02 2009
@@ -104,6 +104,7 @@
     'arraylen_gc'     : (('ptr',), 'int'),
     'call'            : (('ptr', 'varargs'), 'intorptr'),
     'call_pure'       : (('ptr', 'varargs'), 'intorptr'),
+    'cond_call_gc_wb' : (('int', 'int', 'ptr', 'varargs'), None),
     'oosend'          : (('varargs',), 'intorptr'),
     'oosend_pure'     : (('varargs',), 'intorptr'),
     'guard_true'      : (('bool',), None),
@@ -690,6 +691,10 @@
 
     op_call_pure = op_call
 
+    def op_cond_call_gc_wb(self, calldescr, a, b, func, *args):
+        if a & b:
+            self.op_call(calldescr, func, *args)
+
     def op_oosend(self, descr, obj, *args):
         raise NotImplementedError("oosend for lltype backend??")
 

Modified: pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/model.py	(original)
+++ pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/model.py	Mon Aug 31 14:06:02 2009
@@ -139,6 +139,9 @@
     def do_setarrayitem_gc(self, args, arraydescr):
         raise NotImplementedError
 
+    def do_setarrayitem_raw(self, args, arraydescr):
+        raise NotImplementedError
+
     def do_setfield_gc(self, args, fielddescr):
         raise NotImplementedError
 
@@ -160,11 +163,12 @@
     def do_call(self, args, calldescr):
         raise NotImplementedError
 
-    def do_cond_call(self, args, calldescr):
-        if not args[0].getint():
-            return args[1]
-        else:
-            return self.do_call(args[2:], calldescr)
+    def do_cond_call_gc_wb(self, args, calldescr):
+        if args[0].getint() & args[1].getint():
+            self.do_call(args[2:], calldescr)
+
+    def do_cond_call_gc_malloc(self, args, calldescr):
+        xxx
 
     def do_cast_int_to_ptr(self, args, descr=None):
         raise NotImplementedError

Modified: pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/branch/pyjitpl5-llmodel/pypy/jit/backend/test/runner_test.py	Mon Aug 31 14:06:02 2009
@@ -115,23 +115,6 @@
                                          'int', descr=calldescr)
             assert res.value == 2 * num
 
-            # also test COND_CALL:
-            for cond in [False, True]:
-                value = random.randrange(-sys.maxint, sys.maxint)
-                if cond:
-                    value |= 4096
-                else:
-                    value &= ~4096
-                res = self.execute_operation(rop.COND_CALL,
-                                         [BoxInt(value), ConstInt(4096),
-                                          BoxInt(321123),
-                                          funcbox, BoxInt(num), BoxInt(num)],
-                                         'int', descr=calldescr)
-                if cond:
-                    assert res.value == 2 * num
-                else:
-                    assert res.value == 321123
-
     def test_executor(self):
         cpu = self.cpu
         x = execute(cpu, rop.INT_ADD, [BoxInt(100), ConstInt(42)])
@@ -960,6 +943,32 @@
         assert self.cpu.get_latest_value_int(0) == 0
         self.cpu.clear_exception()
 
+    def test_cond_call_gc_wb(self):
+        def func_void(a, b):
+            record.append((a, b))
+        record = []
+        #
+        FUNC = self.FuncType([lltype.Signed, lltype.Signed], lltype.Void)
+        func_ptr = llhelper(lltype.Ptr(FUNC), func_void)
+        funcbox = self.get_funcbox(self.cpu, func_ptr)
+        calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
+        for cond in [False, True]:
+            value = random.randrange(-sys.maxint, sys.maxint)
+            if cond:
+                value |= 4096
+            else:
+                value &= ~4096
+            del record[:]
+            self.execute_operation(rop.COND_CALL_GC_WB,
+                                   [BoxInt(value), ConstInt(4096),
+                                    funcbox, BoxInt(655360), BoxInt(-2121)],
+                                   'void', descr=calldescr)
+            if cond:
+                assert record == [(655360, -2121)]
+            else:
+                assert record == []
+
+
 class OOtypeBackendTest(BaseBackendTest):
 
     type_system = 'ootype'



More information about the Pypy-commit mailing list