[pypy-svn] r64742 - pypy/branch/pyjitpl5/pypy/jit/metainterp

arigo at codespeak.net arigo at codespeak.net
Mon Apr 27 18:57:33 CEST 2009


Author: arigo
Date: Mon Apr 27 18:57:33 2009
New Revision: 64742

Modified:
   pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/typesystem.py
Log:
- make this bit of code ootype-friendly.
- important (but obscure, still working on a test...): never catch
  a JitException here!  That's supposed to get through as an
  exception, not be turned into a box.


Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py	Mon Apr 27 18:57:33 2009
@@ -2,7 +2,6 @@
 from pypy.rpython.lltypesystem import lltype, llmemory, rclass
 from pypy.rpython.ootypesystem import ootype
 from pypy.rpython.llinterp import LLException
-from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
 from pypy.tool.sourcetools import func_with_new_name
 from pypy.rlib.objectmodel import we_are_translated, r_dict, instantiate
 from pypy.rlib.unroll import unrolling_iterable
@@ -931,11 +930,14 @@
                 assert False
 
     def finishframe_exception(self, exceptionbox, excvaluebox):
-        if we_are_translated():   # detect and propagate AssertionErrors early
-            value = excvaluebox.getptr(lltype.Ptr(rclass.OBJECT))
-            value = cast_base_ptr_to_instance(Exception, value)
-            if isinstance(value, AssertionError):
-                raise AssertionError, value
+        # detect and propagate some exceptions early:
+        #  - AssertionError
+        #  - all subclasses of JitException
+        if we_are_translated():
+            from pypy.jit.metainterp.warmspot import JitException
+            e = self.staticdata.ts.get_exception_obj(excvaluebox)
+            if isinstance(e, JitException) or isinstance(e, AssertionError):
+                raise Exception, e
         #
         while self.framestack:
             frame = self.framestack[-1]

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/typesystem.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/typesystem.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/typesystem.py	Mon Apr 27 18:57:33 2009
@@ -3,6 +3,7 @@
 #from pypy.rpython.annlowlevel import cast_instance_to_base_obj
 from pypy.rpython.lltypesystem import lltype, llmemory, rclass
 from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
 from pypy.jit.metainterp import history
 
 def deref(T):
@@ -72,6 +73,11 @@
     def get_exc_value_box(self, evalue):
         return history.BoxPtr(evalue)
 
+    def get_exception_obj(self, evaluebox):
+        # only works when translated
+        obj = evaluebox.getptr(lltype.Ptr(rclass.OBJECT))
+        return cast_base_ptr_to_instance(Exception, obj)
+
 
 class OOTypeHelper(TypeSystemHelper):
 
@@ -108,6 +114,11 @@
     def get_exc_value_box(self, evalue):
         return history.BoxObj(evalue)
 
+    def get_exception_obj(self, evaluebox):
+        # only works when translated
+        obj = evaluebox.getobj()
+        return cast_base_ptr_to_instance(Exception, obj)
+
 
 llhelper = LLTypeHelper()
 oohelper = OOTypeHelper()



More information about the Pypy-commit mailing list