Author: Armin Rigo <ar...@tunes.org> Branch: conditional_call_value_3 Changeset: r87019:377865d888be Date: 2016-09-12 10:41 +0200 http://bitbucket.org/pypy/pypy/changeset/377865d888be/
Log: Rewrite: expand to cond_call_value diff --git a/rpython/jit/backend/llsupport/rewrite.py b/rpython/jit/backend/llsupport/rewrite.py --- a/rpython/jit/backend/llsupport/rewrite.py +++ b/rpython/jit/backend/llsupport/rewrite.py @@ -11,7 +11,7 @@ from rpython.jit.backend.llsupport.symbolic import (WORD, get_array_token) from rpython.jit.backend.llsupport.descr import SizeDescr, ArrayDescr,\ - FLAG_POINTER + FLAG_POINTER, CallDescr from rpython.jit.metainterp.history import JitCellToken from rpython.jit.backend.llsupport.descr import (unpack_arraydescr, unpack_fielddescr, unpack_interiorfielddescr) @@ -370,7 +370,9 @@ self.consider_setfield_gc(op) elif op.getopnum() == rop.SETARRAYITEM_GC: self.consider_setarrayitem_gc(op) - # ---------- call assembler ----------- + # ---------- calls ----------- + if OpHelpers.is_plain_call(op.getopnum()): + self.expand_call_shortcut(op) if OpHelpers.is_call_assembler(op.getopnum()): self.handle_call_assembler(op) continue @@ -616,6 +618,28 @@ self.emit_gc_store_or_indexed(None, ptr, ConstInt(0), value, size, 1, ofs) + def expand_call_shortcut(self, op): + descr = op.getdescr() + if descr is None: + return + assert isinstance(descr, CallDescr) + effectinfo = descr.get_extra_info() + if effectinfo is None or effectinfo.call_shortcut is None: + return + if op.type == 'r': + cond_call_opnum = rop.COND_CALL_VALUE_R + elif op.type == 'i': + cond_call_opnum = rop.COND_CALL_VALUE_I + else: + return + cs = effectinfo.call_shortcut + ptr_box = op.getarg(1 + cs.argnum) + value_box = self.emit_getfield(ptr_box, descr=cs.fielddescr, + raw=(ptr_box.type == 'i')) + self.replace_op_with(op, ResOperation(cond_call_opnum, + [value_box] + op.getarglist(), + descr=descr)) + def handle_call_assembler(self, op): descrs = self.gc_ll_descr.getframedescrs(self.cpu) loop_token = op.getdescr() diff --git a/rpython/jit/backend/llsupport/test/test_rewrite.py b/rpython/jit/backend/llsupport/test/test_rewrite.py --- a/rpython/jit/backend/llsupport/test/test_rewrite.py +++ b/rpython/jit/backend/llsupport/test/test_rewrite.py @@ -1,7 +1,8 @@ import py from rpython.jit.backend.llsupport.descr import get_size_descr,\ get_field_descr, get_array_descr, ArrayDescr, FieldDescr,\ - SizeDescr, get_interiorfield_descr + SizeDescr, get_interiorfield_descr, get_call_descr +from rpython.jit.codewriter.effectinfo import EffectInfo, CallShortcut from rpython.jit.backend.llsupport.gc import GcLLDescr_boehm,\ GcLLDescr_framework from rpython.jit.backend.llsupport import jitframe @@ -80,6 +81,14 @@ lltype.malloc(T, zero=True)) self.myT = myT # + call_shortcut = CallShortcut(0, tzdescr) + effectinfo = EffectInfo(None, None, None, None, None, None, + EffectInfo.EF_RANDOM_EFFECTS, + call_shortcut=call_shortcut) + call_shortcut_descr = get_call_descr(self.gc_ll_descr, + [lltype.Ptr(T)], lltype.Signed, + effectinfo) + # A = lltype.GcArray(lltype.Signed) adescr = get_array_descr(self.gc_ll_descr, A) adescr.tid = 4321 @@ -1429,3 +1438,15 @@ jump() """) assert len(self.gcrefs) == 2 + + def test_handle_call_shortcut(self): + self.check_rewrite(""" + [p0] + i1 = call_i(123, p0, descr=call_shortcut_descr) + jump(i1) + """, """ + [p0] + i2 = gc_load_i(p0, %(tzdescr.offset)s, %(tzdescr.field_size)s) + i1 = cond_call_value_i(i2, 123, p0, descr=call_shortcut_descr) + jump(i1) + """) diff --git a/rpython/jit/metainterp/executor.py b/rpython/jit/metainterp/executor.py --- a/rpython/jit/metainterp/executor.py +++ b/rpython/jit/metainterp/executor.py @@ -366,6 +366,8 @@ rop.CALL_ASSEMBLER_I, rop.CALL_ASSEMBLER_N, rop.INCREMENT_DEBUG_COUNTER, + rop.COND_CALL_VALUE_R, + rop.COND_CALL_VALUE_I, rop.COND_CALL_GC_WB, rop.COND_CALL_GC_WB_ARRAY, rop.ZERO_ARRAY, 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 @@ -1150,6 +1150,7 @@ '_CALL_FIRST', 'CALL/*d/rfin', 'COND_CALL/*d/n', + 'COND_CALL_VALUE/*d/ri', # a conditional call, with first argument as a condition 'CALL_ASSEMBLER/*d/rfin', # call already compiled assembler 'CALL_MAY_FORCE/*d/rfin', _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit