Author: Carl Friedrich Bolz <[email protected]>
Branch: guard-compatible
Changeset: r83195:6920e13f35fd
Date: 2016-03-20 14:17 +0100
http://bitbucket.org/pypy/pypy/changeset/6920e13f35fd/
Log: support for quasi-immutable int/float fields
diff --git a/rpython/jit/metainterp/compatible.py
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -94,7 +94,7 @@
# we want to discover this (and so far precisely this) situation and
# make it possible for the GUARD_COMPATIBLE to still remove the call,
# even though the second argument is not constant
- if arg2.getopnum() != rop.GETFIELD_GC_R:
+ if arg2.getopnum() not in (rop.GETFIELD_GC_R, rop.GETFIELD_GC_I,
rop.GETFIELD_GC_F):
return None, None
if not self.last_quasi_immut_field_op:
return None, None
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_compatible.py
b/rpython/jit/metainterp/optimizeopt/test/test_compatible.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_compatible.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_compatible.py
@@ -141,3 +141,28 @@
assert descr._compatibility_conditions is not None
assert
descr._compatibility_conditions.known_valid.same_constant(ConstPtr(self.myptr))
assert len(descr._compatibility_conditions.conditions) == 1
+
+ def test_quasiimmut(self):
+ ops = """
+ [p1]
+ guard_compatible(p1, ConstPtr(quasiptr)) []
+ quasiimmut_field(p1, descr=quasiimmutdescr)
+ guard_not_invalidated() []
+ i0 = getfield_gc_i(p1, descr=quasifielddescr)
+ i1 = call_pure_i(123, p1, i0, descr=nonwritedescr)
+ escape_n(i1)
+ jump(p1)
+ """
+ expected = """
+ [p1]
+ guard_compatible(p1, ConstPtr(quasiptr)) []
+ guard_not_invalidated() []
+ i0 = getfield_gc_i(p1, descr=quasifielddescr) # will be removed by the
backend
+ escape_n(5)
+ jump(p1)
+ """
+ call_pure_results = {
+ (ConstInt(123), ConstPtr(self.quasiptr), ConstInt(-4247)):
ConstInt(5),
+ }
+ self.optimize_loop(ops, expected, call_pure_results)
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit