[pypy-commit] pypy default: Test and fix (baaa*a*a*ah, took too long): IR_QUASIIMMUTABLE fields
arigo
noreply at buildbot.pypy.org
Fri Sep 2 16:04:34 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r47025:324d50d0f5c7
Date: 2011-09-02 16:02 +0200
http://bitbucket.org/pypy/pypy/changeset/324d50d0f5c7/
Log: Test and fix (baaa*a*a*ah, took too long): IR_QUASIIMMUTABLE fields
must of course not be considered as fully immutable fields!
diff --git a/pypy/rpython/memory/gctypelayout.py b/pypy/rpython/memory/gctypelayout.py
--- a/pypy/rpython/memory/gctypelayout.py
+++ b/pypy/rpython/memory/gctypelayout.py
@@ -459,7 +459,7 @@
if t._hints.get('immutable'):
return
if 'immutable_fields' in t._hints:
- skip = t._hints['immutable_fields'].fields
+ skip = t._hints['immutable_fields'].all_immutable_fields()
for n, t2 in t._flds.iteritems():
if isinstance(t2, lltype.Ptr) and t2.TO._gckind == 'gc':
if n not in skip:
diff --git a/pypy/rpython/memory/test/test_gctypelayout.py b/pypy/rpython/memory/test/test_gctypelayout.py
--- a/pypy/rpython/memory/test/test_gctypelayout.py
+++ b/pypy/rpython/memory/test/test_gctypelayout.py
@@ -4,7 +4,7 @@
from pypy.rpython.memory.gctypelayout import gc_pointers_inside
from pypy.rpython.lltypesystem import lltype, llmemory, rclass
from pypy.rpython.test.test_llinterp import get_interpreter
-from pypy.rpython.rclass import IR_IMMUTABLE
+from pypy.rpython.rclass import IR_IMMUTABLE, IR_QUASIIMMUTABLE
from pypy.objspace.flow.model import Constant
class FakeGC:
@@ -102,7 +102,7 @@
accessor = rclass.FieldListAccessor()
S3 = lltype.GcStruct('S', ('x', PT), ('y', PT),
hints={'immutable_fields': accessor})
- accessor.initialize(S3, {'x': IR_IMMUTABLE})
+ accessor.initialize(S3, {'x': IR_IMMUTABLE, 'y': IR_QUASIIMMUTABLE})
#
s1 = lltype.malloc(S1)
adr = llmemory.cast_ptr_to_adr(s1)
diff --git a/pypy/rpython/rclass.py b/pypy/rpython/rclass.py
--- a/pypy/rpython/rclass.py
+++ b/pypy/rpython/rclass.py
@@ -16,6 +16,13 @@
for x in fields.itervalues():
assert isinstance(x, ImmutableRanking)
+ def all_immutable_fields(self):
+ result = set()
+ for key, value in self.fields.iteritems():
+ if value in (IR_IMMUTABLE, IR_IMMUTABLE_ARRAY):
+ result.add(key)
+ return result
+
def __repr__(self):
return '<FieldListAccessor for %s>' % getattr(self, 'TYPE', '?')
More information about the pypy-commit
mailing list