Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: guard-compatible Changeset: r83008:8969fdd0d8d4 Date: 2016-03-13 13:43 +0100 http://bitbucket.org/pypy/pypy/changeset/8969fdd0d8d4/
Log: a new CPU interface for guard_compatible, a test for it and an llgraph implementation 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 @@ -470,6 +470,12 @@ assert deadframe._saved_data is not None return deadframe._saved_data + def grow_guard_compatible_switch(self, descr, ref): + if not hasattr(descr, '_guard_compatible_llgraph_lst'): + descr._guard_compatible_llgraph_lst = [] + descr._guard_compatible_llgraph_lst.append(ref) + + # ------------------------------------------------------------ def calldescrof(self, FUNC, ARGS, RESULT, effect_info): @@ -1273,8 +1279,11 @@ def execute_guard_compatible(self, descr, arg1, arg2): if arg1 != arg2: - if descr.fake_check_against_list(self.cpu, arg1): - return + if hasattr(descr, '_guard_compatible_llgraph_lst'): + lst = descr._guard_compatible_llgraph_lst + for ref in lst: + if ref == arg1: + return self.fail_guard(descr, extra_value=arg1) def execute_int_add_ovf(self, _, x, y): diff --git a/rpython/jit/backend/model.py b/rpython/jit/backend/model.py --- a/rpython/jit/backend/model.py +++ b/rpython/jit/backend/model.py @@ -158,6 +158,14 @@ """ pass + def grow_guard_compatible_switch(self, guarddescr, gcref): + """ This method is called to add another case to a guard_compatible. + guard_compatible starts like a guard_value, but can grow to check more + cases. The guard should only fail if the argument is unequal to all the + cases added so far. + """ + raise NotImplementedError + def sizeof(self, S): raise NotImplementedError diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py --- a/rpython/jit/backend/test/runner_test.py +++ b/rpython/jit/backend/test/runner_test.py @@ -5,7 +5,7 @@ BasicFinalDescr, JitCellToken, TargetToken, ConstInt, ConstPtr, - ConstFloat, Const) + ConstFloat, Const, newconst) from rpython.jit.metainterp.resoperation import ResOperation, rop, InputArgInt,\ InputArgFloat, opname, InputArgRef from rpython.jit.metainterp.typesystem import deref @@ -190,6 +190,36 @@ res = self.cpu.get_int_value(deadframe, 0) assert res == 10 + def test_extend_guard_compatible(self): + t1_box, T1_box, d1 = self.alloc_instance(self.T) + t2_box, T2_box, d2 = self.alloc_instance(self.T) + t3_box, T3_box, d3 = self.alloc_instance(self.T) + faildescr1 = BasicFailDescr(1) + loop = parse(""" + [p0] + guard_compatible(p0, ConstPtr(t1), descr=faildescr1) [] + finish(p0, descr=fdescr) + """, namespace={'fdescr': BasicFinalDescr(2), + 'faildescr1': faildescr1, + 't1': t1_box._resref}) + looptoken = JitCellToken() + self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken) + deadframe = self.cpu.execute_token(looptoken, + t1_box._resref) + fail = self.cpu.get_latest_descr(deadframe) + assert fail.identifier == 2 + + deadframe = self.cpu.execute_token(looptoken, + t2_box._resref) + fail = self.cpu.get_latest_descr(deadframe) + assert fail.identifier == 1 + + self.cpu.grow_guard_compatible_switch(faildescr1, t2_box._resref) + deadframe = self.cpu.execute_token(looptoken, + t2_box._resref) + fail = self.cpu.get_latest_descr(deadframe) + assert fail.identifier == 2 + def test_compile_with_holes_in_fail_args(self): targettoken = TargetToken() loop = parse(""" _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit