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

arigo at codespeak.net arigo at codespeak.net
Fri May 28 12:38:42 CEST 2010


Author: arigo
Date: Fri May 28 12:38:41 2010
New Revision: 74840

Modified:
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/history.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_recursive.py
Log:
Fix CALL_ASSEMBLER generation.


Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/history.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/history.py	Fri May 28 12:38:41 2010
@@ -816,16 +816,6 @@
         op = ResOperation(opnum, argboxes, resbox, descr)
         self.operations[position] = op
 
-    def slice_history_at(self, position):
-        """ a strange function that does this:
-        history : operation_at_position : rest
-        it'll kill operation_at_position, store everything before that
-        in history.operations and return rest
-        """
-        rest = self.operations[position + 1:]
-        del self.operations[position:]
-        return rest
-
 # ____________________________________________________________
 
 

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	Fri May 28 12:38:41 2010
@@ -40,8 +40,6 @@
 
 class MIFrame(object):
 
-    env = property(lambda: xxx, lambda: xxx)     # temporary: no read/write!
-
     def __init__(self, metainterp):
         self.metainterp = metainterp
         self.registers_i = [None] * 256
@@ -659,36 +657,21 @@
         allboxes = greenboxes + redboxes
         metainterp_sd = self.metainterp.staticdata
         portal_code = metainterp_sd.portal_code
-##        warmrunnerstate = metainterp_sd.state
-##        token = None
-##        if not self.is_blackholing() and warmrunnerstate.inlining:
-##            if warmrunnerstate.can_inline_callable(greenboxes):
-##                return self.metainterp.perform_call(portal_code, allboxes,
-##                                                    greenkey=greenboxes)
-##            token = warmrunnerstate.get_assembler_token(greenboxes)
-##        call_position = 0
-##        if token is not None:
-##            call_position = len(self.history.operations)
-##            # verify that we have all green args, needed to make sure
-##            # that assembler that we call is still correct
-##            self.verify_green_args(greenboxes)
+        warmrunnerstate = metainterp_sd.state
+        token = None
+        if warmrunnerstate.inlining:
+            if warmrunnerstate.can_inline_callable(greenboxes):
+                return self.metainterp.perform_call(portal_code, allboxes,
+                                                    greenkey=greenboxes)
+            token = warmrunnerstate.get_assembler_token(greenboxes)
+            # verify that we have all green args, needed to make sure
+            # that assembler that we call is still correct
+            self.verify_green_args(greenboxes)
         #
         k = llmemory.cast_ptr_to_adr(metainterp_sd._portal_runner_ptr)
         funcbox = ConstInt(llmemory.cast_adr_to_int(k))
-        resbox = self.do_residual_call(funcbox, portal_code.calldescr,
-                                       allboxes)
-        #
-##        if token is not None:
-##            # XXX fix the call position, <UGLY!>
-##            while True:
-##                op = self.history.operations[call_position]
-##                if op.opnum == rop.CALL or op.opnum == rop.CALL_MAY_FORCE:
-##                    break
-##                call_position += 1
-##            # </UGLY!>
-##            # this will substitute the residual call with assembler call
-##            self.direct_assembler_call(boxes, token, call_position)
-        return resbox
+        return self.do_residual_call(funcbox, portal_code.calldescr,
+                                     allboxes, assembler_call_token=token)
 
     opimpl_recursive_call_i = _opimpl_recursive_call
     opimpl_recursive_call_r = _opimpl_recursive_call
@@ -1009,16 +992,20 @@
             self.metainterp.assert_no_exception()
         return resbox
 
-    def do_residual_call(self, funcbox, descr, argboxes):
+    def do_residual_call(self, funcbox, descr, argboxes,
+                         assembler_call_token=None):
         allboxes = [funcbox] + argboxes
         effectinfo = descr.get_extra_info()
-        if (effectinfo is None or effectinfo.extraeffect ==
-                                effectinfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE):
+        if (effectinfo is None or
+                effectinfo.extraeffect ==
+                             effectinfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE or
+                assembler_call_token is not None):
             # residual calls require attention to keep virtualizables in-sync
             self.metainterp.vable_and_vrefs_before_residual_call()
-            # xxx do something about code duplication
             resbox = self.metainterp.execute_and_record_varargs(
                 rop.CALL_MAY_FORCE, allboxes, descr=descr)
+            if assembler_call_token is not None:
+                self.metainterp.direct_assembler_call(assembler_call_token)
             if resbox is not None:
                 self.make_result_of_lastop(resbox)
             self.metainterp.vable_and_vrefs_after_residual_call()
@@ -2007,20 +1994,22 @@
                 max_key = key
         return max_key
 
-    def direct_assembler_call(self, boxes, token, call_position):
-        """ Generate a direct call to assembler for portal entry point.
+    def direct_assembler_call(self, token):
+        """ Generate a direct call to assembler for portal entry point,
+        patching the CALL_MAY_FORCE that occurred just now.
         """
-        assert not self.is_blackholing() # XXX
+        op = self.history.operations.pop()
+        assert op.opnum == rop.CALL_MAY_FORCE
         num_green_args = self.staticdata.num_green_args
-        args = boxes[num_green_args:]
-        resbox = self.history.operations[call_position].result
-        rest = self.history.slice_history_at(call_position)
+        args = op.args[num_green_args + 1:]
         if self.staticdata.virtualizable_info is not None:
             vindex = self.staticdata.virtualizable_info.index_of_virtualizable
-            vbox = boxes[vindex]
+            vbox = args[vindex - num_green_args]
             args += self.gen_load_from_other_virtualizable(vbox)
-        self.history.record(rop.CALL_ASSEMBLER, args[:], resbox, descr=token)
-        self.history.operations += rest
+        op.opnum = rop.CALL_ASSEMBLER
+        op.args = args
+        op.descr = token
+        self.history.operations.append(op)
 
 # ____________________________________________________________
 

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_recursive.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_recursive.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_recursive.py	Fri May 28 12:38:41 2010
@@ -137,7 +137,6 @@
 
         return interpret
 
-    @py.test.mark.xfail()
     def test_inline(self):
         code = "021"
         subcode = "00"
@@ -163,7 +162,6 @@
                                 inline=True) == 42
         self.check_loops(call_may_force = 1, call = 0)
 
-    @py.test.mark.xfail()
     def test_inline_faulty_can_inline(self):
         code = "021"
         subcode = "301"
@@ -471,7 +469,6 @@
         assert not res
         self.check_aborted_count(5)        
 
-    @py.test.mark.xfail()
     def test_set_param_inlining(self):
         myjitdriver = JitDriver(greens=[], reds=['n', 'recurse'])
         def loop(n, recurse=False):
@@ -538,7 +535,6 @@
         self.check_tree_loop_count(3)
         self.check_history(int_add=1)
 
-    @py.test.mark.xfail()
     def test_dont_inline_huge_stuff(self):
         def p(pc, code):
             code = hlstr(code)
@@ -583,7 +579,6 @@
         self.check_history(call_assembler=1, call=0)
         self.check_tree_loop_count(3)
 
-    @py.test.mark.xfail()
     def test_directly_call_assembler(self):
         driver = JitDriver(greens = ['codeno'], reds = ['i'],
                            get_printable_location = lambda codeno : str(codeno),
@@ -621,7 +616,6 @@
         self.check_history(call_assembler=0, call_may_force=1)
         self.check_enter_count_at_most(1)
 
-    @py.test.mark.xfail()
     def test_directly_call_assembler_return(self):
         driver = JitDriver(greens = ['codeno'], reds = ['i', 'k'],
                            get_printable_location = lambda codeno : str(codeno),
@@ -641,7 +635,6 @@
         self.meta_interp(portal, [2], inline=True)
         self.check_history(call_assembler=1)
 
-    @py.test.mark.xfail()
     def test_directly_call_assembler_raise(self):
 
         class MyException(Exception):
@@ -867,7 +860,6 @@
                                policy=StopAtXPolicy(change))
         assert res == main(0)
 
-    @py.test.mark.xfail()
     def test_assembler_call_red_args(self):
         driver = JitDriver(greens = ['codeno'], reds = ['i', 'k'],
                            get_printable_location = lambda codeno : str(codeno),



More information about the Pypy-commit mailing list