[pypy-svn] r52816 - in pypy/branch/jit-hotpath/pypy/jit: rainbow rainbow/test timeshifter

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Mar 21 18:11:32 CET 2008


Author: cfbolz
Date: Fri Mar 21 18:11:31 2008
New Revision: 52816

Modified:
   pypy/branch/jit-hotpath/pypy/jit/rainbow/rhotpath.py
   pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_interpreter.py
   pypy/branch/jit-hotpath/pypy/jit/timeshifter/rtimeshift.py
Log:
fix red ovf ops in the hotpath stuff that get constant red boxes as args


Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/rhotpath.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/rhotpath.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/rhotpath.py	Fri Mar 21 18:11:31 2008
@@ -452,10 +452,13 @@
 
 
 def hp_after_raisingop(jitstate, hotrunnerdesc, ll_evalue):
-    gv_raised = jitstate.greens.pop() # XXX hackish interface,
-                                      # pushed here by ll_gen1 or ll_gen2
+    gv_raised = jitstate.get_gv_op_raised()
     # XXX slightly hackish as well, we actually need gv_raised to be
     # in local_boxes to be passed along to the new block
+    if gv_raised.is_const:
+        if gv_raised.revealconst(lltype.Bool):
+            jitstate.residual_ll_exception(ll_evalue)
+        return
     assert not gv_raised.is_const
     tok_bool = hotrunnerdesc.RGenOp.kindToken(lltype.Bool)
     raisedbox = rvalue.IntRedBox(tok_bool, gv_raised)

Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_interpreter.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hp_interpreter.py	Fri Mar 21 18:11:31 2008
@@ -1777,6 +1777,34 @@
         assert res == -40
         self.check_insns_in_loops(int_add_ovf=1)
 
+    def test_red_int_add_ovf_consts(self):
+        class MyJitDriver(JitDriver):
+            greens = []
+            reds = ['n', 'm', 'i', 'result']
+            def on_enter_jit(self):
+                self.n = hint(hint(self.n, promote=True), variable=True)
+                self.m = hint(hint(self.m, promote=True), variable=True)
+        def f(n, m):
+            i = 1024
+            result = 0
+            while i > 0:
+                i >>= 1
+                try:
+                    result += ovfcheck(n + m)
+                except OverflowError:
+                    result += -42 + m
+                MyJitDriver.jit_merge_point(n=n, m=m, i=i, result=result)
+                MyJitDriver.can_enter_jit(n=n, m=m, i=i, result=result)
+            return result
+
+        res = self.run(f, [100, 20], threshold=2)
+        assert res == 120 * 11
+        self.check_insns_in_loops(int_add_ovf=0)
+
+        res = self.run(f, [sys.maxint, 1], threshold=2)
+        assert res == -41 * 11
+        self.check_insns_in_loops(int_add_ovf=0)
+
     def test_green_int_add_ovf(self):
         py.test.skip("not working yet")
         def f(n, m):

Modified: pypy/branch/jit-hotpath/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/timeshifter/rtimeshift.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/timeshifter/rtimeshift.py	Fri Mar 21 18:11:31 2008
@@ -448,8 +448,7 @@
     return True
 
 def split_raisingop(jitstate, resumepoint, ll_evalue, *greens_gv):
-    exitgvar = jitstate.gv_op_raised   # pushed here by the raising op
-    jitstate.gv_op_raised = None
+    exitgvar = jitstate.get_gv_op_raised()
     if exitgvar.is_const:
         gotexc = exitgvar.revealconst(lltype.Bool)
     else:
@@ -1281,6 +1280,11 @@
             f.dispatchqueue.resuming = None
             f = f.backframe
 
+    def get_gv_op_raised(self):
+        result = self.gv_op_raised
+        self.gv_op_raised = None
+        return result
+
 
 def start_writing(jitstate=None, prevopen=None):
     if jitstate is not prevopen:
@@ -1365,6 +1369,7 @@
         myframe = jitstate.frame
         leave_frame(jitstate)
         jitstate.greens = []
+        assert len(myframe.local_boxes) == 1
         jitstate.returnbox = myframe.local_boxes[0]
         jitstate = jitstate.next
     return return_chain



More information about the Pypy-commit mailing list