Author: Armin Rigo <[email protected]>
Branch:
Changeset: r63146:aaf788a134be
Date: 2013-04-08 18:31 +0200
http://bitbucket.org/pypy/pypy/changeset/aaf788a134be/
Log: Test and fix for debug_fatalerror in the blackhole interp.
diff --git a/rpython/jit/metainterp/blackhole.py
b/rpython/jit/metainterp/blackhole.py
--- a/rpython/jit/metainterp/blackhole.py
+++ b/rpython/jit/metainterp/blackhole.py
@@ -857,6 +857,8 @@
@arguments("r")
def bhimpl_debug_fatalerror(msg):
+ from rpython.rtyper.lltypesystem import rstr
+ msg = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), msg)
llop.debug_fatalerror(lltype.Void, msg)
@arguments("r", "i", "i", "i", "i")
diff --git a/rpython/jit/metainterp/test/test_blackhole.py
b/rpython/jit/metainterp/test/test_blackhole.py
--- a/rpython/jit/metainterp/test/test_blackhole.py
+++ b/rpython/jit/metainterp/test/test_blackhole.py
@@ -228,5 +228,15 @@
assert BlackholeInterpreter.bhimpl_int_lshift.im_func(100, 3) == 100<<3
assert BlackholeInterpreter.bhimpl_int_rshift.im_func(100, 3) == 100>>3
- assert BlackholeInterpreter.bhimpl_uint_rshift.im_func(100, 3) == 100>>3
-
+ assert BlackholeInterpreter.bhimpl_uint_rshift.im_func(100, 3) == 100>>3
+
+def test_debug_fatalerror():
+ from rpython.rtyper.lltypesystem import lltype, llmemory, rstr
+ from rpython.rtyper.llinterp import LLFatalError
+ msg = rstr.mallocstr(1)
+ msg.chars[0] = "!"
+ msg = lltype.cast_opaque_ptr(llmemory.GCREF, msg)
+ e = py.test.raises(LLFatalError,
+ BlackholeInterpreter.bhimpl_debug_fatalerror.im_func,
+ msg)
+ assert str(e.value) == '!'
diff --git a/rpython/rtyper/lltypesystem/lloperation.py
b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -555,7 +555,7 @@
'debug_offset': LLOp(canrun=True),
'debug_flush': LLOp(canrun=True),
'debug_assert': LLOp(tryfold=True),
- 'debug_fatalerror': LLOp(),
+ 'debug_fatalerror': LLOp(canrun=True),
'debug_llinterpcall': LLOp(canraise=(Exception,)),
# Python func call 'res=arg[0](*arg[1:])'
# in backends, abort() or whatever is fine
diff --git a/rpython/rtyper/lltypesystem/opimpl.py
b/rpython/rtyper/lltypesystem/opimpl.py
--- a/rpython/rtyper/lltypesystem/opimpl.py
+++ b/rpython/rtyper/lltypesystem/opimpl.py
@@ -654,6 +654,13 @@
from rpython.rlib.rtimer import read_timestamp
return read_timestamp()
+def op_debug_fatalerror(ll_msg):
+ from rpython.rtyper.lltypesystem import lltype, rstr
+ from rpython.rtyper.llinterp import LLFatalError
+ assert lltype.typeOf(ll_msg) == lltype.Ptr(rstr.STR)
+ msg = ''.join(ll_msg.chars)
+ raise LLFatalError(msg)
+
# ____________________________________________________________
def get_op_impl(opname):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit