aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pypy/jit/backend/llgraph/llimpl.py14
-rw-r--r--pypy/jit/backend/test/runner_test.py2
-rw-r--r--pypy/jit/metainterp/executor.py4
-rw-r--r--pypy/jit/metainterp/optimizeopt/fficall.py4
-rw-r--r--pypy/jit/metainterp/optimizeopt/heap.py3
-rw-r--r--pypy/jit/metainterp/resoperation.py1
-rw-r--r--pypy/jit/metainterp/test/test_optimizefficall.py10
-rw-r--r--pypy/rlib/test/test_libffi.py6
8 files changed, 27 insertions, 17 deletions
diff --git a/pypy/jit/backend/llgraph/llimpl.py b/pypy/jit/backend/llgraph/llimpl.py
index 0a56ac259a..c6890aa35a 100644
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -807,6 +807,12 @@ class Frame(object):
raise NotImplementedError
def op_call(self, calldescr, func, *args):
+ return self._do_call(calldescr, func, args, call_with_llptr=False)
+
+ def op_call_release_gil(self, calldescr, func, *args):
+ return self._do_call(calldescr, func, args, call_with_llptr=True)
+
+ def _do_call(self, calldescr, func, args, call_with_llptr):
global _last_exception
assert _last_exception is None, "exception left behind"
assert _call_args_i == _call_args_r == _call_args_f == []
@@ -825,7 +831,8 @@ class Frame(object):
else:
raise TypeError(x)
try:
- return _do_call_common(func, args_in_order, calldescr)
+ return _do_call_common(func, args_in_order, calldescr,
+ call_with_llptr)
except LLException, lle:
_last_exception = lle
d = {'v': None,
@@ -1452,17 +1459,20 @@ kind2TYPE = {
'v': lltype.Void,
}
-def _do_call_common(f, args_in_order=None, calldescr=None):
+def _do_call_common(f, args_in_order=None, calldescr=None,
+ call_with_llptr=False):
ptr = llmemory.cast_int_to_adr(f).ptr
PTR = lltype.typeOf(ptr)
if PTR == rffi.VOIDP:
# it's a pointer to a C function, so we don't have a precise
# signature: create one from the descr
+ assert call_with_llptr is True
ARGS = map(kind2TYPE.get, calldescr.arg_types)
RESULT = kind2TYPE[calldescr.typeinfo]
FUNC = lltype.FuncType(ARGS, RESULT)
func_to_call = rffi.cast(lltype.Ptr(FUNC), ptr)
else:
+ assert call_with_llptr is False
FUNC = PTR.TO
ARGS = FUNC.ARGS
func_to_call = ptr._obj._callable
diff --git a/pypy/jit/backend/test/runner_test.py b/pypy/jit/backend/test/runner_test.py
index 2c3e1be548..2d4f495e13 100644
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -534,7 +534,7 @@ class BaseBackendTest(Runner):
func_adr = llmemory.cast_ptr_to_adr(c_tolower.funcsym)
funcbox = ConstInt(heaptracker.adr2int(func_adr))
calldescr = self.cpu.calldescrof_dynamic([types.uchar], types.sint)
- res = self.execute_operation(rop.CALL,
+ res = self.execute_operation(rop.CALL_RELEASE_GIL,
[funcbox, BoxInt(ord('A'))],
'int',
descr=calldescr)
diff --git a/pypy/jit/metainterp/executor.py b/pypy/jit/metainterp/executor.py
index cb5b6cda8c..f78d890f68 100644
--- a/pypy/jit/metainterp/executor.py
+++ b/pypy/jit/metainterp/executor.py
@@ -80,9 +80,6 @@ def do_call(cpu, metainterp, argboxes, descr):
do_call_loopinvariant = do_call
do_call_may_force = do_call
-def do_call_c(cpu, metainterp, argboxes, descr):
- raise NotImplementedError("Should never be called directly")
-
def do_getarrayitem_gc(cpu, _, arraybox, indexbox, arraydescr):
array = arraybox.getref_base()
index = indexbox.getint()
@@ -309,6 +306,7 @@ def _make_execute_list():
rop.DEBUG_MERGE_POINT,
rop.JIT_DEBUG,
rop.SETARRAYITEM_RAW,
+ rop.CALL_RELEASE_GIL,
): # list of opcodes never executed by pyjitpl
continue
raise AssertionError("missing %r" % (key,))
diff --git a/pypy/jit/metainterp/optimizeopt/fficall.py b/pypy/jit/metainterp/optimizeopt/fficall.py
index 9ff55a3484..099183ab15 100644
--- a/pypy/jit/metainterp/optimizeopt/fficall.py
+++ b/pypy/jit/metainterp/optimizeopt/fficall.py
@@ -73,7 +73,7 @@ class OptFfiCall(Optimization):
def setup(self):
self.funcinfo = None
- self.logger = self.optimizer.metainterp_sd.logger_noopt
+ self.logger = self.optimizer.metainterp_sd.logger_ops
def propagate_begin_forward(self):
debug_start('jit-log-ffiopt')
@@ -188,7 +188,7 @@ class OptFfiCall(Optimization):
for push_op in funcinfo.opargs:
argval = self.getvalue(push_op.getarg(2))
arglist.append(argval.force_box())
- newop = ResOperation(rop.CALL_MAY_FORCE, arglist, op.result,
+ newop = ResOperation(rop.CALL_RELEASE_GIL, arglist, op.result,
descr=funcinfo.descr)
self.commit_optimization()
ops = []
diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py
index a548e2a245..7dc169f661 100644
--- a/pypy/jit/metainterp/optimizeopt/heap.py
+++ b/pypy/jit/metainterp/optimizeopt/heap.py
@@ -161,6 +161,7 @@ class OptHeap(Optimization):
assert opnum != rop.CALL_PURE
if (opnum == rop.CALL or
opnum == rop.CALL_MAY_FORCE or
+ opnum == rop.CALL_RELEASE_GIL or
opnum == rop.CALL_ASSEMBLER):
if opnum == rop.CALL_ASSEMBLER:
effectinfo = None
@@ -235,7 +236,7 @@ class OptHeap(Optimization):
opnum = prevop.getopnum()
lastop_args = lastop.getarglist()
if ((prevop.is_comparison() or opnum == rop.CALL_MAY_FORCE
- or prevop.is_ovf())
+ or opnum == rop.CALL_RELEASE_GIL or prevop.is_ovf())
and prevop.result not in lastop_args):
newoperations[-2] = lastop
newoperations[-1] = prevop
diff --git a/pypy/jit/metainterp/resoperation.py b/pypy/jit/metainterp/resoperation.py
index 08e2e7126c..ffe0e7687d 100644
--- a/pypy/jit/metainterp/resoperation.py
+++ b/pypy/jit/metainterp/resoperation.py
@@ -482,6 +482,7 @@ _oplist = [
'CALL_ASSEMBLER/*d', # call already compiled assembler
'CALL_MAY_FORCE/*d',
'CALL_LOOPINVARIANT/*d',
+ 'CALL_RELEASE_GIL/*d', # release the GIL and "close the stack" for asmgcc
#'OOSEND', # ootype operation
#'OOSEND_PURE', # ootype operation
'CALL_PURE/*d', # removed before it's passed to the backend
diff --git a/pypy/jit/metainterp/test/test_optimizefficall.py b/pypy/jit/metainterp/test/test_optimizefficall.py
index 6f9a9a9e9e..be5e18a41b 100644
--- a/pypy/jit/metainterp/test/test_optimizefficall.py
+++ b/pypy/jit/metainterp/test/test_optimizefficall.py
@@ -78,7 +78,7 @@ class TestFfiCall(BaseTestBasic, LLtypeMixin):
"""
expected = """
[i0, f1]
- i3 = call_may_force(12345, i0, f1, descr=int_float__int)
+ i3 = call_release_gil(12345, i0, f1, descr=int_float__int)
guard_not_forced() []
guard_no_exception() []
jump(i3, f1)
@@ -101,7 +101,7 @@ class TestFfiCall(BaseTestBasic, LLtypeMixin):
def test_handle_virtualizables(self):
# this test needs an explanation to understand what goes on: see the
- # coment in optimize_FORCE_TOKEN
+ # comment in optimize_FORCE_TOKEN
ops = """
[i0, f1, p2]
call(0, ConstPtr(func), descr=libffi_prepare)
@@ -118,7 +118,7 @@ class TestFfiCall(BaseTestBasic, LLtypeMixin):
[i0, f1, p2]
i4 = force_token()
setfield_gc(p2, i4, descr=vable_token_descr)
- i3 = call_may_force(12345, i0, f1, descr=int_float__int)
+ i3 = call_release_gil(12345, i0, f1, descr=int_float__int)
guard_not_forced() [p2]
guard_no_exception() [p2]
jump(i3, f1, p2)
@@ -215,7 +215,7 @@ class TestFfiCall(BaseTestBasic, LLtypeMixin):
call(0, ConstPtr(func), descr=libffi_prepare)
#
# this "nested" call is nicely optimized
- i4 = call_may_force(67890, i0, f1, descr=int_float__int)
+ i4 = call_release_gil(67890, i0, f1, descr=int_float__int)
guard_not_forced() []
guard_no_exception() []
#
@@ -260,7 +260,7 @@ class TestFfiCall(BaseTestBasic, LLtypeMixin):
expected = """
[i0, f1, p2]
setfield_gc(p2, i0, descr=valuedescr)
- i3 = call_may_force(12345, i0, f1, descr=int_float__int)
+ i3 = call_release_gil(12345, i0, f1, descr=int_float__int)
guard_not_forced() []
guard_no_exception() []
jump(i3, f1, p2)
diff --git a/pypy/rlib/test/test_libffi.py b/pypy/rlib/test/test_libffi.py
index 5b9f9fdec8..1140fc485b 100644
--- a/pypy/rlib/test/test_libffi.py
+++ b/pypy/rlib/test/test_libffi.py
@@ -159,7 +159,7 @@ class TestLibffiCall(BaseFfiTest):
res = self.call(func, [38, 4.2], rffi.LONG)
assert res == 42
self.check_loops({
- 'call_may_force': 1,
+ 'call_release_gil': 1,
'guard_no_exception': 1,
'guard_not_forced': 1,
'int_add': 1,
@@ -172,7 +172,7 @@ class TestLibffiCall(BaseFfiTest):
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_may_force=1, guard_no_exception=1, guard_not_forced=1)
+ self.check_loops(call_release_gil=1, guard_no_exception=1, guard_not_forced=1)
def test_cast_result(self):
"""
@@ -185,7 +185,7 @@ class TestLibffiCall(BaseFfiTest):
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_may_force=1, guard_no_exception=1, guard_not_forced=1)
+ self.check_loops(call_release_gil=1, guard_no_exception=1, guard_not_forced=1)
def test_cast_argument(self):
"""