Author: Carl Friedrich Bolz <[email protected]>
Branch:
Changeset: r73834:d888c64eab67
Date: 2014-10-07 10:25 +0200
http://bitbucket.org/pypy/pypy/changeset/d888c64eab67/
Log: optimize quasi-immutable lists?[*] in the same way
diff --git a/rpython/jit/codewriter/jtransform.py
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -785,8 +785,7 @@
raise Exception("getfield_raw_r (without _pure) not supported")
#
if immut in (IR_QUASIIMMUTABLE, IR_QUASIIMMUTABLE_ARRAY):
- if immut is IR_QUASIIMMUTABLE:
- op1.opname += "_pure"
+ op1.opname += "_pure"
descr1 = self.cpu.fielddescrof(
v_inst.concretetype.TO,
quasiimmut.get_mutate_field_name(c_fieldname.value))
diff --git a/rpython/jit/metainterp/test/test_quasiimmut.py
b/rpython/jit/metainterp/test/test_quasiimmut.py
--- a/rpython/jit/metainterp/test/test_quasiimmut.py
+++ b/rpython/jit/metainterp/test/test_quasiimmut.py
@@ -369,7 +369,7 @@
res = self.meta_interp(f, [100, 7])
assert res == 700
self.check_resops(getarrayitem_gc_pure=0, guard_not_invalidated=2,
- getarrayitem_gc=0, getfield_gc=0)
+ getarrayitem_gc=0, getfield_gc=0, getfield_gc_pure=0)
#
from rpython.jit.metainterp.warmspot import get_stats
loops = get_stats().loops
@@ -377,6 +377,30 @@
assert len(loop.quasi_immutable_deps) == 1
assert isinstance(loop.quasi_immutable_deps.keys()[0], QuasiImmut)
+ def test_list_optimized_while_tracing(self):
+ myjitdriver = JitDriver(greens=['foo'], reds=['x', 'total'])
+ class Foo:
+ _immutable_fields_ = ['lst?[*]']
+ def __init__(self, lst):
+ self.lst = lst
+ def f(a, x):
+ lst1 = [0, 0]
+ lst1[1] = a
+ foo = Foo(lst1)
+ total = 0
+ while x > 0:
+ myjitdriver.jit_merge_point(foo=foo, x=x, total=total)
+ # read a quasi-immutable field out of a Constant
+ total += foo.lst[1]
+ x -= 1
+ return total
+ #
+ res = self.meta_interp(f, [100, 7], enable_opts="")
+ assert res == 700
+ # operations must have been removed by the frontend
+ self.check_resops(getarrayitem_gc_pure=0, guard_not_invalidated=1,
+ getarrayitem_gc=0, getfield_gc=0, getfield_gc_pure=0)
+
def test_list_length_1(self):
myjitdriver = JitDriver(greens=['foo'], reds=['x', 'total'])
class Foo:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit