Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r64467:0ad2bd9495a1
Date: 2013-05-22 10:18 -0700
http://bitbucket.org/pypy/pypy/changeset/0ad2bd9495a1/
Log: In the JIT frontend don't emit writes to young objects where they
are constant 0s.
diff --git a/rpython/jit/metainterp/pyjitpl.py
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -621,7 +621,8 @@
tobox = self.metainterp.heapcache.getfield(box, fielddescr)
if tobox is valuebox:
return
- self.execute_with_descr(rop.SETFIELD_GC, fielddescr, box, valuebox)
+ if tobox is not None or not
self.metainterp.heapcache.is_unescaped(box) or not isinstance(valuebox, Const)
or valuebox.nonnull():
+ self.execute_with_descr(rop.SETFIELD_GC, fielddescr, box, valuebox)
self.metainterp.heapcache.setfield(box, valuebox, fielddescr)
opimpl_setfield_gc_i = _opimpl_setfield_gc_any
opimpl_setfield_gc_r = _opimpl_setfield_gc_any
diff --git a/rpython/jit/metainterp/test/test_tracingopts.py
b/rpython/jit/metainterp/test/test_tracingopts.py
--- a/rpython/jit/metainterp/test/test_tracingopts.py
+++ b/rpython/jit/metainterp/test/test_tracingopts.py
@@ -645,3 +645,20 @@
res = self.interp_operations(fn, [1])
assert res == -1
self.check_operations_history(guard_class=0)
+
+ def test_dont_record_setfield_gc_zeros(self):
+ class A(object):
+ pass
+
+ def make_a():
+ return A()
+ make_a._dont_inline_ = True
+
+ def fn(n):
+ a = make_a()
+ a.x = jit.promote(n)
+ return a.x
+
+ res = self.interp_operations(fn, [0])
+ assert res == 0
+ self.check_operations_history(setfield_gc=0)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit