[pypy-commit] pypy default: emit guard_nonnull_class in the short preamble, instead of two guards in case
cfbolz
pypy.commits at gmail.com
Tue Sep 5 10:34:16 EDT 2017
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch:
Changeset: r92317:e66be45f3914
Date: 2017-09-05 16:33 +0200
http://bitbucket.org/pypy/pypy/changeset/e66be45f3914/
Log: emit guard_nonnull_class in the short preamble, instead of two
guards in case of remove_gctypeptr = True
diff --git a/rpython/jit/metainterp/optimizeopt/info.py b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -329,11 +329,14 @@
def make_guards(self, op, short, optimizer):
if self._known_class is not None:
- short.append(ResOperation(rop.GUARD_NONNULL, [op]))
if not optimizer.cpu.remove_gctypeptr:
+ short.append(ResOperation(rop.GUARD_NONNULL, [op]))
short.append(ResOperation(rop.GUARD_IS_OBJECT, [op]))
- short.append(ResOperation(rop.GUARD_CLASS,
- [op, self._known_class]))
+ short.append(ResOperation(rop.GUARD_CLASS,
+ [op, self._known_class]))
+ else:
+ short.append(ResOperation(rop.GUARD_NONNULL_CLASS,
+ [op, self._known_class]))
elif self.descr is not None:
short.append(ResOperation(rop.GUARD_NONNULL, [op]))
if not optimizer.cpu.remove_gctypeptr:
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
@@ -7541,6 +7541,33 @@
"""
self.optimize_loop(ops, expected, expected_short=short)
+ def test_guards_before_getfields_in_short_preamble_removetypeptr(self, monkeypatch):
+ monkeypatch.setattr(self.cpu, "remove_gctypeptr", True)
+ ops = """
+ [p0]
+ guard_nonnull_class(p0, ConstClass(node_vtable)) []
+ p1 = getfield_gc_r(p0, descr=nextdescr)
+ guard_nonnull_class(p1, ConstClass(node_vtable)) []
+ p2 = getfield_gc_r(p1, descr=nextdescr)
+ guard_nonnull_class(p2, ConstClass(node_vtable)) []
+ jump(p0)
+ """
+ expected = """
+ [p0, p1]
+ jump(p0, p1)
+ """
+ short = """
+ [p0]
+ guard_nonnull_class(p0, ConstClass(node_vtable)) []
+ p1 = getfield_gc_r(p0, descr=nextdescr)
+ guard_nonnull_class(p1, ConstClass(node_vtable)) []
+ p2 = getfield_gc_r(p1, descr=nextdescr)
+ guard_nonnull_class(p2, ConstClass(node_vtable)) []
+ jump(p1)
+ """
+ self.optimize_loop(ops, expected, expected_short=short)
+
+
def test_forced_virtual_pure_getfield(self):
ops = """
[p0]
More information about the pypy-commit
mailing list