[pypy-svn] r76972 - in pypy/branch/saner-guard-exc/pypy/jit: backend backend/llgraph backend/test metainterp metainterp/test

arigo at codespeak.net arigo at codespeak.net
Thu Sep 9 16:45:32 CEST 2010


Author: arigo
Date: Thu Sep  9 16:45:29 2010
New Revision: 76972

Modified:
   pypy/branch/saner-guard-exc/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/saner-guard-exc/pypy/jit/backend/llgraph/runner.py
   pypy/branch/saner-guard-exc/pypy/jit/backend/model.py
   pypy/branch/saner-guard-exc/pypy/jit/backend/test/runner_test.py
   pypy/branch/saner-guard-exc/pypy/jit/metainterp/executor.py
   pypy/branch/saner-guard-exc/pypy/jit/metainterp/test/test_basic.py
Log:
Mostly killing code around.


Modified: pypy/branch/saner-guard-exc/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/saner-guard-exc/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/saner-guard-exc/pypy/jit/backend/llgraph/llimpl.py	Thu Sep  9 16:45:29 2010
@@ -136,8 +136,6 @@
     'guard_false'     : (('bool',), None),
     'guard_value'     : (('int', 'int'), None),
     'guard_class'     : (('ref', 'ref'), None),
-    'guard_no_exception'   : ((), None),
-    'guard_exception'      : (('ref',), 'ref'),
     'guard_no_overflow'    : ((), None),
     'guard_overflow'       : ((), None),
     'guard_nonnull'        : (('ref',), None),
@@ -598,39 +596,12 @@
         if value != expected_value:
             raise GuardFailed
 
-    def op_guard_no_exception(self, _):
-        if _last_exception:
-            raise GuardFailed
-
-    def _check_exception(self, expected_exception):
-        global _last_exception
-        expected_exception = self._cast_exception(expected_exception)
-        assert expected_exception
-        exc = _last_exception
-        if exc:
-            got = exc.args[0]
-            # exact match!
-            if got != expected_exception:
-                return False
-            return True
-        else:
-            return False
-
-    def _cast_exception(self, exception):
-        return llmemory.cast_adr_to_ptr(
-            llmemory.cast_int_to_adr(exception),
-            rclass.CLASSTYPE)
-
-    def _issubclass(self, cls1, cls2):
-        return rclass.ll_issubclass(cls1, cls2)
+    def op_last_exc(self, _):
+        return grab_exc_value()
 
-    def op_guard_exception(self, _, expected_exception):
+    def op_clear_exc(self, _):
         global _last_exception
-        if not self._check_exception(expected_exception):
-            raise GuardFailed
-        res = _last_exception[1]
         _last_exception = None
-        return res
 
     def op_guard_no_overflow(self, _):
         flag = self.overflow_flag
@@ -978,12 +949,6 @@
         cls2 = ootype.cast_from_object(ootype.Class, obj2)
         return ootype.subclassof(cls1, cls2)
 
-    def _cast_exception(self, exception):
-        return ootype.cast_from_object(ootype.Class, exception)
-
-    def _issubclass(self, cls1, cls2):
-        return ootype.subclassof(cls1, cls2)
-
 # ____________________________________________________________
 
 def cast_to_int(x):
@@ -1558,7 +1523,6 @@
 setannotation(frame_get_value_count, annmodel.SomeInteger())
 setannotation(frame_clear_latest_values, annmodel.s_None)
 
-setannotation(grab_exc_value, annmodel.SomePtr(llmemory.GCREF))
 setannotation(force, annmodel.SomeInteger())
 setannotation(get_forced_token_frame, s_Frame)
 setannotation(get_frame_forced_token, annmodel.SomeAddress())

Modified: pypy/branch/saner-guard-exc/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/saner-guard-exc/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/saner-guard-exc/pypy/jit/backend/llgraph/runner.py	Thu Sep  9 16:45:29 2010
@@ -290,9 +290,6 @@
         return self.getdescr(0, token[0], extrainfo=extrainfo,
                              arg_types=''.join(arg_types))
 
-    def grab_exc_value(self):
-        return llimpl.grab_exc_value()
-
     def arraydescrof(self, A):
         assert A.OF != lltype.Void
         size = symbolic.get_size(A)

Modified: pypy/branch/saner-guard-exc/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/saner-guard-exc/pypy/jit/backend/model.py	(original)
+++ pypy/branch/saner-guard-exc/pypy/jit/backend/model.py	Thu Sep  9 16:45:29 2010
@@ -101,12 +101,6 @@
         values -- normally get_latest_value_count()."""
         raise NotImplementedError
 
-    def grab_exc_value(self):
-        """Return and clear the exception set by the latest execute_token(),
-        when it exits due to a failure of a GUARD_EXCEPTION or
-        GUARD_NO_EXCEPTION.  (Returns a GCREF)"""        # XXX remove me
-        raise NotImplementedError
-
     @staticmethod
     def sizeof(S):
         raise NotImplementedError

Modified: pypy/branch/saner-guard-exc/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/saner-guard-exc/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/branch/saner-guard-exc/pypy/jit/backend/test/runner_test.py	Thu Sep  9 16:45:29 2010
@@ -377,8 +377,6 @@
             looptoken = LoopToken()
             self.cpu.compile_loop([v1, v2], ops, looptoken)
             for x, y, z in testcases:
-                excvalue = self.cpu.grab_exc_value()
-                assert not excvalue
                 self.cpu.set_future_value_int(0, x)
                 self.cpu.set_future_value_int(1, y)
                 fail = self.cpu.execute_token(looptoken)
@@ -388,8 +386,6 @@
                     assert fail.identifier == 2
                 if z != boom:
                     assert self.cpu.get_latest_value_int(0) == z
-                excvalue = self.cpu.grab_exc_value()
-                assert not excvalue
 
     def test_ovf_operations_reversed(self):
         self.test_ovf_operations(reversed=True)
@@ -1330,8 +1326,9 @@
         [i0]
         i1 = same_as(1)
         call(ConstClass(fptr), i0, descr=calldescr)
-        p0 = guard_exception(ConstClass(xtp)) [i1]
-        finish(0, p0)
+        p0 = last_exc()
+        clear_exc()
+        finish(p0)
         '''
         FPTR = lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Void))
         fptr = llhelper(FPTR, func)
@@ -1344,64 +1341,19 @@
                             hints={'vtable':  xtp._obj})
         xptr = lltype.cast_opaque_ptr(llmemory.GCREF, lltype.malloc(X))
 
-
         exc_tp = xtp
         exc_ptr = xptr
         loop = parse(ops, self.cpu, namespace=locals())
         self.cpu.compile_loop(loop.inputargs, loop.operations, loop.token)
         self.cpu.set_future_value_int(0, 1)
         self.cpu.execute_token(loop.token)
-        assert self.cpu.get_latest_value_int(0) == 0
-        assert self.cpu.get_latest_value_ref(1) == xptr
-        excvalue = self.cpu.grab_exc_value()
-        assert not excvalue
+        assert self.cpu.get_latest_value_ref(0) == xptr
         self.cpu.set_future_value_int(0, 0)
         self.cpu.execute_token(loop.token)
-        assert self.cpu.get_latest_value_int(0) == 1
-        excvalue = self.cpu.grab_exc_value()
-        assert not excvalue
+        assert self.cpu.get_latest_value_ref(0) == lltype.nullptr(
+            llmemory.GCREF.TO)
 
-        ytp = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
-        ytp.subclassrange_min = 2
-        ytp.subclassrange_max = 2
-        assert rclass.ll_issubclass(ytp, xtp)
-        Y = lltype.GcStruct('Y', ('parent', rclass.OBJECT),
-                            hints={'vtable':  ytp._obj})
-        yptr = lltype.cast_opaque_ptr(llmemory.GCREF, lltype.malloc(Y))
-
-        # guard_exception uses an exact match
-        exc_tp = ytp
-        exc_ptr = yptr
-        loop = parse(ops, self.cpu, namespace=locals())
-        self.cpu.compile_loop(loop.inputargs, loop.operations, loop.token)
-        self.cpu.set_future_value_int(0, 1)
-        self.cpu.execute_token(loop.token)
-        assert self.cpu.get_latest_value_int(0) == 1
-        excvalue = self.cpu.grab_exc_value()
-        assert excvalue == yptr
-        assert not self.cpu.grab_exc_value()   # cleared
-
-        exc_tp = xtp
-        exc_ptr = xptr
-        ops = '''
-        [i0]
-        i1 = same_as(1)
-        call(ConstClass(fptr), i0, descr=calldescr)
-        guard_no_exception() [i1]
-        finish(0)
-        '''
-        loop = parse(ops, self.cpu, namespace=locals())
-        self.cpu.compile_loop(loop.inputargs, loop.operations, loop.token)
-        self.cpu.set_future_value_int(0, 1)
-        self.cpu.execute_token(loop.token)
-        assert self.cpu.get_latest_value_int(0) == 1
-        excvalue = self.cpu.grab_exc_value()
-        assert excvalue == xptr
-        self.cpu.set_future_value_int(0, 0)
-        self.cpu.execute_token(loop.token)
-        assert self.cpu.get_latest_value_int(0) == 0
-        excvalue = self.cpu.grab_exc_value()
-        assert not excvalue
+        assert not hasattr(self.cpu, 'grab_exc_value')   # old interface
 
     def test_cond_call_gc_wb(self):
         def func_void(a, b):

Modified: pypy/branch/saner-guard-exc/pypy/jit/metainterp/executor.py
==============================================================================
--- pypy/branch/saner-guard-exc/pypy/jit/metainterp/executor.py	(original)
+++ pypy/branch/saner-guard-exc/pypy/jit/metainterp/executor.py	Thu Sep  9 16:45:29 2010
@@ -293,6 +293,8 @@
                          rop.COND_CALL_GC_WB,
                          rop.DEBUG_MERGE_POINT,
                          rop.SETARRAYITEM_RAW,
+                         rop.LAST_EXC,
+                         rop.CLEAR_EXC,
                          ):      # list of opcodes never executed by pyjitpl
                 continue
             raise AssertionError("missing %r" % (key,))

Modified: pypy/branch/saner-guard-exc/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/saner-guard-exc/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/saner-guard-exc/pypy/jit/metainterp/test/test_basic.py	Thu Sep  9 16:45:29 2010
@@ -375,7 +375,8 @@
             return externfn(n, n+1)
         res = self.interp_operations(f, [6])
         assert res == 42
-        self.check_operations_history(int_add=1, int_mul=0, call=1, guard_no_exception=0)
+        self.check_operations_history(int_add=1, int_mul=0, call=1,
+                                      last_exc=0, clear_exc=0)
 
     def test_residual_call_pure(self):
         def externfn(x, y):



More information about the Pypy-commit mailing list