[pypy-svn] r67157 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test

pedronis at codespeak.net pedronis at codespeak.net
Mon Aug 24 15:04:52 CEST 2009


Author: pedronis
Date: Mon Aug 24 15:04:52 2009
New Revision: 67157

Modified:
   pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py
Log:
(cfbolz, pedronis): Two tests about virtualizables and blackholes. One of them
s fixed, the other skipped.


Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py	Mon Aug 24 15:04:52 2009
@@ -1553,7 +1553,9 @@
                 # as it contains the old values (before the call)!
                 self.gen_store_back_in_virtualizable_no_perform()
                 return True    # must call after_generate_residual_call()
-        return False   # don't call after_generate_residual_call()
+        # xxx don't call after_generate_residual_call() or
+        # in the case of blackholing abuse it to resynchronize
+        return self.is_blackholing()
 
     def after_generate_residual_call(self):
         # Called after generating a residual call, and only if

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py	Mon Aug 24 15:04:52 2009
@@ -860,6 +860,86 @@
         assert res == 55
         self.check_loops(new_with_vtable=0)
 
+    def test_blackhole_should_not_pay_attention(self):
+        myjitdriver = JitDriver(greens = [], reds = ['frame'],
+                                virtualizables = ['frame'])
+
+        class Frame(object):
+            _virtualizable2_ = ['x', 'y']
+
+            def __init__(self, x, y):
+                self = hint(self, access_directly=True)
+                self.x = x
+                self.y = y
+
+        class SomewhereElse:
+            pass
+        somewhere_else = SomewhereElse()
+
+        def g(frame):
+            frame.y += 100
+
+        def f(n):
+            frame = Frame(n, 0)
+            somewhere_else.top_frame = frame        # escapes
+            frame = hint(frame, access_directly=True)
+            while frame.x > 0:
+                myjitdriver.can_enter_jit(frame=frame)
+                myjitdriver.jit_merge_point(frame=frame)
+                if frame.x == 2:
+                    g(frame)
+                frame.y += frame.x
+                frame.x -= 1
+            return somewhere_else.top_frame.y
+
+        res = self.meta_interp(f, [10])
+        assert res == 155
+        self.check_loops(getfield_gc=0, setfield_gc=0)
+
+    def test_blackhole_should_not_reenter(self):
+        py.test.skip("WIP")
+        myjitdriver = JitDriver(greens = [], reds = ['frame', 'fail'],
+                                virtualizables = ['frame'])
+
+        class Frame(object):
+            _virtualizable2_ = ['x', 'y']
+
+            def __init__(self, x, y):
+                self = hint(self, access_directly=True)
+                self.x = x
+                self.y = y
+
+        class SomewhereElse:
+            pass
+        somewhere_else = SomewhereElse()
+
+        def jump_back(frame, fail):
+            myjitdriver.can_enter_jit(frame=frame, fail=fail)            
+
+        def f(n, fail):
+            frame = Frame(n, 0)
+            somewhere_else.top_frame = frame        # escapes
+            frame = hint(frame, access_directly=True)
+            while frame.x > 0:
+                myjitdriver.jit_merge_point(frame=frame, fail=fail)
+                frame.x -= 1
+                if fail or frame.x > 2:
+                    frame.y += frame.x
+                jump_back(frame, fail)
+
+            return somewhere_else.top_frame.y
+
+        def main():
+            f(10, True)
+            f(10, True)
+            f(10, True)
+            f(10, True)
+            return f(10, False)
+
+        res = self.meta_interp(main, [])
+        assert res == 55
+        self.check_loops(getfield_gc=0, setfield_gc=0)
+
 class TestOOtype(#ExplicitVirtualizableTests,
                  ImplicitVirtualizableTests,
                  OOJitMixin):
@@ -870,6 +950,12 @@
     def test_virtual_child_frame_with_arrays(self):
         py.test.skip("oo virtualizable support incomplete")
 
+    def test_blackhole_should_not_pay_attention(self):
+        py.test.skip("oo virtualizable support incomplete")
+
+    def test_blackhole_should_not_reenter(self):
+        py.test.skip("oo virtualizable support incomplete")
+
 class TestLLtype(ExplicitVirtualizableTests,
                  ImplicitVirtualizableTests,
                  LLJitMixin):



More information about the Pypy-commit mailing list