Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r67031:0da86701160d Date: 2013-09-18 08:25 +0200 http://bitbucket.org/pypy/pypy/changeset/0da86701160d/
Log: Write some tests directly for guard_not_forced_2. 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 @@ -2441,6 +2441,32 @@ assert values == [1, 10] assert self.cpu.get_savedata_ref(deadframe) == random_gcref + def test_guard_not_forced_2(self): + cpu = self.cpu + i0 = BoxInt() + i1 = BoxInt() + tok = BoxPtr() + faildescr = BasicFailDescr(1) + ops = [ + ResOperation(rop.INT_ADD, [i0, ConstInt(10)], i1), + ResOperation(rop.FORCE_TOKEN, [], tok), + ResOperation(rop.GUARD_NOT_FORCED_2, [], None, descr=faildescr), + ResOperation(rop.FINISH, [tok], None, descr=BasicFinalDescr(0)) + ] + ops[-2].setfailargs([i1]) + looptoken = JitCellToken() + self.cpu.compile_loop([i0], ops, looptoken) + deadframe = self.cpu.execute_token(looptoken, 20) + fail = self.cpu.get_latest_descr(deadframe) + assert fail.identifier == 0 + frame = self.cpu.get_ref_value(deadframe, 0) + # actually, we should get the same pointer in 'frame' and 'deadframe' + # but it is not the case on LLGraph + if not getattr(self.cpu, 'is_llgraph', False): + assert frame == deadframe + deadframe2 = self.cpu.force(frame) + assert self.cpu.get_int_value(deadframe2, 0) == 30 + def test_call_to_c_function(self): from rpython.rlib.libffi import CDLL, types, ArgChain, FUNCFLAG_CDECL from rpython.rtyper.lltypesystem.ll2ctypes import libc_name diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py --- a/rpython/jit/metainterp/history.py +++ b/rpython/jit/metainterp/history.py @@ -651,10 +651,10 @@ _list_all_operations(result, self.operations, omit_finish) return result - def summary(self, adding_insns={}): # for debugging + def summary(self, adding_insns={}, omit_finish=True): # for debugging "NOT_RPYTHON" insns = adding_insns.copy() - for op in self._all_operations(omit_finish=True): + for op in self._all_operations(omit_finish=omit_finish): opname = op.getopname() insns[opname] = insns.get(opname, 0) + 1 return insns @@ -895,10 +895,10 @@ "found %d %r, expected %d" % (found, insn, expected_count)) return insns - def check_resops(self, expected=None, **check): + def check_resops(self, expected=None, omit_finish=True, **check): insns = {} for loop in self.get_all_loops(): - insns = loop.summary(adding_insns=insns) + insns = loop.summary(adding_insns=insns, omit_finish=omit_finish) return self._check_insns(insns, expected, check) def _check_insns(self, insns, expected, check): diff --git a/rpython/jit/metainterp/test/test_virtualizable.py b/rpython/jit/metainterp/test/test_virtualizable.py --- a/rpython/jit/metainterp/test/test_virtualizable.py +++ b/rpython/jit/metainterp/test/test_virtualizable.py @@ -153,6 +153,33 @@ assert res == 10180 self.check_resops(setfield_gc=0, getfield_gc=2) + def test_synchronize_in_return_2(self): + myjitdriver = JitDriver(greens = [], reds = ['n', 'xy'], + virtualizables = ['xy']) + class Foo(object): + pass + def g(xy, n): + myjitdriver.jit_merge_point(xy=xy, n=n) + promote_virtualizable(xy, 'inst_x') + xy.inst_x += 1 + return Foo() + def f(n): + xy = self.setup() + promote_virtualizable(xy, 'inst_x') + xy.inst_x = 10000 + m = 10 + foo = None + while m > 0: + foo = g(xy, n) + m -= 1 + assert foo is not None + promote_virtualizable(xy, 'inst_x') + return xy.inst_x + res = self.meta_interp(f, [18]) + assert res == 10010 + self.check_resops(omit_finish=False, + guard_not_forced_2=1, finish=1) + def test_virtualizable_and_greens(self): myjitdriver = JitDriver(greens = ['m'], reds = ['n', 'xy'], virtualizables = ['xy']) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit