Author: Armin Rigo <ar...@tunes.org> Branch: guard-compatible Changeset: r84525:08aed0a2c183 Date: 2016-05-20 17:03 +0200 http://bitbucket.org/pypy/pypy/changeset/08aed0a2c183/
Log: First (passing) test for find_compatible() 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 @@ -190,12 +190,17 @@ res = self.cpu.get_int_value(deadframe, 0) assert res == 10 - def test_extend_guard_compatible(self): - import weakref, gc - + def test_extend_guard_compatible_1(self): + seen = [] + def find_compatible(cpu, arg): + assert cpu is self.cpu + seen.append(arg) + return -1 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) + faildescr1.find_compatible = find_compatible loop = parse(""" [p0] guard_compatible(p0, ConstPtr(t1), descr=faildescr1) [] @@ -209,24 +214,22 @@ 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(looptoken.compiled_loop_token, - faildescr1, t2_box._resref) - for retry in range(5): + assert seen == [] + + for i in range(3): + # find_compatible() returns -1: continue on the main trace deadframe = self.cpu.execute_token(looptoken, t2_box._resref) fail = self.cpu.get_latest_descr(deadframe) assert fail.identifier == 2 - - wr = weakref.ref(t2_box.getref_base()) - del t2_box, T2_box, d2 - gc.collect(); gc.collect() - assert wr() is not None # kept alive by grow_guard_compatible_switch + assert seen == [t2_box._resref] + + for t_box in [t3_box, t1_box, t2_box] * 2: + deadframe = self.cpu.execute_token(looptoken, + t_box._resref) + fail = self.cpu.get_latest_descr(deadframe) + assert fail.identifier == 2 + assert seen == [t2_box._resref, t3_box._resref] def test_compile_with_holes_in_fail_args(self): targettoken = TargetToken() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit