Author: Hakan Ardo <ha...@debian.org> Branch: jit-short_from_state Changeset: r46398:53e4e61a8535 Date: 2011-08-09 17:15 +0200 http://bitbucket.org/pypy/pypy/changeset/53e4e61a8535/
Log: dont override the short_box with an aliased box if it is already present diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py @@ -6924,9 +6924,26 @@ setfield_gc(p5, 1, descr=valuedescr) jump(p5, 1) """ - self.optimize_loop(ops, expected, preamble) - + + def test_dont_mixup_equal_boxes(self): + ops = """ + [p8] + i9 = getfield_gc_pure(p8, descr=valuedescr) + i10 = int_gt(i9, 0) + guard_true(i10) [] + i29 = int_lshift(i9, 1) + i30 = int_rshift(i29, 1) + i40 = int_ne(i30, i9) + guard_false(i40) [] + jump(p8) + """ + expected = """ + [p8] + jump(p8) + """ + self.optimize_loop(ops, expected) + class TestLLtype(OptimizeOptTest, LLtypeMixin): pass diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py --- a/pypy/jit/metainterp/optimizeopt/unroll.py +++ b/pypy/jit/metainterp/optimizeopt/unroll.py @@ -242,13 +242,14 @@ for op in self.short_boxes.operations(): self.ensure_short_op_emitted(op, self.optimizer, seen) if op and op.result: + # The order of these guards is not important as + # self.optimizer.emitting_dissabled is False value = preamble_optimizer.getvalue(op.result) for guard in value.make_guards(op.result): self.optimizer.send_extra_operation(guard) newresult = self.optimizer.getvalue(op.result).get_key_box() if newresult is not op.result: self.short_boxes.alias(newresult, op.result) - self.optimizer.flush() self.optimizer.emitting_dissabled = False diff --git a/pypy/jit/metainterp/optimizeopt/virtualstate.py b/pypy/jit/metainterp/optimizeopt/virtualstate.py --- a/pypy/jit/metainterp/optimizeopt/virtualstate.py +++ b/pypy/jit/metainterp/optimizeopt/virtualstate.py @@ -11,6 +11,7 @@ from pypy.jit.metainterp.resoperation import rop, ResOperation from pypy.rlib.objectmodel import we_are_translated from pypy.rlib.debug import debug_start, debug_stop, debug_print +from pypy.rlib.objectmodel import we_are_translated class AbstractVirtualStateInfo(resume.AbstractVirtualInfo): position = -1 @@ -509,6 +510,10 @@ debug_stop('jit-short-boxes') def operations(self): + if not we_are_translated(): # For tests + ops = self.short_boxes.values() + ops.sort(key=str, reverse=True) + return ops return self.short_boxes.values() def producer(self, box): @@ -518,7 +523,7 @@ return box in self.short_boxes def alias(self, newbox, oldbox): - if not isinstance(oldbox, Const): + if not isinstance(oldbox, Const) and newbox not in self.short_boxes: self.short_boxes[newbox] = self.short_boxes[oldbox] self.aliases[newbox] = oldbox diff --git a/pypy/jit/tl/pypyjit.py b/pypy/jit/tl/pypyjit.py --- a/pypy/jit/tl/pypyjit.py +++ b/pypy/jit/tl/pypyjit.py @@ -37,13 +37,13 @@ set_opt_level(config, level='jit') config.objspace.allworkingmodules = False config.objspace.usemodules.pypyjit = True -config.objspace.usemodules.array = True +config.objspace.usemodules.array = False config.objspace.usemodules._weakref = True config.objspace.usemodules._sre = False config.objspace.usemodules._lsprof = True # config.objspace.usemodules._ffi = True -config.objspace.usemodules.micronumpy = True +config.objspace.usemodules.micronumpy = False # set_pypy_opt_level(config, level='jit') diff --git a/pypy/jit/tl/pypyjit_demo.py b/pypy/jit/tl/pypyjit_demo.py --- a/pypy/jit/tl/pypyjit_demo.py +++ b/pypy/jit/tl/pypyjit_demo.py @@ -1,47 +1,23 @@ -def fannkuch(n): - count = range(1, n+1) - max_flips = 0 - m = n-1 - r = n - check = 0 - perm1 = range(n) - perm = range(n) - perm1_ins = perm1.insert - perm1_pop = perm1.pop +import pypyjit +pypyjit.set_param(threshold=200) - while 1: - if check < 30: - #print "".join(str(i+1) for i in perm1) - check += 1 - while r != 1: - count[r-1] = r - r -= 1 - - if perm1[0] != 0 and perm1[m] != m: - perm = perm1[:] - flips_count = 0 - k = perm[0] - while k: - perm[:k+1] = perm[k::-1] - flips_count += 1 - k = perm[0] - - if flips_count > max_flips: - max_flips = flips_count - - while r != n: - perm1_ins(r, perm1_pop(0)) - count[r] -= 1 - if count[r] > 0: - break - r += 1 - else: - return max_flips - +def main(a, b): + i = sa = 0 + while i < 300: + if a > 0: # Specialises the loop + pass + if b < 2 and b > 0: + pass + if (a >> b) >= 0: + sa += 1 + if (a << b) > 2: + sa += 10000 + i += 1 + return sa try: - fannkuch(9) + print main(2, 1) except Exception, e: print "Exception: ", type(e) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit