[pypy-commit] pypy result-in-resops: pass guard merges
fijal
noreply at buildbot.pypy.org
Tue Sep 25 17:03:15 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: result-in-resops
Changeset: r57579:4e11d3088518
Date: 2012-09-25 16:53 +0200
http://bitbucket.org/pypy/pypy/changeset/4e11d3088518/
Log: pass guard merges
diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py
--- a/pypy/jit/metainterp/optimizeopt/heap.py
+++ b/pypy/jit/metainterp/optimizeopt/heap.py
@@ -427,7 +427,7 @@
cf = self.arrayitem_cache(op.getdescr(), indexvalue.op.getint())
fieldvalue = cf.getfield_from_cache(self, arrayvalue)
if fieldvalue is not None:
- self.make_equal_to(op.result, fieldvalue)
+ self.replace(op, fieldvalue.op)
return
else:
# variable index, so make sure the lazy setarrayitems are done
diff --git a/pypy/jit/metainterp/optimizeopt/optimizer.py b/pypy/jit/metainterp/optimizeopt/optimizer.py
--- a/pypy/jit/metainterp/optimizeopt/optimizer.py
+++ b/pypy/jit/metainterp/optimizeopt/optimizer.py
@@ -183,16 +183,20 @@
else:
return None
- def make_constant_class(self, classbox, guardop):
+ def make_constant_class(self, classbox, guardop, index):
assert self.level < LEVEL_KNOWNCLASS
self.known_class = classbox
self.level = LEVEL_KNOWNCLASS
+ assert self.last_guard is None
self.last_guard = guardop
+ self.last_guard_pos = index
- def make_nonnull(self, guardop):
+ def make_nonnull(self, guardop, index):
assert self.level < LEVEL_NONNULL
self.level = LEVEL_NONNULL
+ assert self.last_guard is None
self.last_guard = guardop
+ self.last_guard_pos = index
def is_nonnull(self):
level = self.level
@@ -365,7 +369,6 @@
self.pendingfields = []
self.quasi_immutable_deps = None
self.opaque_pointers = {}
- self.replaces_guard = {}
self._newoperations = []
self.optimizer = self
self.optpure = None
@@ -579,27 +582,11 @@
self.metainterp_sd.profiler.count(jitprof.Counters.OPT_OPS)
if op.is_guard():
self.metainterp_sd.profiler.count(jitprof.Counters.OPT_GUARDS)
- if self.replaces_guard and op in self.replaces_guard:
- self.replace_op(self.replaces_guard[op], op)
- del self.replaces_guard[op]
- return
- else:
- op = self.store_final_boxes_in_guard(op)
+ op = self.store_final_boxes_in_guard(op)
elif op.can_raise():
self.exception_might_have_happened = True
self._newoperations.append(op)
- def replace_op(self, old_op, new_op):
- # XXX: Do we want to cache indexes to prevent search?
- i = len(self._newoperations)
- while i > 0:
- i -= 1
- if self._newoperations[i] is old_op:
- self._newoperations[i] = new_op
- break
- else:
- assert False
-
def store_final_boxes_in_guard(self, op):
if op.getdescr() is not None:
# means we need to copy the op and attach a new descr
@@ -641,6 +628,13 @@
def optimize_default(self, op):
self.emit_operation(op)
+ def get_pos(self):
+ return len(self._newoperations)
+
+ def replace_op(self, value, new_guard_op):
+ assert self._newoperations[value.last_guard_pos] is value.last_guard
+ self._newoperations[value.last_guard_pos] = new_guard_op
+
def constant_fold(self, op):
argboxes = [self.get_constant_box(op.getarg(i))
for i in range(op.numargs())]
diff --git a/pypy/jit/metainterp/optimizeopt/rewrite.py b/pypy/jit/metainterp/optimizeopt/rewrite.py
--- a/pypy/jit/metainterp/optimizeopt/rewrite.py
+++ b/pypy/jit/metainterp/optimizeopt/rewrite.py
@@ -4,7 +4,8 @@
from pypy.jit.metainterp.optimizeopt.optimizer import *
from pypy.jit.metainterp.optimizeopt.util import _findall, make_dispatcher_method
from pypy.jit.metainterp.resoperation import (opboolinvers, opboolreflex, rop,
- ConstInt, make_hashable_int)
+ ConstInt, make_hashable_int,
+ create_resop_2)
from pypy.rlib.rarithmetic import highest_bit
@@ -220,8 +221,9 @@
return
elif value.is_null():
raise InvalidLoop('A GUARD_NONNULL was proven to always fail')
+ pos = self.optimizer.get_pos()
self.emit_operation(op)
- value.make_nonnull(op)
+ value.make_nonnull(op, pos)
def optimize_GUARD_VALUE(self, op):
value = self.getvalue(op.getarg(0))
@@ -240,22 +242,28 @@
assert expected_classbox is not None
if not previous_classbox.same_constant(expected_classbox):
raise InvalidLoop('A GUARD_VALUE was proven to always fail')
- xxx
- op = old_guard_op.copy_and_change(rop.GUARD_VALUE,
- args = [old_guard_op.getarg(0), op.getarg(1)])
- self.optimizer.replaces_guard[op] = old_guard_op
- # hack hack hack. Change the guard_opnum on
- # new_guard_op.getdescr() so that when resuming,
- # the operation is not skipped by pyjitpl.py.
- descr = op.getdescr()
+ # replace the previous guard
+ new_guard_op = create_resop_2(rop.GUARD_VALUE, None,
+ old_guard_op.getarg(0),
+ op.getarg(1))
+ new_guard_op.set_extra("failargs",
+ old_guard_op.get_extra("failargs"))
+ descr = old_guard_op.getdescr()
+ # hack, we assume there is just one reference to this descr,
+ # so we can modify it
assert isinstance(descr, compile.ResumeGuardDescr)
descr.guard_opnum = rop.GUARD_VALUE
- descr.make_a_counter_per_value(op)
- # to be safe
+ descr.make_a_counter_per_value(new_guard_op)
+ new_guard_op.setdescr(descr)
+ op = new_guard_op
+ self.optimizer.replace_op(value, new_guard_op)
value.last_guard = None
+ emit_operation = False
+ else:
+ emit_operation = True
constbox = op.getarg(1)
assert isinstance(constbox, Const)
- self.optimize_guard(op, constbox)
+ self.optimize_guard(op, constbox, emit_operation=emit_operation)
def optimize_GUARD_TRUE(self, op):
self.optimize_guard(op, CONST_1)
@@ -271,7 +279,8 @@
if realclassbox is not None:
assert realclassbox.same_constant(expectedclassbox)
return
- value.make_constant_class(expectedclassbox, None)
+ value.make_constant_class(expectedclassbox, None,
+ self.optimizer.get_pos())
def optimize_GUARD_CLASS(self, op):
value = self.getvalue(op.getarg(0))
@@ -282,6 +291,7 @@
if realclassbox.same_constant(expectedclassbox):
return
raise InvalidLoop('A GUARD_CLASS was proven to always fail')
+ emit_operation = True
if value.last_guard:
# there already has been a guard_nonnull or guard_class or
# guard_nonnull_class on this value.
@@ -289,18 +299,24 @@
if old_guard_op.getopnum() == rop.GUARD_NONNULL:
# it was a guard_nonnull, which we replace with a
# guard_nonnull_class.
- xxx
- op = old_guard_op.copy_and_change (rop.GUARD_NONNULL_CLASS,
- args = [old_guard_op.getarg(0), op.getarg(1)])
- self.optimizer.replaces_guard[op] = old_guard_op
- # hack hack hack. Change the guard_opnum on
- # new_guard_op.getdescr() so that when resuming,
- # the operation is not skipped by pyjitpl.py.
- descr = op.getdescr()
+ new_op = create_resop_2(rop.GUARD_NONNULL_CLASS,
+ None, old_guard_op.getarg(0),
+ op.getarg(1))
+ descr = old_guard_op.getdescr()
assert isinstance(descr, compile.ResumeGuardDescr)
descr.guard_opnum = rop.GUARD_NONNULL_CLASS
- self.emit_operation(op)
- value.make_constant_class(expectedclassbox, op)
+ new_op.setdescr(descr)
+ new_op.set_extra("failargs", old_guard_op.get_extra("failargs"))
+ self.optimizer.replace_op(value, new_op)
+ op = new_op
+ emit_operation = False
+ value.last_guard = None
+ pos = value.last_guard_pos
+ else:
+ pos = self.optimizer.get_pos()
+ if emit_operation:
+ self.emit_operation(op)
+ value.make_constant_class(expectedclassbox, op, pos)
def optimize_GUARD_NONNULL_CLASS(self, op):
value = self.getvalue(op.getarg(0))
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -126,42 +126,6 @@
print '\n'.join([str(o) for o in loop.operations])
self.assert_equal(loop, expected)
- def setup_method(self, meth=None):
- class FailDescr(compile.ResumeGuardDescr):
- oparse = None
- def _oparser_uses_descr_of_guard(self, oparse, fail_args):
- # typically called 3 times: once when parsing 'ops',
- # once when parsing 'preamble', once when parsing 'expected'.
- self.oparse = oparse
- self.rd_frame_info_list, self.rd_snapshot = snapshot(fail_args)
- def _clone_if_mutable(self):
- assert self is fdescr
- return fdescr2
- def __repr__(self):
- if self is fdescr:
- return 'fdescr'
- if self is fdescr2:
- return 'fdescr2'
- return compile.ResumeGuardDescr.__repr__(self)
- #
- def snapshot(fail_args, got=[]):
- if not got: # only the first time, i.e. when parsing 'ops'
- rd_frame_info_list = resume.FrameInfo(None, "code", 11)
- rd_snapshot = resume.Snapshot(None, fail_args)
- got.append(rd_frame_info_list)
- got.append(rd_snapshot)
- return got
- #
- fdescr = instantiate(FailDescr)
- self.namespace['fdescr'] = fdescr
- fdescr2 = instantiate(FailDescr)
- self.namespace['fdescr2'] = fdescr2
-
- def teardown_method(self, meth):
- self.namespace.pop('fdescr', None)
- self.namespace.pop('fdescr2', None)
-
-
class BaseTestOptimizeBasic(BaseTestBasic):
@@ -1746,7 +1710,7 @@
ops = """
[p1, p2]
setarrayitem_gc(p1, 0, p2, descr=arraydescr2)
- p3 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+ p3 = getarrayitem_gc_p(p1, 0, descr=arraydescr2)
escape(p3)
jump(p1, p3)
"""
@@ -1764,8 +1728,8 @@
[p1, p2, p3, i1]
setarrayitem_gc(p1, 0, p2, descr=arraydescr2)
setarrayitem_gc(p1, i1, p3, descr=arraydescr2)
- p4 = getarrayitem_gc(p1, 0, descr=arraydescr2)
- p5 = getarrayitem_gc(p1, i1, descr=arraydescr2)
+ p4 = getarrayitem_gc_p(p1, 0, descr=arraydescr2)
+ p5 = getarrayitem_gc_p(p1, i1, descr=arraydescr2)
escape(p4)
escape(p5)
jump(p1, p2, p3, i1)
@@ -1774,7 +1738,7 @@
[p1, p2, p3, i1]
setarrayitem_gc(p1, 0, p2, descr=arraydescr2)
setarrayitem_gc(p1, i1, p3, descr=arraydescr2)
- p4 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+ p4 = getarrayitem_gc_p(p1, 0, descr=arraydescr2)
escape(p4)
escape(p3)
jump(p1, p2, p3, i1)
@@ -1787,9 +1751,9 @@
setarrayitem_gc(p1, i1, p2, descr=arraydescr2)
setarrayitem_gc(p1, 0, p3, descr=arraydescr2)
setarrayitem_gc(p1, 1, p4, descr=arraydescr2)
- p5 = getarrayitem_gc(p1, i1, descr=arraydescr2)
- p6 = getarrayitem_gc(p1, 0, descr=arraydescr2)
- p7 = getarrayitem_gc(p1, 1, descr=arraydescr2)
+ p5 = getarrayitem_gc_p(p1, i1, descr=arraydescr2)
+ p6 = getarrayitem_gc_p(p1, 0, descr=arraydescr2)
+ p7 = getarrayitem_gc_p(p1, 1, descr=arraydescr2)
escape(p5)
escape(p6)
escape(p7)
@@ -1800,7 +1764,7 @@
setarrayitem_gc(p1, i1, p2, descr=arraydescr2)
setarrayitem_gc(p1, 0, p3, descr=arraydescr2)
setarrayitem_gc(p1, 1, p4, descr=arraydescr2)
- p5 = getarrayitem_gc(p1, i1, descr=arraydescr2)
+ p5 = getarrayitem_gc_p(p1, i1, descr=arraydescr2)
escape(p5)
escape(p3)
escape(p4)
@@ -1810,22 +1774,24 @@
def test_getarrayitem_pure_does_not_invalidate(self):
ops = """
- [p1, p2]
- p3 = getarrayitem_gc(p1, 0, descr=arraydescr2)
- i4 = getfield_gc_pure(ConstPtr(myptr), descr=valuedescr)
- p5 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+ [p0, p1, p2]
+ guard_value(p0, ConstPtr(myptr)) []
+ p3 = getarrayitem_gc_p(p1, 0, descr=arraydescr2)
+ i4 = getfield_gc_pure_i(p0, descr=valuedescr)
+ p5 = getarrayitem_gc_p(p1, 0, descr=arraydescr2)
escape(p3)
escape(i4)
escape(p5)
- jump(p1, p2)
- """
- expected = """
- [p1, p2]
- p3 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+ jump(p0, p1, p2)
+ """
+ expected = """
+ [p0, p1, p2]
+ guard_value(p0, ConstPtr(myptr)) []
+ p3 = getarrayitem_gc_p(p1, 0, descr=arraydescr2)
escape(p3)
escape(5)
escape(p3)
- jump(p1, p2)
+ jump(ConstPtr(myptr), p1, p2)
"""
self.optimize_loop(ops, expected)
@@ -1834,8 +1800,8 @@
[p1, p2, p3, p4, i1]
setarrayitem_gc(p1, 0, p3, descr=arraydescr2)
setarrayitem_gc(p2, 1, p4, descr=arraydescr2)
- p5 = getarrayitem_gc(p1, 0, descr=arraydescr2)
- p6 = getarrayitem_gc(p2, 1, descr=arraydescr2)
+ p5 = getarrayitem_gc_p(p1, 0, descr=arraydescr2)
+ p6 = getarrayitem_gc_p(p2, 1, descr=arraydescr2)
escape(p5)
escape(p6)
jump(p1, p2, p3, p4, i1)
@@ -1856,7 +1822,7 @@
setarrayitem_gc(p0, 0, i0, descr=arraydescr)
i6 = int_add(i0, 1)
setarrayitem_gc(p0, i1, i6, descr=arraydescr)
- i10 = getarrayitem_gc(p0, 0, descr=arraydescr)
+ i10 = getarrayitem_gc_i(p0, 0, descr=arraydescr)
i11 = int_add(i10, i0)
jump(p0, i11, i1)
"""
@@ -1865,7 +1831,7 @@
i6 = int_add(i0, 1)
setarrayitem_gc(p0, 0, i0, descr=arraydescr)
setarrayitem_gc(p0, i1, i6, descr=arraydescr)
- i10 = getarrayitem_gc(p0, 0, descr=arraydescr)
+ i10 = getarrayitem_gc_i(p0, 0, descr=arraydescr)
i11 = int_add(i10, i0)
jump(p0, i11, i1)
"""
@@ -1874,19 +1840,19 @@
def test_duplicate_getarrayitem_after_setarrayitem_bug2(self):
ops = """
[p0, i0, i1]
- i2 = getarrayitem_gc(p0, 0, descr=arraydescr)
+ i2 = getarrayitem_gc_i(p0, 0, descr=arraydescr)
i6 = int_add(i0, 1)
setarrayitem_gc(p0, i1, i6, descr=arraydescr)
- i10 = getarrayitem_gc(p0, 0, descr=arraydescr)
+ i10 = getarrayitem_gc_i(p0, 0, descr=arraydescr)
i11 = int_add(i10, i2)
jump(p0, i11, i1)
"""
expected = """
[p0, i0, i1]
- i2 = getarrayitem_gc(p0, 0, descr=arraydescr)
+ i2 = getarrayitem_gc_i(p0, 0, descr=arraydescr)
i6 = int_add(i0, 1)
setarrayitem_gc(p0, i1, i6, descr=arraydescr)
- i10 = getarrayitem_gc(p0, 0, descr=arraydescr)
+ i10 = getarrayitem_gc_i(p0, 0, descr=arraydescr)
i11 = int_add(i10, i2)
jump(p0, i11, i1)
"""
@@ -1919,7 +1885,7 @@
def test_bug_2(self):
ops = """
[i0, p1]
- p4 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+ p4 = getarrayitem_gc_p(p1, 0, descr=arraydescr2)
guard_nonnull(p4) []
escape(p4)
#
@@ -2066,14 +2032,14 @@
def test_merge_guard_nonnull_guard_class(self):
ops = """
[p1, i0, i1, i2, p2]
- guard_nonnull(p1, descr=fdescr) [i0]
+ guard_nonnull(p1) [i0]
i3 = int_add(i1, i2)
guard_class(p1, ConstClass(node_vtable)) [i1]
jump(p2, i0, i1, i3, p2)
"""
expected = """
[p1, i0, i1, i2, p2]
- guard_nonnull_class(p1, ConstClass(node_vtable), descr=fdescr) [i0]
+ guard_nonnull_class(p1, ConstClass(node_vtable)) [i0]
i3 = int_add(i1, i2)
jump(p2, i0, i1, i3, p2)
"""
@@ -2083,14 +2049,14 @@
def test_merge_guard_nonnull_guard_value(self):
ops = """
[p1, i0, i1, i2, p2]
- guard_nonnull(p1, descr=fdescr) [i0]
+ guard_nonnull(p1) [i0]
i3 = int_add(i1, i2)
guard_value(p1, ConstPtr(myptr)) [i1]
jump(p2, i0, i1, i3, p2)
"""
expected = """
[p1, i0, i1, i2, p2]
- guard_value(p1, ConstPtr(myptr), descr=fdescr) [i0]
+ guard_value(p1, ConstPtr(myptr)) [i0]
i3 = int_add(i1, i2)
jump(p2, i0, i1, i3, p2)
"""
@@ -2100,7 +2066,7 @@
def test_merge_guard_nonnull_guard_class_guard_value(self):
ops = """
[p1, i0, i1, i2, p2]
- guard_nonnull(p1, descr=fdescr) [i0]
+ guard_nonnull(p1) [i0]
i3 = int_add(i1, i2)
guard_class(p1, ConstClass(node_vtable)) [i2]
i4 = int_sub(i3, 1)
@@ -2109,7 +2075,7 @@
"""
expected = """
[p1, i0, i1, i2, p2]
- guard_value(p1, ConstPtr(myptr), descr=fdescr) [i0]
+ guard_value(p1, ConstPtr(myptr)) [i0]
i3 = int_add(i1, i2)
i4 = int_sub(i3, 1)
jump(p2, i0, i1, i4, p2)
@@ -2435,7 +2401,7 @@
def _variables_equal(box, varname, strict):
if varname not in virtuals:
if strict:
- assert box.same_box(oparse.getvar(varname))
+ assert box.eq(oparse.getvar(varname))
else:
assert box.value == oparse.getvar(varname).value
else:
@@ -2500,13 +2466,13 @@
from pypy.jit.metainterp.test.test_resume import ResumeDataFakeReader
from pypy.jit.metainterp.test.test_resume import MyMetaInterp
guard_op, = [op for op in self.loop.operations if op.is_guard()]
- fail_args = guard_op.getfailargs()
+ fail_args = guard_op.get_extra("failargs")
fdescr = guard_op.getdescr()
assert fdescr.guard_opnum == guard_opnum
reader = ResumeDataFakeReader(fdescr, fail_args,
MyMetaInterp(self.cpu))
boxes = reader.consume_boxes()
- self._verify_fail_args(boxes, fdescr.oparse, expectedtext)
+ self._verify_fail_args(boxes, self.oparsers[1], expectedtext)
def test_expand_fail_1(self):
ops = """
@@ -2517,12 +2483,12 @@
i4 = getfield_gc(p1, descr=valuedescr)
#
i2 = int_add(10, 5)
- guard_true(i1, descr=fdescr) [i2, i4]
+ guard_true(i1) [i2, i4]
jump(i1, i4)
"""
expected = """
[i1, i3]
- guard_true(i1, descr=fdescr) [i3]
+ guard_true(i1) [i3]
jump(1, i3)
"""
self.optimize_loop(ops, expected)
@@ -2534,12 +2500,12 @@
p1 = new_with_vtable(ConstClass(node_vtable))
setfield_gc(p1, i2, descr=valuedescr)
setfield_gc(p1, p1, descr=nextdescr)
- guard_true(i1, descr=fdescr) [p1]
+ guard_true(i1) [p1]
jump(i1, i2)
"""
expected = """
[i1, i2]
- guard_true(i1, descr=fdescr) [i2]
+ guard_true(i1) [i2]
jump(1, i2)
"""
self.optimize_loop(ops, expected)
@@ -2556,12 +2522,12 @@
setfield_gc(p1, p2, descr=nextdescr)
setfield_gc(p2, i2, descr=valuedescr)
setfield_gc(p2, p3, descr=nextdescr)
- guard_true(i1, descr=fdescr) [i3, p1]
+ guard_true(i1) [i3, p1]
jump(i2, i1, i3, p3)
"""
expected = """
[i1, i2, i3, p3]
- guard_true(i1, descr=fdescr) [i3, i2, p3]
+ guard_true(i1) [i3, i2, p3]
jump(i2, 1, i3, p3)
"""
self.optimize_loop(ops, expected)
@@ -2583,12 +2549,12 @@
setfield_gc(p1, i2, descr=valuedescr)
setfield_gc(p1, p2, descr=nextdescr)
setfield_gc(p2, i2, descr=valuedescr)
- guard_true(i1, descr=fdescr) [i4, i3, %s]
+ guard_true(i1) [i4, i3, %s]
jump(i1, i2, i3)
"""
expected = """
[i1, i2, i3]
- guard_true(i1, descr=fdescr) [i3, i2]
+ guard_true(i1) [i3, i2]
jump(1, i2, i3)
"""
self.optimize_loop(ops % arg, expected)
@@ -2606,12 +2572,12 @@
setfield_gc(p1, p2, descr=nextdescr)
setfield_gc(p2, i2, descr=valuedescr)
setfield_gc(p2, p1, descr=nextdescr) # a cycle
- guard_true(i1, descr=fdescr) [i3, i4, p1, p2]
+ guard_true(i1) [i3, i4, p1, p2]
jump(i2, i1, i3, i4)
"""
expected = """
[i1, i2, i3, i4]
- guard_true(i1, descr=fdescr) [i3, i4, i2]
+ guard_true(i1) [i3, i4, i2]
jump(i2, 1, i3, i4)
"""
self.optimize_loop(ops, expected)
@@ -2623,14 +2589,14 @@
def test_expand_fail_6(self):
ops = """
[p0, i0, i1]
- guard_true(i0, descr=fdescr) [p0]
+ guard_true(i0) [p0]
p1 = new_with_vtable(ConstClass(node_vtable))
setfield_gc(p1, i1, descr=valuedescr)
jump(p1, i1, i1)
"""
expected = """
[i1b, i0, i1]
- guard_true(i0, descr=fdescr) [i1b]
+ guard_true(i0) [i1b]
jump(i1, i1, i1)
"""
py.test.skip("XXX")
@@ -2646,13 +2612,13 @@
p1 = new_array(3, descr=arraydescr)
setarrayitem_gc(p1, 1, i1, descr=arraydescr)
setarrayitem_gc(p1, 0, 25, descr=arraydescr)
- guard_true(i1, descr=fdescr) [p1]
+ guard_true(i1) [p1]
i2 = getarrayitem_gc(p1, 1, descr=arraydescr)
jump(i2)
"""
expected = """
[i1]
- guard_true(i1, descr=fdescr) [i1]
+ guard_true(i1) [i1]
jump(1)
"""
self.optimize_loop(ops, expected)
@@ -2666,14 +2632,14 @@
p2 = new(descr=ssize)
setfield_gc(p2, i1, descr=adescr)
setfield_gc(p2, p1, descr=bdescr)
- guard_true(i1, descr=fdescr) [p2]
+ guard_true(i1) [p2]
i3 = getfield_gc(p2, descr=adescr)
p3 = getfield_gc(p2, descr=bdescr)
jump(i3, p3)
"""
expected = """
[i1, p1]
- guard_true(i1, descr=fdescr) [i1, p1]
+ guard_true(i1) [i1, p1]
jump(1, p1)
"""
self.optimize_loop(ops, expected)
@@ -2690,7 +2656,7 @@
setfield_gc(p5s, i2, descr=adescr)
setfield_gc(p5s, p7v, descr=bdescr)
setarrayitem_gc(p1a, 1, p5s, descr=arraydescr2)
- guard_true(i1, descr=fdescr) [p1a]
+ guard_true(i1) [p1a]
p2s = new(descr=ssize)
p3v = new_with_vtable(ConstClass(node_vtable))
p4a = new_array(2, descr=arraydescr2)
@@ -2702,7 +2668,7 @@
"""
expected = """
[i1, ia, iv, pnull, i2]
- guard_true(i1, descr=fdescr) [ia, iv, i2]
+ guard_true(i1) [ia, iv, i2]
jump(1, 1, i2, NULL, i2)
"""
py.test.skip("XXX")
@@ -2728,14 +2694,14 @@
p2 = new_with_vtable(ConstClass(node_vtable))
setfield_gc(p2, i2, descr=valuedescr)
setfield_gc(p1, p2, descr=nextdescr)
- guard_true(i3, descr=fdescr) []
+ guard_true(i3) []
i4 = int_neg(i2)
setfield_gc(p1, NULL, descr=nextdescr)
jump(p1, i2, i4)
"""
expected = """
[p1, i2, i3]
- guard_true(i3, descr=fdescr) [p1, i2]
+ guard_true(i3) [p1, i2]
i4 = int_neg(i2)
setfield_gc(p1, NULL, descr=nextdescr)
jump(p1, i2, i4)
@@ -2753,14 +2719,14 @@
p2 = new_with_vtable(ConstClass(node_vtable))
setfield_gc(p2, i2, descr=valuedescr)
setfield_gc(ConstPtr(myptr), p2, descr=nextdescr)
- guard_true(i3, descr=fdescr) []
+ guard_true(i3) []
i4 = int_neg(i2)
setfield_gc(ConstPtr(myptr), NULL, descr=nextdescr)
jump(i2, i4)
"""
expected = """
[i2, i3]
- guard_true(i3, descr=fdescr) [i2]
+ guard_true(i3) [i2]
i4 = int_neg(i2)
setfield_gc(ConstPtr(myptr), NULL, descr=nextdescr)
jump(i2, i4)
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_util.py b/pypy/jit/metainterp/optimizeopt/test/test_util.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_util.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_util.py
@@ -403,10 +403,17 @@
boxkinds=boxkinds,
results=results, process_guard=self.process_guard)
- def process_guard(self, guard_op):
+ def setup_method(self, meth):
+ self.oparsers = []
+
+ def teardown_method(self, meth):
+ del self.oparsers
+
+ def process_guard(self, guard_op, oparser):
fail_args = guard_op.get_extra("failargs")
guard_op.set_rd_frame_info_list(resume.FrameInfo(None, "code", 11))
guard_op.set_rd_snapshot(resume.Snapshot(None, _sortboxes(fail_args)))
+ self.oparsers.append(oparser)
def assert_equal(self, optimized, expected, text_right=None):
from pypy.jit.metainterp.optimizeopt.util import equaloplists
diff --git a/pypy/jit/metainterp/resume.py b/pypy/jit/metainterp/resume.py
--- a/pypy/jit/metainterp/resume.py
+++ b/pypy/jit/metainterp/resume.py
@@ -1,5 +1,5 @@
from pypy.jit.metainterp.resoperation import Const, ConstInt, getkind
-from pypy.jit.metainterp.resoperation import BoxInt, BoxPtr, BoxFloat, Box
+from pypy.jit.metainterp.resoperation import BoxInt, BoxPtr, BoxFloat
from pypy.jit.metainterp.resoperation import INT, REF, FLOAT
from pypy.jit.metainterp.history import AbstractDescr
from pypy.jit.metainterp.resoperation import rop
diff --git a/pypy/jit/metainterp/test/test_resume.py b/pypy/jit/metainterp/test/test_resume.py
--- a/pypy/jit/metainterp/test/test_resume.py
+++ b/pypy/jit/metainterp/test/test_resume.py
@@ -5,8 +5,8 @@
from pypy.jit.metainterp.optimizeopt.virtualize import VirtualValue, VArrayValue
from pypy.jit.metainterp.optimizeopt.virtualize import VStructValue
from pypy.jit.metainterp.resume import *
-from pypy.jit.metainterp.history import BoxInt, BoxPtr, ConstInt
-from pypy.jit.metainterp.history import ConstPtr, ConstFloat
+from pypy.jit.metainterp.resoperation import BoxInt, BoxPtr, ConstInt
+from pypy.jit.metainterp.resoperation import ConstPtr, ConstFloat
from pypy.jit.metainterp.optimizeopt.test.test_util import LLtypeMixin
from pypy.jit.metainterp import executor
from pypy.jit.codewriter import heaptracker, longlong
diff --git a/pypy/jit/tool/oparser.py b/pypy/jit/tool/oparser.py
--- a/pypy/jit/tool/oparser.py
+++ b/pypy/jit/tool/oparser.py
@@ -270,8 +270,6 @@
raise ParseError(
"Unknown var in fail_args: %s" % arg)
fail_args.append(fail_arg)
- if hasattr(descr, '_oparser_uses_descr_of_guard'):
- descr._oparser_uses_descr_of_guard(self, fail_args)
else:
fail_args = None
if opnum == rop.JUMP:
@@ -307,7 +305,7 @@
if fail_args is not None:
opres.set_extra("failargs", fail_args)
if self.process_guard and opres.is_guard():
- self.process_guard(opres)
+ self.process_guard(opres, self)
return opres
def parse_op_no_result(self, line):
@@ -316,7 +314,7 @@
if fail_args is not None:
res.set_extra("failargs", fail_args)
if self.process_guard and res.is_guard():
- self.process_guard(res)
+ self.process_guard(res, self)
return res
def parse_next_op(self, line, num):
diff --git a/pypy/jit/tool/test/test_oparser.py b/pypy/jit/tool/test/test_oparser.py
--- a/pypy/jit/tool/test/test_oparser.py
+++ b/pypy/jit/tool/test/test_oparser.py
@@ -187,7 +187,7 @@
assert not loop.operations[0].has_extra("failargs")
def test_fail_args_invent_snapshot(self):
- def f(op):
+ def f(op, oparser):
op.set_rd_snapshot(['foo'])
x = '''
More information about the pypy-commit
mailing list