Author: Armin Rigo <[email protected]>
Branch: conditional_call_value_2
Changeset: r86999:ae04add86453
Date: 2016-09-11 16:09 +0200
http://bitbucket.org/pypy/pypy/changeset/ae04add86453/
Log: in-progress
diff --git a/rpython/jit/backend/llgraph/runner.py
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -1328,17 +1328,17 @@
x = math.sqrt(y)
return support.cast_to_floatstorage(x)
- def execute_cond_call_i(self, calldescr, cond, specialval, func, *args):
+ def execute_cond_call_pure_i(self, calldescr, cond, specialval,
func,*args):
if cond == specialval:
cond = self.execute_call_i(calldescr, func, *args)
return cond
- def execute_cond_call_r(self, calldescr, cond, specialval, func, *args):
+ def execute_cond_call_pure_r(self, calldescr, cond, specialval,
func,*args):
if cond == specialval:
cond = self.execute_call_r(calldescr, func, *args)
return cond
- def execute_cond_call_n(self, calldescr, cond, specialval, func, *args):
+ def execute_cond_call(self, calldescr, cond, specialval, func, *args):
assert specialval == 1
assert cond in (0, 1)
if cond == specialval:
diff --git a/rpython/jit/metainterp/heapcache.py
b/rpython/jit/metainterp/heapcache.py
--- a/rpython/jit/metainterp/heapcache.py
+++ b/rpython/jit/metainterp/heapcache.py
@@ -271,8 +271,7 @@
return
if (OpHelpers.is_plain_call(opnum) or
OpHelpers.is_call_loopinvariant(opnum) or
- opnum == rop.COND_CALL_I or
- opnum == rop.COND_CALL_R):
+ OpHelpers.is_cond_call_pure(opnum)):
effectinfo = descr.get_extra_info()
ef = effectinfo.extraeffect
if (ef == effectinfo.EF_LOOPINVARIANT or
diff --git a/rpython/jit/metainterp/pyjitpl.py
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -1076,7 +1076,7 @@
funcbox, argboxes, calldescr, pc):
self.do_conditional_call(condbox, specialvalbox,
funcbox, argboxes, calldescr, pc,
- rop.COND_CALL_N)
+ rop.COND_CALL)
@arguments("int", "boxes3", "boxes3", "orgpc")
def _opimpl_recursive_call(self, jdindex, greenboxes, redboxes, pc):
@@ -1554,8 +1554,8 @@
op = self.metainterp.execute_and_record_varargs(opnum, argboxes,
descr=descr)
if pure and not self.metainterp.last_exc_value and op:
- op = self.metainterp.record_result_of_call_pure(op, argboxes,
descr,
- patch_pos)
+ op = self.metainterp.record_result_of_call_pure(op, opnum,
+ argboxes, descr, patch_pos)
exc = exc and not isinstance(op, Const)
if exc:
if op is not None:
@@ -1739,7 +1739,7 @@
assert not effectinfo.check_forces_virtual_or_virtualizable()
exc = effectinfo.check_can_raise()
pure = effectinfo.check_is_elidable()
- assert pure == (opnum != rop.COND_CALL_N)
+ assert pure == (opnum != rop.COND_CALL)
return self.execute_varargs(opnum,
[condbox, specialvalbox] + allboxes,
descr, exc, pure)
@@ -3078,12 +3078,12 @@
debug_stop("jit-abort-longest-function")
return max_jdsd, max_key
- def record_result_of_call_pure(self, op, argboxes, descr, patch_pos):
+ def record_result_of_call_pure(self, op, opnum, argboxes, descr,
patch_pos):
""" Patch a CALL into a CALL_PURE.
"""
resbox_as_const = executor.constant_from_op(op)
- is_cond = (op.opnum == rop.COND_CALL_PURE_I or
- op.opnum == rop.COND_CALL_PURE_R)
+ is_cond = (opnum == rop.COND_CALL_PURE_I or
+ opnum == rop.COND_CALL_PURE_R)
if is_cond:
argboxes = argboxes[2:]
for argbox in argboxes:
@@ -3099,6 +3099,7 @@
arg_consts = [executor.constant_from_op(a) for a in argboxes]
self.call_pure_results[arg_consts] = resbox_as_const
if is_cond:
+ import pdb;pdb.set_trace()
return op # there is no COND_CALL_I/R
opnum = OpHelpers.call_pure_for_descr(descr)
self.history.cut(patch_pos)
diff --git a/rpython/jit/metainterp/resoperation.py
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -884,6 +884,8 @@
_args = None
def initarglist(self, args):
+ if self.opnum == rop.CALL_PURE_I:
+ import pdb;pdb.set_trace()
self._args = args
if not we_are_translated() and \
self.__class__.__name__.startswith('FINISH'): # XXX remove me
@@ -1439,6 +1441,11 @@
opnum == rop.CALL_RELEASE_GIL_N)
@staticmethod
+ def is_cond_call_pure(opnum):
+ return (opnum == rop.COND_CALL_PURE_I or
+ opnum == rop.COND_CALL_PURE_R)
+
+ @staticmethod
def is_ovf(opnum):
return rop._OVF_FIRST <= opnum <= rop._OVF_LAST
diff --git a/rpython/jit/metainterp/test/test_call.py
b/rpython/jit/metainterp/test/test_call.py
--- a/rpython/jit/metainterp/test/test_call.py
+++ b/rpython/jit/metainterp/test/test_call.py
@@ -54,18 +54,15 @@
self.check_resops(guard_no_exception=0)
def test_cond_call_i(self):
- @jit.elidable # not really, for tests
- def f(l, n):
- l.append(n)
- return 1000
+ @jit.elidable
+ def f(n):
+ return n * 200
def main(n):
- l = []
- x = jit.conditional_call_elidable(n, 10, f, l, n)
- return x + len(l)
+ return jit.conditional_call_elidable(n, 10, f, n)
- assert self.interp_operations(main, [10]) == 1001
- assert self.interp_operations(main, [5]) == 5
+ assert self.interp_operations(main, [10]) == 2000
+ assert self.interp_operations(main, [15]) == 15
def test_cond_call_r(self):
@jit.elidable
@@ -92,8 +89,11 @@
# to f() are constants.
return jit.conditional_call_elidable(n, 23, f, 40, 2)
- assert main(12) == 12 # because 12 != 23
- assert self.interp_operations(main, [12]) == 42 # == f(40, 2)
+ assert main(12) == 12 # because 12 != 23
+ assert self.interp_operations(main, [12]) == 12 # because 12 != 23
+ self.check_operations_history(finish=1) # empty history
+ assert self.interp_operations(main, [23]) == 42 # because 23 == 23
+ self.check_operations_history(finish=1) # empty history
class TestCall(LLJitMixin, CallTest):
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -1236,14 +1236,14 @@
def compute_result_annotation(self, *args_s):
from rpython.annotator import model as annmodel
- self.bookkeeper.emulate_pbc_call(self.bookkeeper.position_key,
- args_s[2], args_s[3:])
+ s_res = self.bookkeeper.emulate_pbc_call(self.bookkeeper.position_key,
+ args_s[2], args_s[3:])
if self.instance is _jit_conditional_call_elidable:
function = args_s[2].const
assert getattr(function, '_elidable_function_', False), (
"jit.conditional_call_elidable() must call an elidable "
"function, but got %r" % (function,))
- return args_s[0]
+ return annmodel.unionof(s_res, args_s[0])
def specialize_call(self, hop):
from rpython.rtyper.lltypesystem import lltype
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit