[pypy-svn] r52523 - in pypy/branch/jit-hotpath/pypy: jit/rainbow jit/rainbow/test rlib
arigo at codespeak.net
arigo at codespeak.net
Fri Mar 14 18:39:21 CET 2008
Author: arigo
Date: Fri Mar 14 18:39:21 2008
New Revision: 52523
Modified:
pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py
pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hotpath.py
pypy/branch/jit-hotpath/pypy/rlib/debug.py
Log:
Implement fb_raise. Redirect debug_trace() to the debug_print
llop when translating the support code.
The first test passes!
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/fallback.py Fri Mar 14 18:39:21 2008
@@ -2,6 +2,7 @@
from pypy.rlib.unroll import unrolling_iterable
from pypy.rlib.objectmodel import we_are_translated, CDefinedIntSymbolic
from pypy.rpython.lltypesystem import lltype, llmemory, lloperation
+from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
from pypy.jit.timeshifter import rvalue
from pypy.jit.timeshifter.greenkey import empty_key, GreenKey
from pypy.jit.rainbow.interpreter import SIGN_EXTEND2, arguments
@@ -108,15 +109,15 @@
# at this point we might have an exception set in self.gv_exc_xxx
# and we have to really raise it.
exceptiondesc = self.exceptiondesc
- llexctype = self.gv_exc_type.revealconst(exceptiondesc.LL_EXC_TYPE)
- if llexctype:
+ llvalue = self.gv_exc_value.revealconst(exceptiondesc.LL_EXC_VALUE)
+ if llvalue:
if we_are_translated():
- lloperation.llop.debug_fatalerror(lltype.Void,
- "fb_raise not implemented")
- assert 0
- # XXX non-translatable hack follows...
+ exception = cast_base_ptr_to_instance(Exception, llvalue)
+ self.interpreter.debug_trace("fb_raise", str(exception))
+ raise Exception, exception
+ # non-translatable hack follows...
from pypy.rpython.llinterp import LLException, type_name
- llvalue = self.gv_exc_value.revealconst(exceptiondesc.LL_EXC_VALUE)
+ llexctype = self.gv_exc_type.revealconst(exceptiondesc.LL_EXC_TYPE)
assert llexctype and llvalue
self.interpreter.debug_trace("fb_raise", type_name(llexctype))
raise LLException(llexctype, llvalue)
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/interpreter.py Fri Mar 14 18:39:21 2008
@@ -1,6 +1,7 @@
from pypy.rlib.rarithmetic import intmask
from pypy.rlib.unroll import unrolling_iterable
from pypy.rlib.objectmodel import we_are_translated, CDefinedIntSymbolic, noop
+from pypy.rlib.debug import debug_print
from pypy.jit.timeshifter import rtimeshift, rcontainer, rvalue
from pypy.jit.timeshifter.greenkey import empty_key, GreenKey, newgreendict
from pypy.jit.rainbow import rhotpath
@@ -225,8 +226,11 @@
log.trace(trace)
self.debug_traces.append(trace)
- debug_trace = noop # RPython-friendly,
- # patched for tests in set_hotrunnerdesc()
+ # a choice of two RPython-friendly implementation,
+ # patched for tests in set_hotrunnerdesc():
+
+ #debug_trace = staticmethod(noop)
+ debug_trace = staticmethod(debug_print)
def set_hotrunnerdesc(self, hotrunnerdesc):
self.hotrunnerdesc = hotrunnerdesc
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hotpath.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hotpath.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_hotpath.py Fri Mar 14 18:39:21 2008
@@ -75,6 +75,8 @@
return self.hotrunnerdesc.interpreter.debug_traces
def check_traces(self, expected):
+ if self.translate_support_code:
+ return # XXX it would be nice to check traces in this case too
traces = self.get_traces()
i = 0
for trace, expect in zip(traces + ['--end of traces--'],
Modified: pypy/branch/jit-hotpath/pypy/rlib/debug.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/rlib/debug.py (original)
+++ pypy/branch/jit-hotpath/pypy/rlib/debug.py Fri Mar 14 18:39:21 2008
@@ -1,4 +1,4 @@
-
+import sys
from pypy.rpython.extregistry import ExtRegistryEntry
def ll_assert(x, msg):
@@ -16,9 +16,27 @@
def specialize_call(self, hop):
from pypy.rpython.lltypesystem import lltype
vlist = hop.inputargs(lltype.Bool, lltype.Void)
+ hop.exception_cannot_occur()
hop.genop('debug_assert', vlist)
+def debug_print(*args):
+ for arg in args:
+ print >> sys.stderr, arg,
+ print >> sys.stderr
+
+class Entry(ExtRegistryEntry):
+ _about_ = debug_print
+
+ def compute_result_annotation(self, *args_s):
+ return None
+
+ def specialize_call(self, hop):
+ vlist = hop.inputargs(*hop.args_r)
+ hop.exception_cannot_occur()
+ hop.genop('debug_print', vlist)
+
+
def llinterpcall(RESTYPE, pythonfunction, *args):
"""When running on the llinterp, this causes the llinterp to call to
the provided Python function with the run-time value of the given args.
More information about the Pypy-commit
mailing list