[pypy-svn] r64726 - pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp

antocuni at codespeak.net antocuni at codespeak.net
Mon Apr 27 14:10:39 CEST 2009


Author: antocuni
Date: Mon Apr 27 14:10:38 2009
New Revision: 64726

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/compile.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py
Log:
split ExitFrameWithExceptionDescr into an lltype and an ootype version



Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/compile.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/compile.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/compile.py	Mon Apr 27 14:10:38 2009
@@ -161,7 +161,7 @@
             result = resultbox.getobj()
         raise metainterp_sd.DoneWithThisFrameObj(result)
 
-class ExitFrameWithExceptionDescr(AbstractDescr):
+class ExitFrameWithExceptionDescrPtr(AbstractDescr):
     def handle_fail_op(self, metainterp_sd, fail_op):
         assert len(fail_op.args) == 1
         valuebox = fail_op.args[0]
@@ -170,13 +170,25 @@
         else:
             assert isinstance(valuebox, history.Const)
             value = valuebox.getptr_base()
-        raise metainterp_sd.ExitFrameWithException(value)
+        raise metainterp_sd.ExitFrameWithExceptionPtr(value)
+
+class ExitFrameWithExceptionDescrObj(AbstractDescr):
+    def handle_fail_op(self, metainterp_sd, fail_op):
+        assert len(fail_op.args) == 1
+        valuebox = fail_op.args[0]
+        if isinstance(valuebox, BoxObj):
+            value = metainterp_sd.cpu.get_latest_value_obj(0)
+        else:
+            assert isinstance(valuebox, history.Const)
+            value = valuebox.getobj()
+        raise metainterp_sd.ExitFrameWithExceptionObj(value)
 
 done_with_this_frame_descr_void = DoneWithThisFrameDescrVoid()
 done_with_this_frame_descr_int = DoneWithThisFrameDescrInt()
 done_with_this_frame_descr_ptr = DoneWithThisFrameDescrPtr()
 done_with_this_frame_descr_obj = DoneWithThisFrameDescrObj()
-exit_frame_with_exception_descr = ExitFrameWithExceptionDescr()
+exit_frame_with_exception_descr_ptr = ExitFrameWithExceptionDescrPtr()
+exit_frame_with_exception_descr_obj = ExitFrameWithExceptionDescrObj()
 
 class TerminatingLoop(TreeLoop):
     pass
@@ -206,11 +218,17 @@
 _loop.finishdescr = done_with_this_frame_descr_void
 loops_done_with_this_frame_void = [_loop]
 
-_loop = TerminatingLoop('exit_frame_with_exception')
+_loop = TerminatingLoop('exit_frame_with_exception_ptr')
 _loop.specnodes = [NotSpecNode()]
 _loop.inputargs = [BoxPtr()]
-_loop.finishdescr = exit_frame_with_exception_descr
-loops_exit_frame_with_exception = [_loop]
+_loop.finishdescr = exit_frame_with_exception_descr_ptr
+loops_exit_frame_with_exception_ptr = [_loop]
+
+_loop = TerminatingLoop('exit_frame_with_exception_obj')
+_loop.specnodes = [NotSpecNode()]
+_loop.inputargs = [BoxObj()]
+_loop.finishdescr = exit_frame_with_exception_descr_obj
+loops_exit_frame_with_exception_obj = [_loop]
 del _loop
 
 

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	Mon Apr 27 14:10:38 2009
@@ -941,7 +941,10 @@
             self.framestack.pop()
         if not isinstance(self.history, history.BlackHole):
             self.compile_exit_frame_with_exception(excvaluebox)
-        raise self.staticdata.ExitFrameWithException(excvaluebox.getptr_base())
+        if self.cpu.is_oo:
+            raise self.staticdata.ExitFrameWithExceptionObj(excvaluebox.getobj())
+        else:
+            raise self.staticdata.ExitFrameWithExceptionPtr(excvaluebox.getptr_base())
 
     def create_empty_history(self):
         self.history = history.History(self.cpu)
@@ -1156,7 +1159,10 @@
     def compile_exit_frame_with_exception(self, valuebox):
         # temporarily put a JUMP to a pseudo-loop
         self.history.record(rop.JUMP, [valuebox], None)
-        loops = compile.loops_exit_frame_with_exception
+        if self.cpu.is_oo:
+            loops = compile.loops_exit_frame_with_exception_obj
+        else:
+            loops = compile.loops_exit_frame_with_exception_ptr
         target_loop = compile.compile_new_bridge(self, loops, self.resumekey)
         assert target_loop is loops[0]
 

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/typesystem.py	Mon Apr 27 14:10:38 2009
@@ -72,9 +72,6 @@
     def get_exc_value_box(self, evalue):
         return history.BoxPtr(evalue)
 
-    @staticmethod
-    def unwrap_exc_value_box(valuebox):
-        return valuebox.getptr(lltype.Ptr(rclass.OBJECT))
 
 class OOTypeHelper(TypeSystemHelper):
 
@@ -111,10 +108,6 @@
     def get_exc_value_box(self, evalue):
         return history.BoxObj(evalue)
 
-    @staticmethod
-    def unwrap_exc_value_box(valuebox):
-        return ootype.cast_from_object(ootype.ROOT, valuebox.getobj())
-
 
 llhelper = LLTypeHelper()
 oohelper = OOTypeHelper()

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py	Mon Apr 27 14:10:38 2009
@@ -316,12 +316,19 @@
             def __str__(self):
                 return 'DoneWithThisFrameObj(%s)' % (self.result,)
 
-        class ExitFrameWithException(JitException):
+        class ExitFrameWithExceptionPtr(JitException):
             def __init__(self, value):
                 assert lltype.typeOf(value) == llmemory.GCREF
                 self.value = value
             def __str__(self):
-                return 'ExitFrameWithException(%s)' % (self.value,)
+                return 'ExitFrameWithExceptionPtr(%s)' % (self.value,)
+
+        class ExitFrameWithExceptionObj(JitException):
+            def __init__(self, value):
+                assert lltype.typeOf(value) == ootype.Object
+                self.value = value
+            def __str__(self):
+                return 'ExitFrameWithExceptionObj(%s)' % (self.value,)
 
         class ContinueRunningNormally(JitException):
             def __init__(self, args):
@@ -335,20 +342,22 @@
         self.DoneWithThisFrameInt = DoneWithThisFrameInt
         self.DoneWithThisFramePtr = DoneWithThisFramePtr
         self.DoneWithThisFrameObj = DoneWithThisFrameObj
-        self.ExitFrameWithException = ExitFrameWithException
+        self.ExitFrameWithExceptionPtr = ExitFrameWithExceptionPtr
+        self.ExitFrameWithExceptionObj = ExitFrameWithExceptionObj
         self.ContinueRunningNormally = ContinueRunningNormally
         self.metainterp_sd.DoneWithThisFrameVoid = DoneWithThisFrameVoid
         self.metainterp_sd.DoneWithThisFrameInt = DoneWithThisFrameInt
         self.metainterp_sd.DoneWithThisFramePtr = DoneWithThisFramePtr
         self.metainterp_sd.DoneWithThisFrameObj = DoneWithThisFrameObj
-        self.metainterp_sd.ExitFrameWithException = ExitFrameWithException
+        self.metainterp_sd.ExitFrameWithExceptionPtr = ExitFrameWithExceptionPtr
+        self.metainterp_sd.ExitFrameWithExceptionObj = ExitFrameWithExceptionObj
         self.metainterp_sd.ContinueRunningNormally = ContinueRunningNormally
         rtyper = self.translator.rtyper
         portalfunc_ARGS = unrolling_iterable(list(enumerate(PORTALFUNC.ARGS)))
         RESULT = PORTALFUNC.RESULT
         result_kind = history.getkind(RESULT)
+        is_oo = self.cpu.is_oo
 
-        unwrap_exc_value_box = self.metainterp_sd.ts.unwrap_exc_value_box
         def ll_portal_runner(*args):
             while 1:
                 try:
@@ -371,13 +380,19 @@
                 except DoneWithThisFrameObj, e:
                     assert result_kind == 'obj'
                     return ootype.cast_from_object(RESULT, e.result)
-                except ExitFrameWithException, e:
-                    value = unwrap_exc_value_box(e.valuebox)
+                except ExitFrameWithExceptionPtr, e:
+                    value = lltype.cast_opaque_ptr(lltype.Ptr(rclass.OBJECT),
+                                                   e.value)
+                    if not we_are_translated():
+                        raise LLException(value.typeptr, value)
+                    else:
+                        value = cast_base_ptr_to_instance(Exception, value)
+                        raise Exception, value
+                except ExitFrameWithExceptionObj, e:
+                    assert is_oo
+                    value = ootype.cast_from_object(ootype.ROOT, e.value)
                     if not we_are_translated():
-                        if hasattr(value, 'typeptr'):
-                            raise LLException(value.typeptr, value)
-                        else:
-                            raise LLException(ootype.classof(value), value)
+                        raise LLException(ootype.classof(value), value)
                     else:
                         value = cast_base_ptr_to_instance(Exception, value)
                         raise Exception, value



More information about the Pypy-commit mailing list