[pypy-svn] r52015 - in pypy/branch/jit-refactoring/pypy/jit: rainbow timeshifter

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Mar 1 20:26:10 CET 2008


Author: cfbolz
Date: Sat Mar  1 20:26:08 2008
New Revision: 52015

Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
   pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py
   pypy/branch/jit-refactoring/pypy/jit/timeshifter/rtimeshift.py
Log:
try to support virtual oop operations that raise


Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	Sat Mar  1 20:26:08 2008
@@ -14,6 +14,15 @@
 from pypy.translator.backendopt.ssa import SSA_to_SSI
 from pypy.translator.unsimplify import varoftype
 
+def residual_exception_nontranslated(jitstate, e, rtyper):
+    # since we have a normal exception instance here
+    # we need to turn it into a low level one
+    assert not we_are_translated()
+    bk = rtyper.annotator.bookkeeper
+    exc_classdef = bk.getuniqueclassdef(type(e))
+    ll_exc = rtyper.exceptiondata.get_standard_ll_exc_instance(
+        rtyper, exc_classdef)
+    jitstate.residual_ll_exception(ll_exc)
 
 class CallDesc:
     __metaclass__ = cachedtype
@@ -50,15 +59,9 @@
                 result = rgenop.genconst(fnptr(*args))
             except Exception, e:
                 if not we_are_translated():
-                    # since we have a normal exception instance here
-                    # we need to turn it into a low level one
-                    bk = rtyper.annotator.bookkeeper
-                    exc_classdef = bk.getuniqueclassdef(type(e))
-                    ll_exc = rtyper.exceptiondata.get_standard_ll_exc_instance(
-                        rtyper, exc_classdef)
-                    interpreter.jitstate.residual_ll_exception(ll_exc)
+                    residual_exception_nontranslated(interpreter.jitstate, e, rtyper)
                 else:
-                    interpreter.jitstate.residual_exception(ll_exc)
+                    interpreter.jitstate.residual_exception(e)
                 result = rgenop.genconst(whatever_return_value)
             interpreter.green_result(result)
         self.green_call = green_call

Modified: pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py	Sat Mar  1 20:26:08 2008
@@ -1,10 +1,11 @@
-from pypy.rpython.lltypesystem import lltype
-from pypy.rpython.extregistry import ExtRegistryEntry
-from pypy.jit.timeshifter.rcontainer import cachedtype
 from pypy.jit.timeshifter import rvalue, rtimeshift
-from pypy.translator import exceptiontransform
+from pypy.jit.timeshifter.rcontainer import cachedtype
+from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.unroll import unrolling_iterable
+from pypy.rpython.extregistry import ExtRegistryEntry
+from pypy.rpython.lltypesystem import lltype
 from pypy.tool.sourcetools import func_with_new_name
+from pypy.translator import exceptiontransform
 
 
 class SegfaultException(Exception):
@@ -21,6 +22,7 @@
     do_call = None
 
     def __init__(self, RGenOp, rtyper, fnobj, can_raise):
+        self.rtyper = rtyper
         ll_func = fnobj._callable
         FUNCTYPE = lltype.typeOf(fnobj)
         nb_args = len(FUNCTYPE.ARGS)
@@ -151,8 +153,12 @@
         return self.redboxbuilder(self.result_kind, gv_result)
 
     def residual_exception(self, jitstate, ExcCls):
-        ll_evalue = get_ll_instance_for_exccls(ExcCls)
-        jitstate.residual_ll_exception(ll_evalue)
+        from pypy.jit.rainbow.codewriter import residual_exception_nontranslated
+        if we_are_translated():
+            ll_evalue = get_ll_instance_for_exccls(ExcCls)
+            jitstate.residual_ll_exception(ll_evalue)
+        else:
+            residual_exception_nontranslated(jitstate, ExcClass(), self.rtyper)
         return self.errorbox
     residual_exception._annspecialcase_ = 'specialize:arg(2)'
 

Modified: pypy/branch/jit-refactoring/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/timeshifter/rtimeshift.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/timeshifter/rtimeshift.py	Sat Mar  1 20:26:08 2008
@@ -555,7 +555,7 @@
     jitstate.next = dispatchqueue.return_chain
     dispatchqueue.return_chain = jitstate
 
-def ll_learn_nonzeroness(jitstate, ptrbox, nonzeroness):
+def learn_nonzeroness(jitstate, ptrbox, nonzeroness):
     ptrbox.learn_nonzeroness(jitstate, nonzeroness)
 
 ##def ll_gvar_from_redbox(jitstate, redbox):
@@ -1204,7 +1204,6 @@
     def residual_exception(self, e):
         self.residual_ll_exception(cast_instance_to_base_ptr(e))
 
-
     def get_resuming(self):
         return self.frame.dispatchqueue.resuming
 



More information about the Pypy-commit mailing list