[pypy-svn] r77948 - in pypy/branch/jitffi/pypy/jit/metainterp: optimizeopt test

antocuni at codespeak.net antocuni at codespeak.net
Thu Oct 14 17:43:47 CEST 2010


Author: antocuni
Date: Thu Oct 14 17:43:46 2010
New Revision: 77948

Modified:
   pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
   pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizefficall.py
Log:
add one more case when to rollback


Modified: pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py	(original)
+++ pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py	Thu Oct 14 17:43:46 2010
@@ -100,7 +100,9 @@
     def _get_funcval(self, op):
         funcval = self.getvalue(op.getarg(1))
         if self.funcval:
-            assert self.funcval is funcval # XXX do something nice
+            if self.funcval is not funcval:
+                self.rollback()
+                return None
         if not funcval.is_constant():
             return None
         return funcval

Modified: pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizefficall.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizefficall.py	(original)
+++ pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizefficall.py	Thu Oct 14 17:43:46 2010
@@ -40,6 +40,9 @@
         func = FakeLLObject(_fake_class=Func,
                             argtypes=[types.sint, types.double],
                             restype=types.sint)
+        func2 = FakeLLObject(_fake_class=Func,
+                             argtypes=[types.sint, types.double],
+                             restype=types.sint)
         #
         def calldescr(cpu, FUNC, oopspecindex):
             einfo = EffectInfo([], [], [], oopspecindex=oopspecindex)
@@ -99,3 +102,21 @@
         """
         expected = ops
         loop = self.optimize_loop(ops, 'Not, Not', expected)
+
+    def test_rollback_multiple_calls(self):
+        ops = """
+        [i0, i2, f1]
+        call(0, ConstPtr(func),             descr=libffi_prepare)
+        call(0, ConstPtr(func), i0,         descr=libffi_push_arg)
+        call(0, ConstPtr(func2),             descr=libffi_prepare) # culprit!
+        call(0, ConstPtr(func), f1,         descr=libffi_push_arg)
+        i3 = call_may_force(0, ConstPtr(func), 12345, descr=libffi_call)
+        call(0, ConstPtr(func2), i0,         descr=libffi_push_arg)
+        call(0, ConstPtr(func2), f1,         descr=libffi_push_arg)
+        i4 = call_may_force(0, ConstPtr(func), 12345, descr=libffi_call)
+        guard_not_forced() []
+        guard_no_exception() []
+        jump(i3, i4, f1)
+        """
+        expected = ops
+        loop = self.optimize_loop(ops, 'Not, Not, Not', expected)



More information about the Pypy-commit mailing list