[pypy-svn] r70930 - in pypy/branch/gc-huge-list/pypy/rpython/memory/gc: . test
arigo at codespeak.net
arigo at codespeak.net
Wed Jan 27 18:23:59 CET 2010
Author: arigo
Date: Wed Jan 27 18:23:58 2010
New Revision: 70930
Modified:
pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py
pypy/branch/gc-huge-list/pypy/rpython/memory/gc/test/test_direct.py
Log:
(fijal, arigo)
Write 'foreach_marked_card_and_clean' and improve the test a bit.
Modified: pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py (original)
+++ pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py Wed Jan 27 18:23:58 2010
@@ -608,14 +608,16 @@
item += itemlength
trace_marked_card._annspecialcase_ = 'specialize:arg(3)'
- def foreach_marked_card(self, obj, callback, arg):
+ def foreach_marked_card_and_clean(self, obj, callback, arg):
bytearraysize = self.get_extra_bitarray_size(self.get_size_incl_hash(obj))
size_gc_header = self.gcheaderbuilder.size_gc_header
bytearrayaddr = obj - size_gc_header
i = 0
while i < bytearraysize:
- next = ord((bytearrayaddr + llarena.negative_byte_index(i)).char[0])
+ nextaddr = bytearrayaddr + llarena.negative_byte_index(i)
+ next = ord(nextaddr.char[0])
if next != 0:
+ nextaddr.char[0] = chr(0)
base = i << 3
if next & 0x01: self.trace_marked_card(obj, base | 0, callback, arg)
if next & 0x02: self.trace_marked_card(obj, base | 1, callback, arg)
@@ -626,7 +628,7 @@
if next & 0x40: self.trace_marked_card(obj, base | 6, callback, arg)
if next & 0x80: self.trace_marked_card(obj, base | 7, callback, arg)
i += 1
- foreach_marked_card._annspecialcase_ = 'specialize:arg(2)'
+ foreach_marked_card_and_clean._annspecialcase_ = 'specialize:arg(2)'
# _________________________________________________________
Modified: pypy/branch/gc-huge-list/pypy/rpython/memory/gc/test/test_direct.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/memory/gc/test/test_direct.py (original)
+++ pypy/branch/gc-huge-list/pypy/rpython/memory/gc/test/test_direct.py Wed Jan 27 18:23:58 2010
@@ -415,25 +415,36 @@
old_trace = gc.trace_marked_card
gc.trace_marked_card = callback
- gc.foreach_marked_card(addr, 123, 456)
+ gc.foreach_marked_card_and_clean(addr, 123, 456)
assert marked_cards == [2]
gc.trace_marked_card = old_trace
+ assert (addr - size_gc_header + llarena.NegativeByteIndex(0)).char[0] == chr(0)
objs = []
def callback(obj, arg):
# obj is the address inside 'addr',
# so we need to read that array item
objs.append(obj.address[0])
- gc.foreach_marked_card(addr, callback, None)
+ self.writearray(obj, 7, p)
+ gc.foreach_marked_card_and_clean(addr, callback, None)
addrp = llmemory.cast_ptr_to_adr(p)
assert objs == [addrp]
+ self.writearray(obj, 7, p)
self.writearray(obj, 8, p)
+ assert (addr - size_gc_header + llarena.NegativeByteIndex(0)).char[0] == chr(1<<2 | 1<<3)
+
del objs[:]
- gc.foreach_marked_card(addr, callback, None)
+ gc.foreach_marked_card_and_clean(addr, callback, None)
assert objs == [addrp, addrp]
- assert (addr - size_gc_header + llarena.NegativeByteIndex(0)).char[0] == chr(1<<2 | 1<<3)
+ self.writearray(obj, 0, p)
+ self.writearray(obj, 11, p)
+ assert (addr - size_gc_header + llarena.NegativeByteIndex(0)).char[0] == chr(1<<0 | 1<<4)
+
+ del objs[:]
+ gc.foreach_marked_card_and_clean(addr, callback, None)
+ assert objs == [addrp, addrp]
class TestMarkCompactGC(DirectGCTest):
from pypy.rpython.memory.gc.markcompact import MarkCompactGC as GCClass
More information about the Pypy-commit
mailing list