[pypy-svn] r70777 - in pypy/branch/direct-assembler-call/pypy/jit/metainterp: . test

fijal at codespeak.net fijal at codespeak.net
Fri Jan 22 16:18:03 CET 2010


Author: fijal
Date: Fri Jan 22 16:18:03 2010
New Revision: 70777

Modified:
   pypy/branch/direct-assembler-call/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py
Log:
note down a test that I fail to write as a corner-case (it should not happen
in practice). Write a test and fix a real issue.


Modified: pypy/branch/direct-assembler-call/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/direct-assembler-call/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/direct-assembler-call/pypy/jit/metainterp/pyjitpl.py	Fri Jan 22 16:18:03 2010
@@ -664,7 +664,7 @@
     def opimpl_recursive_call(self, calldescr, varargs):
         warmrunnerstate = self.metainterp.staticdata.state
         token = None
-        if warmrunnerstate.inlining:
+        if not self.metainterp.is_blackholing() and warmrunnerstate.inlining:
             num_green_args = self.metainterp.staticdata.num_green_args
             portal_code = self.metainterp.staticdata.portal_code
             greenkey = varargs[1:num_green_args + 1]
@@ -675,7 +675,7 @@
         if token is not None:
             call_position = len(self.metainterp.history.operations)
         res = self.do_residual_call(varargs, descr=calldescr, exc=True)
-        if token is not None:
+        if not self.metainterp.is_blackholing() and token is not None:
             # XXX fix the call position, <UGLY!>
             found = False
             while True:

Modified: pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py
==============================================================================
--- pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py	(original)
+++ pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py	Fri Jan 22 16:18:03 2010
@@ -859,35 +859,62 @@
         res = self.meta_interp(main, [0, 10, 1], listops=True, inline=True)
         assert res == main(0, 10, 1)
 
-    # def test_recursive_call_while_blackholing(self):
-    #     driver = JitDriver(greens = ['codeno'], reds = ['i', 'k'],
-    #                        get_printable_location = lambda codeno : str(codeno),
-    #                        can_inline = lambda codeno : False)
-
-    #     def f(codeno, k):
-    #         i = 0
-    #         while i < 10:
-    #             driver.can_enter_jit(codeno=codeno, i=i, k=k)
-    #             driver.jit_merge_point(codeno=codeno, i=i, k=k)
-    #             if codeno == 0:
-    #                 k += indirection(1, k)
-    #             if codeno == 1 and k > 70 or codeno == 0:
-    #                 indirection(2, k)
-    #             i += 1
-    #             if codeno != 2:
-    #                 k += 1
-    #         return k
-
-    #     def indirection(a, b):
-    #         return f(a, b)
-
-    #     res = self.meta_interp(f, [0, 0], inline=True)
-    #     assert res == f(0, 0)
-
-    # There are two tests which I fail to write.
-    #   1. what happens if we call recursive_call while blackholing
-    #   2. what happens if in opimpl_recursive_call we switch to blackhole
-    #      while doing do_residual_call
+    def test_directly_call_assembler_virtualizable_force_blackhole(self):
+        class Thing(object):
+            def __init__(self, val):
+                self.val = val
+        
+        class Frame(object):
+            _virtualizable2_ = ['thing']
+        
+        driver = JitDriver(greens = ['codeno'], reds = ['frame', 'i'],
+                           virtualizables = ['frame'],
+                           get_printable_location = lambda codeno : str(codeno),
+                           can_inline = lambda codeno : False)
+        class SomewhereElse(object):
+            pass
+
+        somewhere_else = SomewhereElse()
+
+        def change(newthing, arg):
+            print arg
+            if arg > 30:
+                somewhere_else.frame.thing = newthing
+                arg = 13
+            return arg
+
+        def main(codeno):
+            frame = Frame()
+            somewhere_else.frame = frame
+            frame.thing = Thing(0)
+            portal(codeno, frame)
+            return frame.thing.val
+
+        def portal(codeno, frame):
+            i = 0
+            while i < 10:
+                driver.can_enter_jit(frame=frame, codeno=codeno, i=i)
+                driver.jit_merge_point(frame=frame, codeno=codeno, i=i)
+                nextval = frame.thing.val
+                if codeno == 0:
+                    subframe = Frame()
+                    subframe.thing = Thing(nextval)
+                    nextval = portal(1, subframe)
+                else:
+                    nextval = change(Thing(13), frame.thing.val)
+                frame.thing = Thing(nextval + 1)
+                i += 1
+            return frame.thing.val
+
+        res = self.meta_interp(main, [0], inline=True,
+                               policy=StopAtXPolicy(change))
+        assert res == main(0)
+
+
+    # There is a test which I fail to write.
+    #   * what happens if we call recursive_call while blackholing
+    #     this seems to be completely corner case and not really happening
+    #     in the wild
 
 class TestLLtype(RecursiveTests, LLJitMixin):
     pass



More information about the Pypy-commit mailing list