[pypy-svn] r63783 - in pypy/branch/pyjitpl5-simplify/pypy/jit: backend/llgraph metainterp

arigo at codespeak.net arigo at codespeak.net
Tue Apr 7 12:15:54 CEST 2009


Author: arigo
Date: Tue Apr  7 12:15:51 2009
New Revision: 63783

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py
Log:
Split GUARD_EXCEPTION in two, the guard and a following GET_EXC_VALUE,
so that the guard itself no longer sometimes returns a result.
Fixes metainterp/test/test_exception.


Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py	Tue Apr  7 12:15:51 2009
@@ -118,6 +118,7 @@
     'strsetitem'      : (('ptr', 'int', 'int'), None),
     'cast_ptr_to_int' : (('ptr',), 'int'),
     'cast_int_to_ptr' : (('int',), 'ptr'),
+    'get_exc_value'   : ((), 'ptr'),
     #'getitem'         : (('void', 'ptr', 'int'), 'int'),
     #'setitem'         : (('void', 'ptr', 'int', 'int'), None),
     #'newlist'         : (('void', 'varargs'), 'ptr'),
@@ -541,7 +542,6 @@
             raise GuardFailed
 
     def _check_exception(self, expected_exception):
-        global _last_exception
         expected_exception = llmemory.cast_adr_to_ptr(
             cast_int_to_adr(self.memocast, expected_exception),
             rclass.CLASSTYPE)
@@ -550,20 +550,19 @@
         if exc:
             got = exc.args[0]
             if not rclass.ll_issubclass(got, expected_exception):
-                raise GuardFailed
-            _last_exception = None
-            return exc.args[1]
+                return False
+            return True
         else:
-            return None
+            return False
 
     def op_guard_exception(self, _, expected_exception):
-        if self._check_exception(expected_exception) is None:
+        if not self._check_exception(expected_exception):
             raise GuardFailed
 
     def op_guard_exception_inverse(self, _, expected_exception):
-        if self._check_exception(expected_exception) is not None:
+        if self._check_exception(expected_exception):
             raise GuardFailed
-    
+
     # ----------
     # delegating to the builtins do_xxx() (done automatically for simple cases)
 
@@ -643,6 +642,12 @@
     def op_uint_xor(self, descr, arg1, arg2):
         return arg1 ^ arg2
 
+    def op_get_exc_value(self, descr):
+        exc_value = get_exc_value()
+        assert exc_value    # should be guarded
+        clear_exception()
+        return exc_value
+
 # ____________________________________________________________
 
 def cast_to_int(x, memocast):

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	Tue Apr  7 12:15:51 2009
@@ -349,6 +349,12 @@
         return history.BoxInt(llimpl.cast_to_int(args[0].getptr_base(),
                                                         self.memo_cast))
 
+    def do_get_exc_value(self, args, descr=None):
+        exc_value = llimpl.get_exc_value()
+        assert exc_value    # should be guarded
+        llimpl.clear_exception()
+        return history.BoxPtr(exc_value)
+
 # ____________________________________________________________
 
 import pypy.jit.metainterp.executor

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py	Tue Apr  7 12:15:51 2009
@@ -1088,10 +1088,9 @@
         if etype:
             exception_box = ConstInt(etype)
             exc_value_box = BoxPtr(evalue)
-            op = frame.generate_guard(frame.pc, rop.GUARD_EXCEPTION,
-                                      None, [exception_box])
-            if op:
-                op.result = exc_value_box
+            frame.generate_guard(frame.pc, rop.GUARD_EXCEPTION,
+                                 None, [exception_box])
+            self.history.record(rop.GET_EXC_VALUE, [], exc_value_box)
             return self.finishframe_exception(exception_box, exc_value_box)
         else:
             frame.generate_guard(frame.pc, rop.GUARD_NO_EXCEPTION, None, [])

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py	Tue Apr  7 12:15:51 2009
@@ -165,6 +165,7 @@
     GETARRAYITEM_GC        = 83
     GETFIELD_GC            = 84
     GETFIELD_RAW           = 85
+    GET_EXC_VALUE          = 86
     _NOSIDEEFFECT_LAST = 89 # ----- end of no_side_effect operations -----
 
     NEW                    = 90



More information about the Pypy-commit mailing list