[pypy-commit] pypy s390x-backend: catchup with default
plan_rich
pypy.commits at gmail.com
Tue Feb 16 03:51:51 EST 2016
Author: Richard Plangger <planrichi at gmail.com>
Branch: s390x-backend
Changeset: r82276:c9f5118bcf08
Date: 2016-02-16 09:51 +0100
http://bitbucket.org/pypy/pypy/changeset/c9f5118bcf08/
Log: catchup with default
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -551,20 +551,6 @@
emulated = callback
return self.pbc_call(pbc, args, emulated=emulated)
- def _find_current_op(self, opname=None, arity=None, pos=None, s_type=None):
- """ Find operation that is currently being annotated. Do some
- sanity checks to see whether the correct op was found."""
- # XXX XXX HACK HACK HACK
- fn, block, i = self.position_key
- op = block.operations[i]
- if opname is not None:
- assert op.opname == opname
- if arity is not None:
- assert len(op.args) == arity
- if pos is not None:
- assert self.annotator.binding(op.args[pos]) == s_type
- return op
-
def whereami(self):
return self.annotator.whereami(self.position_key)
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -380,7 +380,7 @@
raise InvalidLoop("promote of a virtual")
old_guard_op = info.get_last_guard(self.optimizer)
if old_guard_op is not None:
- op = self.replace_guard_class_with_guard_value(op, info,
+ op = self.replace_old_guard_with_guard_value(op, info,
old_guard_op)
elif arg0.type == 'f':
arg0 = self.get_box_replacement(arg0)
@@ -390,11 +390,26 @@
assert isinstance(constbox, Const)
self.optimize_guard(op, constbox)
- def replace_guard_class_with_guard_value(self, op, info, old_guard_op):
- if old_guard_op.opnum != rop.GUARD_NONNULL:
- previous_classbox = info.get_known_class(self.optimizer.cpu)
- expected_classbox = self.optimizer.cpu.ts.cls_of_box(op.getarg(1))
- assert previous_classbox is not None
+ def replace_old_guard_with_guard_value(self, op, info, old_guard_op):
+ # there already has been a guard_nonnull or guard_class or
+ # guard_nonnull_class on this value, which is rather silly.
+ # This function replaces the original guard with a
+ # guard_value. Must be careful: doing so is unsafe if the
+ # original guard checks for something inconsistent,
+ # i.e. different than what it would give if the guard_value
+ # passed (this is a rare case, but possible). If we get
+ # inconsistent results in this way, then we must not do the
+ # replacement, otherwise we'd put guard_value up there but all
+ # intermediate ops might be executed by assuming something
+ # different, from the old guard that is now removed...
+
+ c_value = op.getarg(1)
+ if not c_value.nonnull():
+ raise InvalidLoop('A GUARD_VALUE(..., NULL) follows some other '
+ 'guard that it is not NULL')
+ previous_classbox = info.get_known_class(self.optimizer.cpu)
+ if previous_classbox is not None:
+ expected_classbox = self.optimizer.cpu.ts.cls_of_box(c_value)
assert expected_classbox is not None
if not previous_classbox.same_constant(
expected_classbox):
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -3063,6 +3063,16 @@
self.optimize_loop(ops, expected, preamble)
#self.check_expanded_fail_descr("i0", rop.GUARD_VALUE)
+ def test_invalid_guard_value_after_guard_class(self):
+ ops = """
+ [p1, i0, i1, i2, p2]
+ guard_class(p1, ConstClass(node_vtable)) [i0]
+ i3 = int_add(i1, i2)
+ guard_value(p1, NULL) [i1]
+ jump(p2, i0, i1, i3, p2)
+ """
+ self.raises(InvalidLoop, self.optimize_loop, ops, ops)
+
def test_guard_class_oois(self):
ops = """
[p1]
diff --git a/rpython/rlib/rvmprof/test/test_rvmprof.py b/rpython/rlib/rvmprof/test/test_rvmprof.py
--- a/rpython/rlib/rvmprof/test/test_rvmprof.py
+++ b/rpython/rlib/rvmprof/test/test_rvmprof.py
@@ -101,7 +101,7 @@
s = 0
for i in range(num):
s += (i << 1)
- if s % 32423423423 == 0:
+ if s % 2123423423 == 0:
print s
return s
More information about the pypy-commit
mailing list