[pypy-svn] r51920 - in pypy/branch/jit-refactoring/pypy/jit/rainbow: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Feb 28 17:34:09 CET 2008


Author: cfbolz
Date: Thu Feb 28 17:34:07 2008
New Revision: 51920

Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
Log:
support for oopspec calls that are residual and raise


Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	Thu Feb 28 17:34:07 2008
@@ -185,7 +185,7 @@
         bytecode._source = self.assembler
         bytecode._interpreter = self.interpreter
         bytecode._labelpos = labelpos
-        #bytecode.dump()
+        bytecode.dump()
         if is_portal:
             self.finish_all_graphs()
             self.interpreter.set_num_global_mergepoints(
@@ -740,11 +740,21 @@
         else:
             deepfrozen = False
 
-        self.emit("red_oopspec_call_%s" % (len(args), ))
+        hasresult = op.result.concretetype != lltype.Void
+        self.emit("red_oopspec_call%s_%s" % ("_noresult" * (not hasresult),
+                                             len(args)))
         self.emit(oopspecdescindex)
         self.emit(deepfrozen)
         self.emit(*args)
-        self.register_redvar(op.result)
+        if hasresult:
+            self.register_redvar(op.result)
+
+        if withexc:
+            self.emit("goto_if_oopcall_was_virtual", tlabel(("oop_call", op)))
+            self.emit("after_oop_residual_call")
+            self.emit(self.promotiondesc_position(lltype.Signed))
+
+            self.emit(label(("oop_call", op)))
 
     def handle_green_call(self, op, withexc):
         voidargs = [const.value for const in op.args[1:]

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py	Thu Feb 28 17:34:07 2008
@@ -227,6 +227,7 @@
             bytecode = self.load_2byte()
             assert bytecode >= 0
             result = self.opcode_implementations[bytecode](self)
+            #assert self.frame.local_boxes[-1] is not None
             if result is STOP:
                 return
             else:
@@ -378,6 +379,11 @@
         if valuebox.is_constant():
             self.frame.pc = target
 
+    @arguments("jumptarget")
+    def opimpl_goto_if_oopcall_was_virtual(self, target):
+        if not rtimeshift.oopspec_was_residual(self.jitstate):
+            self.frame.pc = target
+
     @arguments("red", returns="red")
     def opimpl_red_ptr_nonzero(self, ptrbox):
         return rtimeshift.genptrnonzero(self.jitstate, ptrbox, False)
@@ -536,6 +542,36 @@
     def opimpl_red_oopspec_call_3(self, oopspec, deepfrozen, arg1, arg2, arg3):
         return oopspec.ll_handler_3(self.jitstate, oopspec, deepfrozen, arg1, arg2, arg3)
 
+    @arguments("oopspec", "bool")
+    def opimpl_red_oopspec_call_noresult_0(self, oopspec, deepfrozen):
+        oopspec.ll_handler_0(self.jitstate, oopspec, deepfrozen)
+
+    @arguments("oopspec", "bool", "red")
+    def opimpl_red_oopspec_call_noresult_1(self, oopspec, deepfrozen, arg1):
+        oopspec.ll_handler_1(self.jitstate, oopspec, deepfrozen, arg1)
+
+    @arguments("oopspec", "bool", "red", "red")
+    def opimpl_red_oopspec_call_noresult_2(self, oopspec, deepfrozen, arg1, arg2):
+        oopspec.ll_handler_2(self.jitstate, oopspec, deepfrozen, arg1, arg2)
+
+    @arguments("oopspec", "bool", "red", "red", "red")
+    def opimpl_red_oopspec_call_noresult_3(self, oopspec, deepfrozen, arg1, arg2, arg3):
+        oopspec.ll_handler_3(self.jitstate, oopspec, deepfrozen, arg1, arg2, arg3)
+
+    @arguments("promotiondesc")
+    def opimpl_after_oop_residual_call(self, promotiondesc):
+        exceptiondesc = self.exceptiondesc
+        check_forced = False
+        flagbox = rtimeshift.after_residual_call(self.jitstate,
+                                                 exceptiondesc, check_forced)
+        done = rtimeshift.promote(self.jitstate, flagbox, promotiondesc)
+        if done:
+            return self.dispatch()
+        gv_flag = flagbox.getgenvar(self.jitstate)
+        assert gv_flag.is_const
+        rtimeshift.residual_fetch(self.jitstate, self.exceptiondesc,
+                                  check_forced, flagbox)
+
     @arguments("red", "calldesc", "bool", "red_varargs", "promotiondesc")
     def opimpl_red_residual_call(self, funcbox, calldesc, withexc,
                                         redargs, promotiondesc):

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	Thu Feb 28 17:34:07 2008
@@ -70,6 +70,7 @@
 class InterpretationTest(object):
 
     RGenOp = LLRGenOp
+    small = False
 
     def setup_class(cls):
         cls.on_llgraph = cls.RGenOp is LLRGenOp

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_portal.py	Thu Feb 28 17:34:07 2008
@@ -405,7 +405,6 @@
         self.check_insns(int_add=0)
 
     def test_residual_oop_raising(self):
-        py.test.skip("not working yet")
         def g(x):
             lst = []
             if x > 10:



More information about the Pypy-commit mailing list