[pypy-commit] pypy array-overallocation-in-nursery: (fijal, arigo) Finish and pass the test for gctypelayout.
arigo
noreply at buildbot.pypy.org
Tue Oct 22 13:47:35 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: array-overallocation-in-nursery
Changeset: r67509:5148aded3637
Date: 2013-10-22 13:46 +0200
http://bitbucket.org/pypy/pypy/changeset/5148aded3637/
Log: (fijal, arigo) Finish and pass the test for gctypelayout.
diff --git a/rpython/memory/gctypelayout.py b/rpython/memory/gctypelayout.py
--- a/rpython/memory/gctypelayout.py
+++ b/rpython/memory/gctypelayout.py
@@ -113,6 +113,9 @@
def q_varsize_offset_to_length(self, typeid):
return self.get_varsize(typeid).ofstolength
+ def q_varsize_offset_to_used_length(self, typeid):
+ return self.get_varsize(typeid).ofstousedlength
+
def q_varsize_offsets_to_gcpointers_in_var_part(self, typeid):
return self.get_varsize(typeid).varofstoptrs
@@ -241,13 +244,15 @@
else:
assert isinstance(TYPE, lltype.GcArray)
ARRAY = TYPE
- if ARRAY._is_overallocated_array():
+ if not ARRAY._is_overallocated_array():
if (isinstance(ARRAY.OF, lltype.Ptr)
and ARRAY.OF.TO._gckind == 'gc'):
infobits |= T_IS_GCARRAY_OF_GCPTR
varinfo.ofstolength = llmemory.ArrayLengthOffset(ARRAY)
else:
- ...
+ ALO = llmemory.ArrayLengthOffset
+ varinfo.ofstolength = ALO(ARRAY, attrkind="allocated_length")
+ varinfo.ofstousedlength = ALO(ARRAY, attrkind="used_length")
varinfo.ofstovar = llmemory.itemoffsetof(TYPE, 0)
assert isinstance(ARRAY, lltype.Array)
if ARRAY.OF != lltype.Void:
diff --git a/rpython/memory/test/test_gctypelayout.py b/rpython/memory/test/test_gctypelayout.py
--- a/rpython/memory/test/test_gctypelayout.py
+++ b/rpython/memory/test/test_gctypelayout.py
@@ -127,4 +127,12 @@
layoutbuilder = TypeLayoutBuilder(FakeGC)
tid = layoutbuilder.get_type_id(A)
- xxx
+ gcdata = GCData(layoutbuilder.type_info_group)
+ assert gcdata.q_is_varsize(tid)
+ assert not gcdata.q_is_gcarrayofgcptr(tid) # XXX for now
+ ofs = gcdata.q_varsize_offset_to_length(tid)
+ assert isinstance(ofs, llmemory.ArrayLengthOffset)
+ assert ofs.attrkind == "allocated_length"
+ ofs = gcdata.q_varsize_offset_to_used_length(tid)
+ assert isinstance(ofs, llmemory.ArrayLengthOffset)
+ assert ofs.attrkind == "used_length"
More information about the pypy-commit
mailing list