[pypy-svn] r27297 - in pypy/dist/pypy/rpython/memory: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue May 16 20:53:00 CEST 2006
Author: cfbolz
Date: Tue May 16 20:52:58 2006
New Revision: 27297
Modified:
pypy/dist/pypy/rpython/memory/gc.py
pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py
Log:
test + fix for the problem that static roots don't have their mark bit reset
after a collection and are considered to be already visited in the next one
Modified: pypy/dist/pypy/rpython/memory/gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc.py (original)
+++ pypy/dist/pypy/rpython/memory/gc.py Tue May 16 20:52:58 2006
@@ -182,10 +182,11 @@
break
# roots is a list of addresses to addresses:
objects.append(curr.address[0])
-## # constants roots are not malloced and thus don't have their mark
-## # bit reset
-## gc_info = curr.address[0] - MarkSweepGC._size_gc_header
-## gc_info.signed[0] = gc_info.signed[0] & (~1)
+ # the last sweep did not clear the mark bit of static roots,
+ # since they are not in the malloced_objects list
+ gc_info = curr.address[0] - MarkSweepGC._size_gc_header
+ hdr = llmemory.cast_adr_to_ptr(gc_info, self.HDRPTR)
+ hdr.typeid = hdr.typeid & (~1)
free_non_gc_object(roots)
# from this point onwards, no more mallocs should be possible
old_malloced = self.bytes_malloced
Modified: pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py (original)
+++ pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py Tue May 16 20:52:58 2006
@@ -158,6 +158,8 @@
from pypy.annotation import model as annmodel
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.memory import gctransform
+from pypy.rpython.lltypesystem.lloperation import llop
+from pypy.rpython.lltypesystem import lltype
from pypy.rpython.memory.support import INT_SIZE
from pypy import conftest
@@ -259,7 +261,7 @@
run, statistics = self.runner(malloc_a_lot, statistics=True)
run([])
heap_size = statistics().item0
- assert heap_size < 16000 * INT_SIZE / 4 # xxx
+ assert heap_size < 16000 * INT_SIZE / 4 # xxx
def test_global_list(self):
class Box:
@@ -268,11 +270,12 @@
box = Box()
def append_to_list(i, j):
box.lst.append([i] * 50)
+ llop.gc__collect(lltype.Void)
return box.lst[j][0]
run = self.runner(append_to_list, nbargs=2)
res = run([0, 0])
assert res == 0
- for i in range(1, 15):
+ for i in range(1, 5):
res = run([i, i - 1])
assert res == i - 1 # crashes if constants are not considered roots
More information about the Pypy-commit
mailing list