Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r69417:3c477e9543db Date: 2014-02-25 13:16 +0100 http://bitbucket.org/pypy/pypy/changeset/3c477e9543db/
Log: Test and fix: the _nowrapper C functions couldn't be elided before. diff --git a/rpython/jit/codewriter/test/test_call.py b/rpython/jit/codewriter/test/test_call.py --- a/rpython/jit/codewriter/test/test_call.py +++ b/rpython/jit/codewriter/test/test_call.py @@ -248,3 +248,26 @@ op = block.operations[-1] call_descr = cc.getcalldescr(op) assert call_descr.extrainfo.has_random_effects() + +def test_no_random_effects_for_rotateLeft(): + from rpython.jit.backend.llgraph.runner import LLGraphCPU + from rpython.rlib.rarithmetic import r_uint + + if r_uint.BITS == 32: + py.test.skip("64-bit only") + + from rpython.rlib.rmd5 import _rotateLeft + def f(n, m): + return _rotateLeft(r_uint(n), m) + + rtyper = support.annotate(f, [7, 9]) + jitdriver_sd = FakeJitDriverSD(rtyper.annotator.translator.graphs[0]) + cc = CallControl(LLGraphCPU(rtyper), jitdrivers_sd=[jitdriver_sd]) + res = cc.find_all_graphs(FakePolicy()) + + [f_graph] = [x for x in res if x.func is f] + [block, _] = list(f_graph.iterblocks()) + op = block.operations[-1] + call_descr = cc.getcalldescr(op) + assert not call_descr.extrainfo.has_random_effects() + assert call_descr.extrainfo.check_is_elidable() diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py --- a/rpython/rtyper/lltypesystem/rffi.py +++ b/rpython/rtyper/lltypesystem/rffi.py @@ -116,12 +116,14 @@ # default case: # invoke the around-handlers only for "not too small" external calls; # sandboxsafe is a hint for "too-small-ness" (e.g. math functions). - invoke_around_handlers = not sandboxsafe + # Also, _nowrapper functions cannot release the GIL, by default. + invoke_around_handlers = not sandboxsafe and not _nowrapper if random_effects_on_gcobjs not in (False, True): random_effects_on_gcobjs = ( invoke_around_handlers or # because it can release the GIL has_callback) # because the callback can do it + assert not (elidable_function and random_effects_on_gcobjs) funcptr = lltype.functionptr(ext_type, name, external='C', compilation_info=compilation_info, _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit