Author: Armin Rigo <[email protected]>
Branch: continulet-jit-3
Changeset: r58136:363e0ca83d9d
Date: 2012-10-15 17:08 +0200
http://bitbucket.org/pypy/pypy/changeset/363e0ca83d9d/

Log:    Fix tests

diff --git a/pypy/jit/backend/llgraph/llimpl.py 
b/pypy/jit/backend/llgraph/llimpl.py
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -479,6 +479,7 @@
 # ------------------------------
 
 class Frame(object):
+    _carry_around_for_tests = True
     OPHANDLERS = [None] * (rop._LAST+1)
 
     def __init__(self, cpu):
diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -820,14 +820,14 @@
 
 # ____________________________________________________________
 
-class PropagateExceptionDescr(AbstractFailDescr):
+class PropagateExceptionDescr(ResumeDescr):
     def handle_fail(self, metainterp_sd, jitdriver_sd, jitframe):
         cpu = metainterp_sd.cpu
         exception = cpu.get_finish_value_ref(jitframe)
         assert exception, "PropagateExceptionDescr: no exception??"
         raise metainterp_sd.ExitFrameWithExceptionRef(cpu, exception)
 
-def compile_tmp_callback(cpu, jitdriver_sd, greenboxes, redargtypes,
+def compile_tmp_callback(metainterp_sd, jitdriver_sd, greenboxes, redargtypes,
                          memory_manager=None):
     """Make a LoopToken that corresponds to assembler code that just
     calls back the interpreter.  Used temporarily: a fully compiled
@@ -850,12 +850,16 @@
     result_type = jitdriver_sd.result_type
     if result_type == history.INT:
         result = BoxInt()
+        DoneCls = DoneWithThisFrameDescrInt
     elif result_type == history.REF:
         result = BoxPtr()
+        DoneCls = DoneWithThisFrameDescrRef
     elif result_type == history.FLOAT:
         result = BoxFloat()
+        DoneCls = DoneWithThisFrameDescrFloat
     elif result_type == history.VOID:
         result = None
+        DoneCls = DoneWithThisFrameDescrVoid
     else:
         assert 0, "bad result_type"
     if result is not None:
@@ -865,14 +869,16 @@
     #
     jd = jitdriver_sd
     faildescr = PropagateExceptionDescr()
+    finishdescr = DoneCls(metainterp_sd, jitdriver_sd)
     operations = [
         ResOperation(rop.CALL, callargs, result, descr=jd.portal_calldescr),
         ResOperation(rop.GUARD_NO_EXCEPTION, [], None, descr=faildescr),
-        ResOperation(rop.FINISH, finishargs, None, descr=jd.portal_finishtoken)
+        ResOperation(rop.FINISH, finishargs, None, descr=finishdescr)
         ]
     operations[1].setfailargs([])
     operations[2].setfailargs([])
     operations = get_deep_immutable_oplist(operations)
+    cpu = metainterp_sd.cpu
     cpu.compile_loop(inputargs, operations, jitcell_token, log=False)
     if memory_manager is not None:    # for tests
         memory_manager.keep_loop_alive(jitcell_token)
diff --git a/pypy/jit/metainterp/test/test_compile.py 
b/pypy/jit/metainterp/test/test_compile.py
--- a/pypy/jit/metainterp/test/test_compile.py
+++ b/pypy/jit/metainterp/test/test_compile.py
@@ -165,18 +165,21 @@
         portal_runner_ptr = llhelper(lltype.Ptr(FUNC), ll_portal_runner)
         portal_runner_adr = llmemory.cast_ptr_to_adr(portal_runner_ptr)
         portal_calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT, None)
-        portal_finishtoken = compile.DoneWithThisFrameDescrInt(None, None)
         num_red_args = 2
         result_type = INT
     #
-    loop_token = compile_tmp_callback(cpu, FakeJitDriverSD(),
+    class FakeMetaInterpSD:
+        pass
+    FakeMetaInterpSD.cpu = cpu
+    #
+    loop_token = compile_tmp_callback(FakeMetaInterpSD, FakeJitDriverSD(),
                                       [ConstInt(12), ConstInt(34)], "ii")
     #
     raiseme = None
     # only two arguments must be passed in
     jit_frame = cpu.execute_token(loop_token, -156, -178)
     fail_descr = cpu.get_latest_descr(jit_frame)
-    assert fail_descr is FakeJitDriverSD().portal_finishtoken
+    assert isinstance(fail_descr, compile.DoneWithThisFrameDescrInt)
     #
     EXC = lltype.GcStruct('EXC')
     llexc = lltype.malloc(EXC)
diff --git a/pypy/jit/metainterp/test/test_recursive.py 
b/pypy/jit/metainterp/test/test_recursive.py
--- a/pypy/jit/metainterp/test/test_recursive.py
+++ b/pypy/jit/metainterp/test/test_recursive.py
@@ -797,59 +797,6 @@
         res = self.meta_interp(main, [0], inline=True)
         assert res == main(0)
 
-    def test_directly_call_assembler_virtualizable_reset_token(self):
-        from pypy.rpython.lltypesystem import lltype
-        from pypy.rlib.debug import llinterpcall
-
-        class Thing(object):
-            def __init__(self, val):
-                self.val = val
-        
-        class Frame(object):
-            _virtualizable2_ = ['thing']
-        
-        driver = JitDriver(greens = ['codeno'], reds = ['i', 'frame'],
-                           virtualizables = ['frame'],
-                           get_printable_location = lambda codeno : 
str(codeno))
-
-        @dont_look_inside
-        def check_frame(subframe):
-            if we_are_translated():
-                llinterpcall(lltype.Void, check_ll_frame, subframe)
-        def check_ll_frame(ll_subframe):
-            # This is called with the low-level Struct that is the frame.
-            # Check that the jit_frame was correctly reset to zero.
-            # Note that in order for that test to catch failures, it needs
-            # three levels of recursion: the jit_frame of the subframe
-            # at the level 2 is set to a non-zero value when doing the
-            # call to the level 3 only.  This used to fail when the test
-            # is run via pypy.jit.backend.x86.test.test_recursive.
-            assert ll_subframe.jit_frame == lltype.nullptr(llmemory.GCREF.TO)
-
-        def main(codeno):
-            frame = Frame()
-            frame.thing = Thing(0)
-            portal(codeno, frame)
-            return frame.thing.val
-
-        def portal(codeno, frame):
-            i = 0
-            while i < 5:
-                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 < 2:
-                    subframe = Frame()
-                    subframe.thing = Thing(nextval)
-                    nextval = portal(codeno + 1, subframe)
-                    check_frame(subframe)
-                frame.thing = Thing(nextval + 1)
-                i += 1
-            return frame.thing.val
-
-        res = self.meta_interp(main, [0], inline=True)
-        assert res == main(0)
-
     def test_directly_call_assembler_virtualizable_force1(self):
         class Thing(object):
             def __init__(self, val):
diff --git a/pypy/jit/metainterp/test/test_virtualref.py 
b/pypy/jit/metainterp/test/test_virtualref.py
--- a/pypy/jit/metainterp/test/test_virtualref.py
+++ b/pypy/jit/metainterp/test/test_virtualref.py
@@ -110,7 +110,9 @@
                   if str(box._getrepr_()).endswith('JitVirtualRef')]
         assert len(bxs2) == 1
         JIT_VIRTUAL_REF = self.vrefinfo.JIT_VIRTUAL_REF
-        someframe = lltype.malloc(jitframe.JITFRAMEPTR.TO, 5)
+        JITFRAME = lltype.GcStruct('SOME_JIT_FRAME')
+        someframe = lltype.malloc(JITFRAME)
+        someframe = lltype.cast_opaque_ptr(llmemory.GCREF, someframe)
         bxs2[0].getref(lltype.Ptr(JIT_VIRTUAL_REF)).jit_frame = someframe
         #
         # try reloading from blackhole.py's point of view
diff --git a/pypy/jit/metainterp/test/test_warmspot.py 
b/pypy/jit/metainterp/test/test_warmspot.py
--- a/pypy/jit/metainterp/test/test_warmspot.py
+++ b/pypy/jit/metainterp/test/test_warmspot.py
@@ -1,5 +1,5 @@
 import py
-from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.jit.metainterp.warmspot import get_stats
 from pypy.rlib.jit import JitDriver, set_param, unroll_safe
 from pypy.jit.backend.llgraph import runner
@@ -331,6 +331,8 @@
         exc_vtable = lltype.malloc(OBJECT_VTABLE, immortal=True)
         cls.exc_vtable = exc_vtable
 
+        cls.FAKEFRAME = lltype.GcStruct('FAKEFRAME')
+
         class FakeFailDescr(object):
             def __init__(self, no):
                 self.no = no
@@ -377,7 +379,7 @@
                 return "not callable"
 
             def get_latest_descr(self, frame):
-                assert lltype.typeOf(frame) == JITFRAMEPTR
+                assert frame._obj.container._TYPE == cls.FAKEFRAME
                 return FakeFailDescr(self._fail_index)
 
         driver = JitDriver(reds = ['red'], greens = ['green'])
@@ -401,14 +403,15 @@
 
         [jd] = self.desc.jitdrivers_sd
         cpu = self.desc.cpu
-        fakeframe = lltype.malloc(JITFRAMEPTR.TO, 5)
+        fakeframe = lltype.malloc(self.FAKEFRAME)
+        fakeframe = lltype.cast_opaque_ptr(llmemory.GCREF, fakeframe)
         cpu._fail_index = 0
-        assert jd._assembler_call_helper(fakeframe, 0) == 3
+        assert jd._assembler_call_helper(fakeframe) == 3
         cpu._fail_index = 1
-        assert jd._assembler_call_helper(fakeframe, 0) == 10
+        assert jd._assembler_call_helper(fakeframe) == 10
         try:
             cpu._fail_index = 3
-            jd._assembler_call_helper(fakeframe, 0)
+            jd._assembler_call_helper(fakeframe)
         except LLException, lle:
             assert lle[0] == self.exc_vtable
         else:
diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -574,7 +574,6 @@
         unwrap_greenkey = self.make_unwrap_greenkey()
         jit_getter = self.make_jitcell_getter()
         jd = self.jitdriver_sd
-        cpu = self.cpu
 
         def can_inline_greenargs(*greenargs):
             if can_never_inline(*greenargs):
@@ -611,8 +610,9 @@
                 if cell.counter == -1:    # used to be a valid entry bridge,
                     cell.counter = 0      # but was freed in the meantime.
                 memmgr = warmrunnerdesc.memory_manager
-                procedure_token = compile_tmp_callback(cpu, jd, greenkey,
-                                                       redargtypes, memmgr)
+                procedure_token = compile_tmp_callback(
+                    warmrunnerdesc.metainterp_sd, jd,
+                    greenkey, redargtypes, memmgr)
                 cell.set_procedure_token(procedure_token)
             return procedure_token
         self.get_assembler_token = get_assembler_token
diff --git a/pypy/rpython/lltypesystem/lltype.py 
b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -1049,6 +1049,8 @@
         # this must be an opaque ptr originating from an integer
         assert isinstance(obj, _opaque)
         return cast_int_to_ptr(obj.ORIGTYPE, container)
+    if getattr(container, '_carry_around_for_tests', False):
+        return p
     if container is not obj:
         p = _ptr(Ptr(typeOf(container)), container, p._solid)
     return p
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to