[pypy-svn] r67003 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
arigo at codespeak.net
arigo at codespeak.net
Wed Aug 19 20:50:47 CEST 2009
Author: arigo
Date: Wed Aug 19 20:50:45 2009
New Revision: 67003
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_codewriter.py
Log:
Fix (oups).
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py Wed Aug 19 20:50:45 2009
@@ -869,11 +869,12 @@
# check for deepfrozen structures that force constant-folding
hints = deref(v_inst.concretetype)._hints
accessor = hints.get("immutable_fields")
- if hints.get('immutable') or \
- accessor and c_fieldname.value in accessor.fields:
+ if accessor and c_fieldname.value in accessor.fields:
pure = '_pure'
- if accessor and accessor.fields[c_fieldname.value] == "[*]":
+ if accessor.fields[c_fieldname.value] == "[*]":
self.immutable_arrays[op.result] = True
+ elif hints.get('immutable'):
+ pure = '_pure'
else:
pure = ''
argname = getattr(deref(v_inst.concretetype), '_gckind', 'gc')
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_codewriter.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_codewriter.py Wed Aug 19 20:50:45 2009
@@ -35,6 +35,25 @@
getarrayitem_gc=0, getarrayitem_gc_pure=1)
+ def test_array_in_immutable(self):
+ class X(object):
+ _immutable_ = True
+ _immutable_fields_ = ["lst[*]"]
+
+ def __init__(self, lst, y):
+ self.lst = lst
+ self.y = y
+
+ def f(x, index):
+ y = X([x], x+1)
+ return y.lst[index] + y.y + 5
+ res = self.interp_operations(f, [23, 0], listops=True)
+ assert res == 23 + 24 + 5
+ self.check_history_(getfield_gc=0, getfield_gc_pure=2,
+ getarrayitem_gc=0, getarrayitem_gc_pure=1,
+ int_add=3)
+
+
class TestLLtypeImmutableFieldsTests(ImmutableFieldsTests, LLJitMixin):
pass
More information about the Pypy-commit
mailing list