[pypy-svn] pypy default: (arigo (and alex and greg around))
arigo
commits-noreply at bitbucket.org
Thu Mar 17 01:11:31 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r42730:7e193f3296f7
Date: 2011-03-16 20:10 -0400
http://bitbucket.org/pypy/pypy/changeset/7e193f3296f7/
Log: (arigo (and alex and greg around))
Fix an obscure case triggered when the portal returns a short
integer-like type (like a char or a bool). Fixed by changing the
signature of assembler_call_helper() and handle_jitexception() to
return the standardized type instead of a char or a bool.
diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -47,7 +47,7 @@
elif isinstance(value, float):
return longlong.getfloatstorage(value)
else:
- return intmask(value)
+ return lltype.cast_primitive(lltype.Signed, value)
@specialize.arg(0)
def unwrap(TYPE, box):
diff --git a/pypy/jit/backend/x86/test/test_ztranslation.py b/pypy/jit/backend/x86/test/test_ztranslation.py
--- a/pypy/jit/backend/x86/test/test_ztranslation.py
+++ b/pypy/jit/backend/x86/test/test_ztranslation.py
@@ -64,7 +64,7 @@
k = myabs(j)
if k - abs(j): raise ValueError
if k - abs(-j): raise ValueError
- return total * 10
+ return chr(total % 253)
#
from pypy.rpython.lltypesystem import lltype, rffi
from pypy.rlib.libffi import types, CDLL, ArgChain
@@ -84,10 +84,12 @@
argchain.arg(x)
res = func.call(argchain, rffi.DOUBLE)
i -= 1
- return int(res)
+ return res
#
def main(i, j):
- return f(i, j) + libffi_stuff(i, j)
+ a_char = f(i, j)
+ a_float = libffi_stuff(i, j)
+ return ord(a_char) * 10 + int(a_float)
expected = main(40, -49)
res = self.meta_interp(main, [40, -49])
assert res == expected
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -489,8 +489,19 @@
jd._PTR_JIT_ENTER_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, lltype.Void)
(jd._PORTAL_FUNCTYPE,
jd._PTR_PORTAL_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, RESTYPE)
+ #
+ if jd.result_type == 'v':
+ ASMRESTYPE = lltype.Void
+ elif jd.result_type == history.INT:
+ ASMRESTYPE = lltype.Signed
+ elif jd.result_type == history.REF:
+ ASMRESTYPE = llmemory.GCREF
+ elif jd.result_type == history.FLOAT:
+ ASMRESTYPE = lltype.Float
+ else:
+ assert False
(_, jd._PTR_ASSEMBLER_HELPER_FUNCTYPE) = self.cpu.ts.get_FuncType(
- [lltype.Signed, llmemory.GCREF], RESTYPE)
+ [lltype.Signed, llmemory.GCREF], ASMRESTYPE)
def rewrite_can_enter_jits(self):
sublists = {}
@@ -671,7 +682,7 @@
raise Exception, value
def handle_jitexception(e):
- # XXX the bulk of this function is a copy-paste from above :-(
+ # XXX the bulk of this function is mostly a copy-paste from above
try:
raise e
except self.ContinueRunningNormally, e:
@@ -680,19 +691,22 @@
x = getattr(e, attrname)[count]
x = specialize_value(ARGTYPE, x)
args = args + (x,)
- return ll_portal_runner(*args)
+ result = ll_portal_runner(*args)
+ if result_kind != 'void':
+ result = unspecialize_value(result)
+ return result
except self.DoneWithThisFrameVoid:
assert result_kind == 'void'
return
except self.DoneWithThisFrameInt, e:
assert result_kind == 'int'
- return specialize_value(RESULT, e.result)
+ return e.result
except self.DoneWithThisFrameRef, e:
assert result_kind == 'ref'
- return specialize_value(RESULT, e.result)
+ return e.result
except self.DoneWithThisFrameFloat, e:
assert result_kind == 'float'
- return specialize_value(RESULT, e.result)
+ return e.result
except self.ExitFrameWithExceptionRef, e:
value = ts.cast_to_baseclass(e.value)
if not we_are_translated():
@@ -736,17 +750,16 @@
def handle_jitexception_from_blackhole(bhcaller, e):
result = handle_jitexception(e)
- #
- if result_kind != 'void':
- result = unspecialize_value(result)
- if result_kind == 'int':
- bhcaller._setup_return_value_i(result)
- elif result_kind == 'ref':
- bhcaller._setup_return_value_r(result)
- elif result_kind == 'float':
- bhcaller._setup_return_value_f(result)
- else:
- assert False
+ if result_kind == 'void':
+ pass
+ if result_kind == 'int':
+ bhcaller._setup_return_value_i(result)
+ elif result_kind == 'ref':
+ bhcaller._setup_return_value_r(result)
+ elif result_kind == 'float':
+ bhcaller._setup_return_value_f(result)
+ else:
+ assert False
jd.handle_jitexc_from_bh = handle_jitexception_from_blackhole
# ____________________________________________________________
More information about the Pypy-commit
mailing list