[pypy-svn] r51628 - in pypy/branch/no-forw-ptr/pypy/rpython: lltypesystem memory/gc
arigo at codespeak.net
arigo at codespeak.net
Tue Feb 19 13:20:06 CET 2008
Author: arigo
Date: Tue Feb 19 13:20:06 2008
New Revision: 51628
Modified:
pypy/branch/no-forw-ptr/pypy/rpython/lltypesystem/llarena.py
pypy/branch/no-forw-ptr/pypy/rpython/memory/gc/generation.py
Log:
Fix the GenerationGC for the removal of the .forw pointers.
Modified: pypy/branch/no-forw-ptr/pypy/rpython/lltypesystem/llarena.py
==============================================================================
--- pypy/branch/no-forw-ptr/pypy/rpython/lltypesystem/llarena.py (original)
+++ pypy/branch/no-forw-ptr/pypy/rpython/lltypesystem/llarena.py Tue Feb 19 13:20:06 2008
@@ -152,6 +152,7 @@
return True
def compare_with_fakeaddr(self, other):
+ other = other._fixup()
if not other:
return None, None
obj = other.ptr._obj
Modified: pypy/branch/no-forw-ptr/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/branch/no-forw-ptr/pypy/rpython/memory/gc/generation.py (original)
+++ pypy/branch/no-forw-ptr/pypy/rpython/memory/gc/generation.py Tue Feb 19 13:20:06 2008
@@ -22,8 +22,8 @@
class GenerationGC(SemiSpaceGC):
"""A basic generational GC: it's a SemiSpaceGC with an additional
nursery for young objects. A write barrier is used to ensure that
- old objects that contain pointers to young objects are in a linked
- list, chained to each other via their 'forw' header field.
+ old objects that contain pointers to young objects are recorded in
+ a list.
"""
inline_simple_malloc = True
inline_simple_malloc_varsize = True
@@ -44,19 +44,16 @@
self.initial_nursery_size = nursery_size
self.auto_nursery_size = auto_nursery_size
self.min_nursery_size = min_nursery_size
-
- def setup(self):
- SemiSpaceGC.setup(self)
- self.reset_nursery()
- self.old_objects_pointing_to_young = NULL
- # ^^^ the head of a linked list inside the old objects space; it
+ self.old_objects_pointing_to_young = self.AddressStack()
+ # ^^^ a list of addresses inside the old objects space; it
# may contain static prebuilt objects as well. More precisely,
# it lists exactly the old and static objects whose
- # GCFLAG_NO_YOUNG_PTRS bit is not set. The 'forw' header field
- # of such objects is abused for this linked list; it needs to be
- # reset to its correct value when GCFLAG_NO_YOUNG_PTRS is set
- # again at the start of a collection.
+ # GCFLAG_NO_YOUNG_PTRS bit is not set.
self.young_objects_with_weakrefs = self.AddressStack()
+ self.reset_nursery()
+
+ def setup(self):
+ SemiSpaceGC.setup(self)
self.set_nursery_size(self.initial_nursery_size)
# the GC is fully setup now. The rest can make use of it.
if self.auto_nursery_size:
@@ -226,14 +223,11 @@
# the next usage.
def reset_young_gcflags(self):
- obj = self.old_objects_pointing_to_young
- while obj:
+ oldlist = self.old_objects_pointing_to_young
+ while oldlist.non_empty():
+ obj = oldlist.pop()
hdr = self.header(obj)
hdr.tid |= GCFLAG_NO_YOUNG_PTRS
- nextobj = hdr.forw
- self.init_forwarding(obj)
- obj = nextobj
- self.old_objects_pointing_to_young = NULL
def weakrefs_grow_older(self):
while self.young_objects_with_weakrefs.non_empty():
@@ -278,19 +272,15 @@
def collect_oldrefs_to_nursery(self):
# Follow the old_objects_pointing_to_young list and move the
- # young objects they point to out of the nursery. The 'forw'
- # fields are reset to their correct value along the way.
+ # young objects they point to out of the nursery.
count = 0
- obj = self.old_objects_pointing_to_young
- while obj:
+ oldlist = self.old_objects_pointing_to_young
+ while oldlist.non_empty():
count += 1
- nextobj = self.header(obj).forw
- self.init_forwarding(obj)
+ obj = oldlist.pop()
self.trace_and_drag_out_of_nursery(obj)
- obj = nextobj
if DEBUG_PRINT:
llop.debug_print(lltype.Void, "collect_oldrefs_to_nursery", count)
- self.old_objects_pointing_to_young = NULL
def collect_roots_in_nursery(self):
# we don't need to trace prebuilt GcStructs during a minor collect:
@@ -362,8 +352,7 @@
"nursery object with GCFLAG_NO_YOUNG_PTRS")
oldhdr = self.header(addr_struct)
if self.is_in_nursery(addr):
- oldhdr.forw = self.old_objects_pointing_to_young
- self.old_objects_pointing_to_young = addr_struct
+ self.old_objects_pointing_to_young.append(addr_struct)
oldhdr.tid &= ~GCFLAG_NO_YOUNG_PTRS
if oldhdr.tid & GCFLAG_NO_HEAP_PTRS:
self.move_to_static_roots(addr_struct)
More information about the Pypy-commit
mailing list