[pypy-svn] r67253 - pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp

antocuni at codespeak.net antocuni at codespeak.net
Thu Aug 27 17:50:14 CEST 2009


Author: antocuni
Date: Thu Aug 27 17:50:11 2009
New Revision: 67253

Modified:
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/compile.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py
Log:
unify ExitFrameWithException{Obj,Ptr} into ExitFrameWithExceptionRef


Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/compile.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/compile.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/compile.py	Thu Aug 27 17:50:11 2009
@@ -181,7 +181,7 @@
         else:
             assert isinstance(valuebox, history.Const)
             value = valuebox.getref_base()
-        raise metainterp_sd.ExitFrameWithExceptionPtr(value)
+        raise metainterp_sd.ExitFrameWithExceptionRef(metainterp_sd.cpu, value)
 
 class ExitFrameWithExceptionDescrObj(AbstractDescr):
     def handle_fail_op(self, metainterp_sd, fail_op):
@@ -192,7 +192,7 @@
         else:
             assert isinstance(valuebox, history.Const)
             value = valuebox.getref_base()
-        raise metainterp_sd.ExitFrameWithExceptionObj(value)
+        raise metainterp_sd.ExitFrameWithExceptionRef(metainterp_sd.cpu, value)
 
 done_with_this_frame_descr_void = DoneWithThisFrameDescrVoid()
 done_with_this_frame_descr_int = DoneWithThisFrameDescrInt()

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py	Thu Aug 27 17:50:11 2009
@@ -1051,7 +1051,7 @@
     def _setup_class_sizes(self):
         class_sizes = {}
         for vtable, sizedescr in self._class_sizes:
-            vtable = self.cpu.ts.cast_ref_to_hashable(self.cpu, vtable)
+            vtable = self.cpu.ts.cast_baseclass_to_hashable(self.cpu, vtable)
             class_sizes[vtable] = sizedescr
         self.cpu.set_class_sizes(class_sizes)
 
@@ -1165,10 +1165,7 @@
             self.framestack.pop()
         if not self.is_blackholing():
             self.compile_exit_frame_with_exception(excvaluebox)
-        if self.cpu.is_oo:
-            raise self.staticdata.ExitFrameWithExceptionObj(excvaluebox.getref_base())
-        else:
-            raise self.staticdata.ExitFrameWithExceptionPtr(excvaluebox.getref_base())
+        raise self.staticdata.ExitFrameWithExceptionRef(self.cpu, excvaluebox.getref_base())
 
     def raise_overflow_error(self):
         etype, evalue = self.cpu.get_overflow_error()

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py	Thu Aug 27 17:50:11 2009
@@ -37,6 +37,7 @@
 
     name = 'lltype'
     functionptr = staticmethod(lltype.functionptr)
+    BASETYPE = llmemory.GCREF
     BoxRef = history.BoxPtr
     ConstRef = history.ConstPtr
 
@@ -74,6 +75,9 @@
         obj = evaluebox.getref(lltype.Ptr(rclass.OBJECT))
         return cast_base_ptr_to_instance(Exception, obj)
 
+    def cast_to_baseclass(self, value):
+        return lltype.cast_opaque_ptr(lltype.Ptr(rclass.OBJECT), value)
+
     def clean_box(self, box):
         if isinstance(box, history.BoxPtr):
             box.value = lltype.nullptr(llmemory.GCREF.TO)
@@ -95,15 +99,21 @@
         adr = llmemory.cast_ptr_to_adr(ptr)
         return cpu.cast_adr_to_int(adr)
 
+    def cast_baseclass_to_hashable(self, cpu, ptr):
+        adr = llmemory.cast_ptr_to_adr(ptr)
+        return cpu.cast_adr_to_int(adr)
+
+
 class OOTypeHelper(TypeSystemHelper):
 
     name = 'ootype'
     functionptr = staticmethod(ootype.static_meth)
+    BASETYPE = ootype.Object
     BoxRef = history.BoxObj
     ConstRef = history.ConstObj
 
     def get_typeptr(self, obj):
-        return obj.meta
+        return ootype.classof(obj)
 
     def get_FuncType(self, ARGS, RESULT):
         FUNCTYPE = ootype.StaticMethod(ARGS, RESULT)
@@ -133,6 +143,9 @@
         obj = evaluebox.getref(ootype.ROOT)
         return cast_base_ptr_to_instance(Exception, obj)
 
+    def cast_to_baseclass(self, value):
+        return ootype.cast_from_object(ootype.ROOT, value)
+
     def clean_box(self, box):
         if isinstance(box, history.BoxObj):
             box.value = ootype.NULL
@@ -153,6 +166,8 @@
     def cast_ref_to_hashable(self, cpu, obj):
         return ootype.cast_to_object(obj)
 
+    def cast_baseclass_to_hashable(self, cpu, obj):
+        return ootype.cast_to_object(obj)
 
 llhelper = LLTypeHelper()
 oohelper = OOTypeHelper()

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py	Thu Aug 27 17:50:11 2009
@@ -399,19 +399,12 @@
             def __str__(self):
                 return 'DoneWithThisFrameObj(%s)' % (self.result,)
 
-        class ExitFrameWithExceptionPtr(JitException):
-            def __init__(self, value):
-                assert lltype.typeOf(value) == llmemory.GCREF
+        class ExitFrameWithExceptionRef(JitException):
+            def __init__(self, cpu, value):
+                assert lltype.typeOf(value) == cpu.ts.BASETYPE
                 self.value = value
             def __str__(self):
-                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,)
+                return 'ExitFrameWithExceptionRef(%s)' % (self.value,)
 
         class ContinueRunningNormally(JitException):
             def __init__(self, argboxes):
@@ -430,20 +423,19 @@
         self.DoneWithThisFrameInt = DoneWithThisFrameInt
         self.DoneWithThisFramePtr = DoneWithThisFramePtr
         self.DoneWithThisFrameObj = DoneWithThisFrameObj
-        self.ExitFrameWithExceptionPtr = ExitFrameWithExceptionPtr
-        self.ExitFrameWithExceptionObj = ExitFrameWithExceptionObj
+        self.ExitFrameWithExceptionRef = ExitFrameWithExceptionRef
         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.ExitFrameWithExceptionPtr = ExitFrameWithExceptionPtr
-        self.metainterp_sd.ExitFrameWithExceptionObj = ExitFrameWithExceptionObj
+        self.metainterp_sd.ExitFrameWithExceptionRef = ExitFrameWithExceptionRef
         self.metainterp_sd.ContinueRunningNormally = ContinueRunningNormally
         rtyper = self.translator.rtyper
         RESULT = PORTALFUNC.RESULT
         result_kind = history.getkind(RESULT)
         is_oo = self.cpu.is_oo
+        ts = self.cpu.ts
 
         def ll_portal_runner(*args):
             while 1:
@@ -467,20 +459,10 @@
                 except DoneWithThisFrameObj, e:
                     assert result_kind == 'obj'
                     return ootype.cast_from_object(RESULT, e.result)
-                except ExitFrameWithExceptionPtr, e:
-                    assert not is_oo
-                    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)
+                except ExitFrameWithExceptionRef, e:
+                    value = ts.cast_to_baseclass(e.value)
                     if not we_are_translated():
-                        raise LLException(ootype.classof(value), value)
+                        raise LLException(ts.get_typeptr(value), value)
                     else:
                         value = cast_base_ptr_to_instance(Exception, value)
                         raise Exception, value



More information about the Pypy-commit mailing list