[pypy-commit] pypy default: test and fix: in the on_abort hook, the descrs of guards are still None as it runs before optimization
cfbolz
pypy.commits at gmail.com
Fri Mar 30 02:29:32 EDT 2018
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch:
Changeset: r94178:fe40f4eff666
Date: 2018-03-30 08:28 +0200
http://bitbucket.org/pypy/pypy/changeset/fe40f4eff666/
Log: test and fix: in the on_abort hook, the descrs of guards are still
None as it runs before optimization
diff --git a/pypy/module/pypyjit/interp_resop.py b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -113,22 +113,27 @@
ofs = ops_offset.get(op, 0)
num = op.getopnum()
name = op.getopname()
+ repr = logops.repr_of_resop(op)
if num == rop.DEBUG_MERGE_POINT:
jd_sd = jitdrivers_sd[op.getarg(0).getint()]
greenkey = op.getarglist()[3:]
repr = jd_sd.warmstate.get_location_str(greenkey)
w_greenkey = wrap_greenkey(space, jd_sd.jitdriver, greenkey, repr)
l_w.append(DebugMergePoint(space, name,
- logops.repr_of_resop(op),
+ repr,
jd_sd.jitdriver.name,
op.getarg(1).getint(),
op.getarg(2).getint(),
w_greenkey))
elif op.is_guard():
- l_w.append(GuardOp(name, ofs, logops.repr_of_resop(op),
- op.getdescr().get_jitcounter_hash()))
+ descr = op.getdescr()
+ if descr is not None: # can be none in on_abort!
+ hash = op.getdescr().get_jitcounter_hash()
+ else:
+ hash = -1
+ l_w.append(GuardOp(name, ofs, repr, hash))
else:
- l_w.append(WrappedOp(name, ofs, logops.repr_of_resop(op)))
+ l_w.append(WrappedOp(name, ofs, repr))
return l_w
@unwrap_spec(offset=int, repr='text', name='text')
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -65,6 +65,17 @@
if i != 1:
offset[op] = i
+ oplist_no_descrs = parse("""
+ [i1, i2, p2]
+ i3 = int_add(i1, i2)
+ debug_merge_point(0, 0, 0, 0, 0, ConstPtr(ptr0))
+ guard_nonnull(p2) []
+ guard_true(i3) []
+ """, namespace={'ptr0': code_gcref}).operations
+ for op in oplist_no_descrs:
+ if op.is_guard():
+ op.setdescr(None)
+
class FailDescr(BasicFailDescr):
def get_jitcounter_hash(self):
from rpython.rlib.rarithmetic import r_uint
@@ -101,7 +112,8 @@
def interp_on_abort():
if pypy_hooks.are_hooks_enabled():
pypy_hooks.on_abort(Counters.ABORT_TOO_LONG, pypyjitdriver,
- greenkey, 'blah', Logger(MockSD), [])
+ greenkey, 'blah', Logger(MockSD),
+ cls.oplist_no_descrs)
space = cls.space
cls.w_on_compile = space.wrap(interp2app(interp_on_compile))
@@ -111,10 +123,12 @@
cls.w_dmp_num = space.wrap(rop.DEBUG_MERGE_POINT)
cls.w_on_optimize = space.wrap(interp2app(interp_on_optimize))
cls.orig_oplist = oplist
+ cls.orig_oplist_no_descrs = oplist_no_descrs
cls.w_sorted_keys = space.wrap(sorted(Counters.counter_names))
def setup_method(self, meth):
self.__class__.oplist = self.orig_oplist[:]
+ self.__class__.oplist_no_descrs = self.orig_oplist_no_descrs[:]
def test_on_compile(self):
import pypyjit
@@ -223,7 +237,11 @@
pypyjit.set_abort_hook(hook)
self.on_abort()
- assert l == [('pypyjit', 'ABORT_TOO_LONG', [])]
+ assert len(l) == 1
+ name, reason, ops = l[0]
+ assert name == 'pypyjit'
+ assert reason == 'ABORT_TOO_LONG'
+ assert len(ops) == 4
def test_creation(self):
from pypyjit import ResOperation
More information about the pypy-commit
mailing list