Author: Maciej Fijalkowski <[email protected]>
Branch: optresult
Changeset: r77772:979818fc7953
Date: 2015-06-02 16:32 +0200
http://bitbucket.org/pypy/pypy/changeset/979818fc7953/

Log:    finish fixing exceptions

diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -915,6 +915,7 @@
     def execute_guard_overflow(self, descr):
         if not self.overflow_flag:
             self.fail_guard(descr)
+        return lltype.nullptr(llmemory.GCREF.TO) # I think it's fine....
 
     def execute_jump(self, descr, *args):
         raise Jump(descr._llgraph_target, args)
diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -1301,7 +1301,7 @@
         exc_value = self.metainterp.last_exc_value
         assert exc_value
         assert self.metainterp.class_of_last_exc_is_const
-        return self.metainterp.cpu.ts.cls_of_box(ConstPtr(exc_value))
+        return 
self.metainterp.cpu.ts.cls_of_box(ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF,
 exc_value)))
 
     @arguments()
     def opimpl_last_exc_value(self):
@@ -2013,7 +2013,7 @@
             moreargs = [box] + extraargs
         else:
             moreargs = list(extraargs)
-        if opnum == rop.GUARD_EXCEPTION:
+        if opnum == rop.GUARD_EXCEPTION or opnum == rop.GUARD_OVERFLOW:
             guard_op = self.history.record(opnum, moreargs,
                                            lltype.nullptr(llmemory.GCREF.TO))
         else:
@@ -2749,9 +2749,12 @@
                 llmemory.cast_ptr_to_adr(self.last_exc_value.typeptr)))
             op = self.generate_guard(rop.GUARD_EXCEPTION,
                                      None, [exception_box])
-            self.last_exc_box = op
-            op.setref_base(lltype.cast_opaque_ptr(llmemory.GCREF,
-                                                  self.last_exc_value))
+            val = lltype.cast_opaque_ptr(llmemory.GCREF, self.last_exc_value)
+            if self.class_of_last_exc_is_const:
+                self.last_exc_box = ConstPtr(val)
+            else:
+                self.last_exc_box = op
+                op.setref_base(val)
             assert op is not None
             self.class_of_last_exc_is_const = True
             self.finishframe_exception()
@@ -2760,8 +2763,12 @@
 
     def handle_possible_overflow_error(self):
         if self.last_exc_value:
-            self.generate_guard(rop.GUARD_OVERFLOW, None)
+            op = self.generate_guard(rop.GUARD_OVERFLOW, None)
+            op.setref_base(lltype.cast_opaque_ptr(llmemory.GCREF,
+                                                  self.last_exc_value))
             assert self.class_of_last_exc_is_const
+            self.last_exc_box = ConstPtr(
+                lltype.cast_opaque_ptr(llmemory.GCREF, self.last_exc_value))
             self.finishframe_exception()
         else:
             self.generate_guard(rop.GUARD_NO_OVERFLOW, None)
diff --git a/rpython/jit/metainterp/resoperation.py 
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -653,7 +653,7 @@
     'GUARD_NO_EXCEPTION/0d/n',   # may be called with an exception currently 
set
     'GUARD_EXCEPTION/1d/r',     # may be called with an exception currently set
     'GUARD_NO_OVERFLOW/0d/n',
-    'GUARD_OVERFLOW/0d/n',
+    'GUARD_OVERFLOW/0d/r',
     'GUARD_NOT_FORCED/0d/n',      # may be called with an exception currently 
set
     'GUARD_NOT_FORCED_2/0d/n',    # same as GUARD_NOT_FORCED, but for finish()
     'GUARD_NOT_INVALIDATED/0d/n',
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to