[pypy-svn] r77931 - in pypy/branch/jitffi/pypy: jit/codewriter jit/metainterp/optimizeopt jit/metainterp/test rlib/test
antocuni at codespeak.net
antocuni at codespeak.net
Thu Oct 14 15:23:12 CEST 2010
Author: antocuni
Date: Thu Oct 14 15:23:11 2010
New Revision: 77931
Modified:
pypy/branch/jitffi/pypy/jit/codewriter/jtransform.py
pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizefficall.py
pypy/branch/jitffi/pypy/rlib/test/test_libffi.py
Log:
attach the correct effectinfo to the libffi oopspec, and adapt the optimizer
and the tests: now the ffi call is done through CALL_MAY_FORCE, not simply CALL.
It might force in case of callbacks
Modified: pypy/branch/jitffi/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/codewriter/jtransform.py (original)
+++ pypy/branch/jitffi/pypy/jit/codewriter/jtransform.py Thu Oct 14 15:23:11 2010
@@ -1030,8 +1030,10 @@
# ----------
# Strings and Unicodes.
- def _handle_oopspec_call(self, op, args, oopspecindex):
+ def _handle_oopspec_call(self, op, args, oopspecindex, extraeffect=None):
calldescr = self.callcontrol.getcalldescr(op, oopspecindex)
+ if extraeffect:
+ calldescr.get_extra_info().extraeffect = extraeffect
if isinstance(op.args[0].value, str):
pass # for tests only
else:
@@ -1129,13 +1131,16 @@
def _handle_libffi_call(self, op, oopspec_name, args):
if oopspec_name == 'libffi_prepare_call':
oopspecindex = EffectInfo.OS_LIBFFI_PREPARE
+ extraeffect = EffectInfo.EF_CANNOT_RAISE
elif oopspec_name.startswith('libffi_push_'):
oopspecindex = EffectInfo.OS_LIBFFI_PUSH_ARG
+ extraeffect = EffectInfo.EF_CANNOT_RAISE
elif oopspec_name.startswith('libffi_call_'):
oopspecindex = EffectInfo.OS_LIBFFI_CALL
+ extraeffect = EffectInfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE
else:
assert False, 'unsupported oopspec: %s' % oopspec_name
- return self._handle_oopspec_call(op, args, oopspecindex)
+ return self._handle_oopspec_call(op, args, oopspecindex, extraeffect)
def rewrite_op_jit_force_virtual(self, op):
return self._do_builtin_call(op)
Modified: pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py (original)
+++ pypy/branch/jitffi/pypy/jit/metainterp/optimizeopt/fficall.py Thu Oct 14 15:23:11 2010
@@ -88,6 +88,8 @@
# normal case
self.emit_operation(op)
+ optimize_CALL_MAY_FORCE = optimize_CALL
+
def _get_funcval(self, op):
funcval = self.getvalue(op.getarg(1))
if not funcval.is_constant():
@@ -113,7 +115,7 @@
for push_op in info.opargs:
argval = self.getvalue(push_op.getarg(2))
arglist.append(argval.force_box())
- newop = ResOperation(rop.CALL, arglist, op.result, descr=info.descr)
+ newop = ResOperation(rop.CALL_MAY_FORCE, arglist, op.result, descr=info.descr)
del self.func_infos[funcval]
return newop
Modified: pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizefficall.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizefficall.py (original)
+++ pypy/branch/jitffi/pypy/jit/metainterp/test/test_optimizefficall.py Thu Oct 14 15:23:11 2010
@@ -57,12 +57,16 @@
call(0, ConstPtr(func), descr=libffi_prepare)
call(0, ConstPtr(func), i0, descr=libffi_push_arg)
call(0, ConstPtr(func), f1, descr=libffi_push_arg)
- i3 = call(0, ConstPtr(func), 12345, descr=libffi_call)
+ i3 = call_may_force(0, ConstPtr(func), 12345, descr=libffi_call)
+ guard_not_forced() []
+ guard_no_exception() []
jump(i3, f1)
"""
expected = """
[i0, f1]
- i3 = call(12345, i0, f1, descr=int_float__int)
+ i3 = call_may_force(12345, i0, f1, descr=int_float__int)
+ guard_not_forced() []
+ guard_no_exception() []
jump(i3, f1)
"""
loop = self.optimize_loop(ops, 'Not, Not', expected)
Modified: pypy/branch/jitffi/pypy/rlib/test/test_libffi.py
==============================================================================
--- pypy/branch/jitffi/pypy/rlib/test/test_libffi.py (original)
+++ pypy/branch/jitffi/pypy/rlib/test/test_libffi.py Thu Oct 14 15:23:11 2010
@@ -133,8 +133,9 @@
res = self.call(func, [38, 4.2], rffi.LONG)
assert res == 42
self.check_loops({
- 'call': 1,
+ 'call_may_force': 1,
'guard_no_exception': 1,
+ 'guard_not_forced': 1,
'int_add': 1,
'int_lt': 1,
'guard_true': 1,
@@ -145,7 +146,7 @@
func = (libm, 'pow', [types.double, types.double], types.double)
res = self.call(func, [2.0, 3.0], rffi.DOUBLE, init_result=0.0)
assert res == 8.0
- self.check_loops(call=1)
+ self.check_loops(call_may_force=1, guard_no_exception=1, guard_not_forced=1)
def test_cast_result(self):
"""
@@ -158,7 +159,7 @@
func = (libfoo, 'cast_to_uchar_and_ovf', [types.sint], types.uchar)
res = self.call(func, [0], rffi.UCHAR)
assert res == 200
- self.check_loops(call=1)
+ self.check_loops(call_may_force=1, guard_no_exception=1, guard_not_forced=1)
def test_cast_argument(self):
"""
More information about the Pypy-commit
mailing list