[pypy-svn] r74748 - in pypy/branch/blackhole-improvement/pypy/jit/metainterp: . test

arigo at codespeak.net arigo at codespeak.net
Tue May 25 20:59:37 CEST 2010


Author: arigo
Date: Tue May 25 20:59:35 2010
New Revision: 74748

Modified:
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/compile.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_blackhole.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/warmstate.py
Log:
In-progress.  Link the blackhole interp to pyjitpl directly,
called when the new exception SwitchToBlackhole is raised.


Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py	Tue May 25 20:59:35 2010
@@ -789,8 +789,16 @@
 
     @arguments("self", "I", "R", "F", "I", "R", "F")
     def bhimpl_jit_merge_point(self, *results):
-        CRN = self.builder.metainterp_sd.ContinueRunningNormally
-        raise CRN(*results)
+        if self.nextblackholeinterp is None:    # we are the last level
+            CRN = self.builder.metainterp_sd.ContinueRunningNormally
+            raise CRN(*results)
+        else:
+            # This occurs when we reach 'jit_merge_point' in the portal
+            # function called by recursion.  In this case, we can directly
+            # call the interpreter main loop from here, and just return its
+            # result.
+            XXX
+            raise LeaveFrame
 
     # ----------
     # list operations
@@ -1160,8 +1168,29 @@
         e = lltype.cast_opaque_ptr(llmemory.GCREF, e)
         raise sd.ExitFrameWithExceptionRef(self.cpu, e)
 
+    def _copy_data_from_miframe(self, miframe):
+        self.setposition(miframe.jitcode, miframe.pc)
+        for i in range(self.jitcode.num_regs_i()):
+            box = miframe.registers_i[i]
+            if box is not None:
+                self.setarg_i(i, box.getint())
+        for i in range(self.jitcode.num_regs_r()):
+            box = miframe.registers_r[i]
+            if box is not None:
+                self.setarg_r(i, box.getref_base())
+        for i in range(self.jitcode.num_regs_f()):
+            box = miframe.registers_f[i]
+            if box is not None:
+                self.setarg_f(i, box.getfloat())
+
 # ____________________________________________________________
 
+def _run_forever(blackholeinterp, current_exc):
+    current_exc = lltype.cast_opaque_ptr(rclass.OBJECTPTR, current_exc)
+    while True:
+        current_exc = blackholeinterp._resume_mainloop(current_exc)
+        blackholeinterp = blackholeinterp.nextblackholeinterp
+
 def resume_in_blackhole(metainterp_sd, resumedescr):
     from pypy.jit.metainterp.resume import blackhole_from_resumedata
     debug_start('jit-blackhole')
@@ -1175,10 +1204,29 @@
     current_exc = blackholeinterp._prepare_resume_from_failure(
         resumedescr.guard_opnum)
     try:
-        current_exc = lltype.cast_opaque_ptr(rclass.OBJECTPTR, current_exc)
-        while True:
-            current_exc = blackholeinterp._resume_mainloop(current_exc)
-            blackholeinterp = blackholeinterp.nextblackholeinterp
+        _run_forever(blackholeinterp, current_exc)
+    finally:
+        metainterp_sd.profiler.end_blackhole()
+        debug_stop('jit-blackhole')
+
+def convert_and_run_from_pyjitpl(metainterp, current_exc=NULL):
+    # Get a chain of blackhole interpreters and fill them by copying
+    # 'metainterp.framestack'.  Note that the order is important: the
+    # first one we get must be the bottom one, in order to make
+    # the comment in BlackholeInterpreter.setposition() valid.
+    debug_start('jit-blackhole')
+    metainterp_sd = metainterp.staticdata
+    metainterp_sd.profiler.start_blackhole()
+    nextbh = None
+    for frame in metainterp.framestack:
+        curbh = metainterp_sd.blackholeinterpbuilder.acquire_interp()
+        curbh._copy_data_from_miframe(frame)
+        curbh.nextblackholeinterp = nextbh
+        nextbh = curbh
+    firstbh = nextbh
+    #
+    try:
+        _run_forever(firstbh, current_exc)
     finally:
         metainterp_sd.profiler.end_blackhole()
         debug_stop('jit-blackhole')

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/compile.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/compile.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/compile.py	Tue May 25 20:59:35 2010
@@ -294,12 +294,10 @@
                 assert 0, typetag
             return counter >= trace_eagerness
 
-    def reset_counter_from_failure(self, metainterp):
+    def reset_counter_from_failure(self):
         if self._counter >= 0:
             self._counter = 0
         self._counters = None
-        warmrunnerstate = metainterp.staticdata.state
-        warmrunnerstate.disable_noninlinable_function(metainterp)
 
     def compile_and_attach(self, metainterp, new_loop):
         # We managed to create a bridge.  Attach the new operations
@@ -476,6 +474,9 @@
         # general loop token
         old_loop_tokens.append(new_loop_token)
 
+    def reset_counter_from_failure(self):
+        pass
+
 
 def compile_new_bridge(metainterp, old_loop_tokens, resumekey):
     """Try to compile a new bridge leading from the beginning of the history

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py	Tue May 25 20:59:35 2010
@@ -1,6 +1,5 @@
 import py, os
-from pypy.rpython.lltypesystem import llmemory
-from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.llinterp import LLException
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.unroll import unrolling_iterable
@@ -319,47 +318,13 @@
         if value:
             self.pc = target
 
-##    def follow_jump(self):
-##        _op_goto_if_not = self.metainterp.staticdata._op_goto_if_not
-##        assert ord(self.bytecode[self.pc]) == _op_goto_if_not
-##        self.pc += 1          # past the bytecode for 'goto_if_not'
-##        target = self.load_3byte()  # load the 'target' argument
-##        self.pc = target      # jump
-
-##    def ignore_next_guard_nullness(self, opnum):
-##        _op_ooisnull = self.metainterp.staticdata._op_ooisnull
-##        _op_oononnull = self.metainterp.staticdata._op_oononnull
-##        bc = ord(self.bytecode[self.pc])
-##        if bc == _op_ooisnull:
-##            if opnum == rop.GUARD_ISNULL:
-##                res = ConstInt(0)
-##            else:
-##                res = ConstInt(1)
-##        else:
-##            assert bc == _op_oononnull
-##            if opnum == rop.GUARD_ISNULL:
-##                res = ConstInt(1)
-##            else:
-##                res = ConstInt(0)
-##        self.pc += 1    # past the bytecode for ptr_iszero/ptr_nonzero
-##        self.load_int() # past the 'box' argument
-##        self.make_result_box(res)
-
-##    def dont_follow_jump(self):
-##        _op_goto_if_not = self.metainterp.staticdata._op_goto_if_not
-##        assert ord(self.bytecode[self.pc]) == _op_goto_if_not
-##        self.pc += 1          # past the bytecode for 'goto_if_not'
-##        self.load_3byte()     # past the 'target' argument
-##        self.load_int()       # past the 'box' argument
-##        self.ignore_varargs() # past the 'livelist' argument
-
     @arguments("box", "descr", "orgpc")
     def opimpl_switch(self, valuebox, switchdict, orgpc):
         box = self.implement_guard_value(orgpc, valuebox)
-        switchvalue = box.getint()
+        search_value = box.getint()
         assert isinstance(switchdict, SwitchDictDescr)
         try:
-            self.pc = switchdict.dict[switchvalue]
+            self.pc = switchdict.dict[search_value]
         except KeyError:
             pass
 
@@ -800,26 +765,26 @@
         for i in range(num_green_args):
             assert isinstance(varargs[i], Const)
 
-    def blackhole_reached_merge_point(self, varargs):
-        if self.metainterp.in_recursion:
-            portal_code = self.metainterp.staticdata.portal_code
-            # small hack: fish for the result box
-            lenenv = len(self.env)
-            raised = self.perform_call(portal_code, varargs)
-            # in general this cannot be assumed, but when blackholing,
-            # perform_call returns True only if an exception is called. In
-            # this case perform_call has called finishframe_exception
-            # already, so we need to return.
-            if raised:
-                return
-            if lenenv == len(self.env):
-                res = None
-            else:
-                assert lenenv == len(self.env) - 1
-                res = self.env.pop()
-            self.metainterp.finishframe(res)
-        else:
-            raise self.metainterp.staticdata.ContinueRunningNormally(varargs)
+##    def blackhole_reached_merge_point(self, varargs):
+##        if self.metainterp.in_recursion:
+##            portal_code = self.metainterp.staticdata.portal_code
+##            # small hack: fish for the result box
+##            lenenv = len(self.env)
+##            raised = self.perform_call(portal_code, varargs)
+##            # in general this cannot be assumed, but when blackholing,
+##            # perform_call returns True only if an exception is called. In
+##            # this case perform_call has called finishframe_exception
+##            # already, so we need to return.
+##            if raised:
+##                return
+##            if lenenv == len(self.env):
+##                res = None
+##            else:
+##                assert lenenv == len(self.env) - 1
+##                res = self.env.pop()
+##            self.metainterp.finishframe(res)
+##        else:
+##            raise self.metainterp.staticdata.ContinueRunningNormally(varargs)
 
     @arguments()
     def opimpl_can_enter_jit(self):
@@ -828,18 +793,21 @@
             raise CannotInlineCanEnterJit()
         self.metainterp.seen_can_enter_jit = True
 
-    @arguments("boxes3", "boxes3")
-    def opimpl_jit_merge_point(self, greenboxes, redboxes):
+    @arguments("orgpc", "boxes3", "boxes3")
+    def opimpl_jit_merge_point(self, orgpc, greenboxes, redboxes):
         self.verify_green_args(greenboxes)
         # xxx we may disable the following line in some context later
         self.debug_merge_point(greenboxes)
         if self.metainterp.seen_can_enter_jit:
             self.metainterp.seen_can_enter_jit = False
-            try:
-                self.metainterp.reached_can_enter_jit(greenboxes, redboxes)
-            except GiveUp:
-                XXX
-                self.metainterp.switch_to_blackhole(ABORT_BRIDGE)
+            # Set self.pc to point to jit_merge_point instead of just after:
+            # if reached_can_enter_jit() raises SwitchToBlackhole, then the
+            # pc is still at the jit_merge_point, which is a point that is
+            # much less expensive to blackhole out of.
+            saved_pc = self.pc
+            self.pc = orgpc
+            self.metainterp.reached_can_enter_jit(greenboxes, redboxes)
+            self.pc = saved_pc
 
     def debug_merge_point(self, greenkey):
         # debugging: produce a DEBUG_MERGE_POINT operation
@@ -1054,6 +1022,7 @@
         effectinfo = descr.get_extra_info()
         if (effectinfo is None or effectinfo.extraeffect ==
                                 effectinfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE):
+            XXX
             # residual calls require attention to keep virtualizables in-sync
             self.metainterp.vable_and_vrefs_before_residual_call()
             # xxx do something about code duplication
@@ -1273,7 +1242,6 @@
         self.staticdata = staticdata
         self.cpu = staticdata.cpu
         self.portal_trace_positions = []
-        self.greenkey_of_huge_function = None
         self.free_frames_list = []
         self.last_exc_value_box = None
 
@@ -1319,11 +1287,10 @@
             self.framestack[-1].make_result_of_lastop(resultbox)
             raise ChangeFrame
         else:
-            if not self.is_blackholing():
-                try:
-                    self.compile_done_with_this_frame(resultbox)
-                except GiveUp:
-                    self.switch_to_blackhole(ABORT_BRIDGE)
+            try:
+                self.compile_done_with_this_frame(resultbox)
+            except GiveUp:
+                self.aborted_tracing(ABORT_BRIDGE)
             sd = self.staticdata
             if sd.result_type == 'void':
                 assert resultbox is None
@@ -1361,11 +1328,10 @@
                     frame.pc = target
                     raise ChangeFrame
             self.popframe()
-        if not self.is_blackholing():
-            try:
-                self.compile_exit_frame_with_exception(excvaluebox)
-            except GiveUp:
-                self.switch_to_blackhole(ABORT_BRIDGE)
+        try:
+            self.compile_exit_frame_with_exception(excvaluebox)
+        except GiveUp:
+            self.aborted_tracing(ABORT_BRIDGE)
         raise self.staticdata.ExitFrameWithExceptionRef(self.cpu, excvaluebox.getref_base())
 
     def check_recursion_invariant(self):
@@ -1488,41 +1454,32 @@
     def execute_did_not_raise(self):
         self.last_exc_value_box = None
 
-    def switch_to_blackhole(self, reason):
-        XXX
+    def aborted_tracing(self, reason):
         self.staticdata.profiler.count(reason)
         debug_print('~~~ ABORTING TRACING')
-        debug_stop('jit-tracing')
-        debug_start('jit-blackhole')
-        self.history = None   # start blackholing
         self.staticdata.stats.aborted()
-        self.staticdata.profiler.end_tracing()
-        self.staticdata.profiler.start_blackhole()
-    switch_to_blackhole._dont_inline_ = True
-
-    def switch_to_blackhole_if_trace_too_long(self):
-        if not self.is_blackholing():
-            warmrunnerstate = self.staticdata.state
-            if len(self.history.operations) > warmrunnerstate.trace_limit:
-                self.greenkey_of_huge_function = self.find_biggest_function()
-                self.portal_trace_positions = None
-                self.switch_to_blackhole(ABORT_TOO_LONG)
+        self.resumekey.reset_counter_from_failure()
+
+    def blackhole_if_trace_too_long(self):
+        warmrunnerstate = self.staticdata.state
+        if len(self.history.operations) > warmrunnerstate.trace_limit:
+            greenkey_of_huge_function = self.find_biggest_function()
+            self.portal_trace_positions = None
+            if greenkey_of_huge_function is not None:
+                warmrunnerstate = self.staticdata.state
+                warmrunnerstate.disable_noninlinable_function(
+                    greenkey_of_huge_function)
+            raise SwitchToBlackhole(ABORT_TOO_LONG)
 
     def _interpret(self):
         # Execute the frames forward until we raise a DoneWithThisFrame,
-        # a ContinueRunningNormally, or a GenerateMergePoint exception.
+        # a ExitFrameWithException, or a GenerateMergePoint exception.
         self.staticdata.stats.entered()
-        try:
-            while True:
-                self.framestack[-1].run_one_step()
-                self.switch_to_blackhole_if_trace_too_long()
-                if not we_are_translated():
-                    self.check_recursion_invariant()
-        finally:
-            if self.is_blackholing():
-                self.staticdata.profiler.end_blackhole()
-            else:
-                self.staticdata.profiler.end_tracing()
+        while True:
+            self.framestack[-1].run_one_step()
+            self.blackhole_if_trace_too_long()
+            if not we_are_translated():
+                self.check_recursion_invariant()
 
     def interpret(self):
         if we_are_translated():
@@ -1538,11 +1495,13 @@
 
     def compile_and_run_once(self, *args):
         debug_start('jit-tracing')
+        self.staticdata.profiler.start_tracing()
         self.staticdata._setup_once()
         self.create_empty_history()
         try:
             return self._compile_and_run_once(*args)
         finally:
+            self.staticdata.profiler.end_tracing()
             debug_stop('jit-tracing')
 
     def _compile_and_run_once(self, *args):
@@ -1559,17 +1518,21 @@
             assert False, "should always raise"
         except GenerateMergePoint, gmp:
             return self.designate_target_loop(gmp)
+        except SwitchToBlackhole, stb:
+            self.run_blackhole_interp_to_cancel_tracing(stb)
 
     def handle_guard_failure(self, key):
+        debug_start('jit-tracing')
+        self.staticdata.profiler.start_tracing()
         assert isinstance(key, compile.ResumeGuardDescr)
         self.initialize_state_from_guard_failure(key)
         try:
             return self._handle_guard_failure(key)
         finally:
+            self.staticdata.profiler.end_tracing()
             debug_stop('jit-tracing')
 
     def _handle_guard_failure(self, key):
-        from pypy.jit.metainterp.warmspot import ContinueRunningNormallyBase
         original_greenkey = key.original_greenkey
         # notice that here we just put the greenkey
         # use -1 to mark that we will have to give up
@@ -1583,9 +1546,17 @@
             assert False, "should always raise"
         except GenerateMergePoint, gmp:
             return self.designate_target_loop(gmp)
-        except ContinueRunningNormallyBase:
-            key.reset_counter_from_failure(self)
-            raise
+        except SwitchToBlackhole, stb:
+            self.run_blackhole_interp_to_cancel_tracing(stb)
+
+    def run_blackhole_interp_to_cancel_tracing(self, stb):
+        # We got a SwitchToBlackhole exception.  Convert the framestack into
+        # a stack of blackhole interpreters filled with the same values, and
+        # run it.
+        from pypy.jit.metainterp.blackhole import convert_and_run_from_pyjitpl
+        self.aborted_tracing(stb.reason)
+        convert_and_run_from_pyjitpl(self, stb.current_exc)
+        assert False    # ^^^ must raise
 
     def remove_consts_and_duplicates(self, boxes, endindex, duplicates):
         for i in range(endindex):
@@ -1639,7 +1610,7 @@
                 # Found!  Compile it as a loop.
                 if start < 0:
                     # we cannot reconstruct the beginning of the proper loop
-                    raise GiveUp
+                    raise SwitchToBlackhole(ABORT_BRIDGE)
 
                 # raises in case it works -- which is the common case
                 self.compile(original_boxes, live_arg_boxes, start)
@@ -1777,7 +1748,6 @@
 
     def initialize_state_from_start(self, *args):
         self.in_recursion = -1 # always one portal around
-        self.staticdata.profiler.start_tracing()
         num_green_args = self.staticdata.num_green_args
         original_boxes = []
         self._initialize_from_start(original_boxes, num_green_args, *args)
@@ -1791,8 +1761,6 @@
 
     def initialize_state_from_guard_failure(self, resumedescr):
         # guard failure: rebuild a complete MIFrame stack
-        debug_start('jit-tracing')
-        self.staticdata.profiler.start_tracing()
         self.in_recursion = -1 # always one portal around
         self.history = history.History()
         inputargs_and_holes = self.rebuild_state_after_failure(resumedescr)
@@ -1842,36 +1810,25 @@
                                 None, descr=vinfo.vable_token_descr)
 
     def vable_and_vrefs_after_residual_call(self):
-        if self.is_blackholing():
-            escapes = True
-        else:
-            escapes = False
-            #
-            vrefinfo = self.staticdata.virtualref_info
-            for i in range(0, len(self.virtualref_boxes), 2):
-                virtualbox = self.virtualref_boxes[i]
-                vrefbox = self.virtualref_boxes[i+1]
-                vref = vrefbox.getref_base()
-                if vrefinfo.tracing_after_residual_call(vref):
-                    # this vref was really a virtual_ref, but it escaped
-                    # during this CALL_MAY_FORCE.  Mark this fact by
-                    # generating a VIRTUAL_REF_FINISH on it and replacing
-                    # it by ConstPtr(NULL).
-                    self.stop_tracking_virtualref(i)
-            #
-            vinfo = self.staticdata.virtualizable_info
-            if vinfo is not None:
-                virtualizable_box = self.virtualizable_boxes[-1]
-                virtualizable = vinfo.unwrap_virtualizable_box(virtualizable_box)
-                if vinfo.tracing_after_residual_call(virtualizable):
-                    # the virtualizable escaped during CALL_MAY_FORCE.
-                    escapes = True
-            #
-            if escapes:
-                self.switch_to_blackhole(ABORT_ESCAPE)
+        vrefinfo = self.staticdata.virtualref_info
+        for i in range(0, len(self.virtualref_boxes), 2):
+            virtualbox = self.virtualref_boxes[i]
+            vrefbox = self.virtualref_boxes[i+1]
+            vref = vrefbox.getref_base()
+            if vrefinfo.tracing_after_residual_call(vref):
+                # this vref was really a virtual_ref, but it escaped
+                # during this CALL_MAY_FORCE.  Mark this fact by
+                # generating a VIRTUAL_REF_FINISH on it and replacing
+                # it by ConstPtr(NULL).
+                self.stop_tracking_virtualref(i)
         #
-        if escapes:
-            self.load_fields_from_virtualizable()
+        vinfo = self.staticdata.virtualizable_info
+        if vinfo is not None:
+            virtualizable_box = self.virtualizable_boxes[-1]
+            virtualizable = vinfo.unwrap_virtualizable_box(virtualizable_box)
+            if vinfo.tracing_after_residual_call(virtualizable):
+                # the virtualizable escaped during CALL_MAY_FORCE.
+                raise XXX-SwitchToBlackhole(ABORT_ESCAPE, yyy)
 
     def stop_tracking_virtualref(self, i):
         virtualbox = self.virtualref_boxes[i]
@@ -2072,18 +2029,25 @@
         self.history.record(rop.CALL_ASSEMBLER, args[:], resbox, descr=token)
         self.history.operations += rest
 
+# ____________________________________________________________
+
 class GenerateMergePoint(Exception):
     def __init__(self, args, target_loop_token):
         assert target_loop_token is not None
         self.argboxes = args
         self.target_loop_token = target_loop_token
 
-# ____________________________________________________________
-
 class ChangeFrame(Exception):
     """Raised after we mutated metainterp.framestack, in order to force
     it to reload the current top-of-stack frame that gets interpreted."""
 
+class SwitchToBlackhole(Exception):
+    def __init__(self, reason, current_exc=lltype.nullptr(llmemory.GCREF.TO)):
+        self.reason = reason
+        self.current_exc = current_exc
+
+# ____________________________________________________________
+
 def _get_opimpl_method(name, argcodes):
     from pypy.jit.metainterp.blackhole import signedord
     #

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_blackhole.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_blackhole.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_blackhole.py	Tue May 25 20:59:35 2010
@@ -1,6 +1,9 @@
+import py
 from pypy.rlib.jit import JitDriver
 from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.blackhole import BlackholeInterpBuilder
+from pypy.jit.metainterp.blackhole import convert_and_run_from_pyjitpl
+from pypy.jit.metainterp import history
 from pypy.jit.codewriter.assembler import JitCode
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.llinterp import LLException
@@ -106,3 +109,33 @@
     blackholeinterp.setarg_i(0x9, -100)
     blackholeinterp.run()
     assert blackholeinterp.final_result_i() == 42
+
+def test_convert_and_run_from_pyjitpl():
+    class MyMIFrame:
+        jitcode = JitCode("test")
+        jitcode.setup("\xFF"               # illegal instruction
+                      "\x00\x00\x01\x02"   # int_add/ii>i
+                      "\x01\x02",          # int_return/i
+                      [],
+                      num_regs_i=3, num_regs_r=0, num_regs_f=0)
+        pc = 1
+        registers_i = [history.BoxInt(40), history.ConstInt(2), None]
+    class MyMetaInterp:
+        class staticdata:
+            result_type = 'int'
+            class profiler:
+                @staticmethod
+                def start_blackhole(): pass
+                @staticmethod
+                def end_blackhole(): pass
+            class DoneWithThisFrameInt(Exception):
+                pass
+        framestack = [MyMIFrame()]
+    MyMetaInterp.staticdata.blackholeinterpbuilder = getblackholeinterp(
+        {'int_add/ii>i': 0, 'int_return/i': 1}).builder
+    MyMetaInterp.staticdata.blackholeinterpbuilder.metainterp_sd = \
+        MyMetaInterp.staticdata
+    #
+    d = py.test.raises(MyMetaInterp.staticdata.DoneWithThisFrameInt,
+                       convert_and_run_from_pyjitpl, MyMetaInterp())
+    assert d.value.args == (42,)

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/warmstate.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/warmstate.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/warmstate.py	Tue May 25 20:59:35 2010
@@ -172,16 +172,14 @@
         if self.profiler is not None:
             self.profiler.set_printing(value >= DEBUG_PROFILE)
 
-    def disable_noninlinable_function(self, metainterp):
-        greenkey = metainterp.greenkey_of_huge_function
-        if greenkey is not None:
-            cell = self.jit_cell_at_key(greenkey)
-            cell.dont_trace_here = True
-            debug_start("jit-disableinlining")
-            sd = self.warmrunnerdesc.metainterp_sd
-            loc = sd.state.get_location_str(greenkey)
-            debug_print("disabled inlining", loc)
-            debug_stop("jit-disableinlining")
+    def disable_noninlinable_function(self, greenkey):
+        cell = self.jit_cell_at_key(greenkey)
+        cell.dont_trace_here = True
+        debug_start("jit-disableinlining")
+        sd = self.warmrunnerdesc.metainterp_sd
+        loc = sd.state.get_location_str(greenkey)
+        debug_print("disabled inlining", loc)
+        debug_stop("jit-disableinlining")
 
     def attach_unoptimized_bridge_from_interp(self, greenkey,
                                               entry_loop_token):
@@ -198,7 +196,6 @@
 
         metainterp_sd = self.warmrunnerdesc.metainterp_sd
         vinfo = metainterp_sd.virtualizable_info
-        ContinueRunningNormally = self.warmrunnerdesc.ContinueRunningNormally
         num_green_args = self.warmrunnerdesc.num_green_args
         get_jitcell = self.make_jitcell_getter()
         set_future_values = self.make_set_future_values()
@@ -242,11 +239,6 @@
                 cell.counter = -2
                 try:
                     loop_token = metainterp.compile_and_run_once(*args)
-                except ContinueRunningNormally:
-                    # the trace got too long, reset the counter
-                    cell.counter = 0
-                    self.disable_noninlinable_function(metainterp)
-                    raise
                 finally:
                     if cell.counter == -2:
                         cell.counter = 0



More information about the Pypy-commit mailing list