[pypy-commit] pypy lightweight-finalizers: clean up previous attempts, make this one work
fijal
noreply at buildbot.pypy.org
Sun Oct 9 14:33:45 CEST 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: lightweight-finalizers
Changeset: r47894:b399c49c9fe6
Date: 2011-10-09 14:33 +0200
http://bitbucket.org/pypy/pypy/changeset/b399c49c9fe6/
Log: clean up previous attempts, make this one work
diff --git a/pypy/rpython/memory/gc/generation.py b/pypy/rpython/memory/gc/generation.py
--- a/pypy/rpython/memory/gc/generation.py
+++ b/pypy/rpython/memory/gc/generation.py
@@ -87,7 +87,6 @@
self.last_generation_root_objects = self.AddressStack()
self.young_objects_with_id = self.AddressDict()
- self.young_objects_with_raw_mem = self.AddressStack()
SemiSpaceGC.setup(self)
self.set_nursery_size(self.initial_nursery_size)
# the GC is fully setup now. The rest can make use of it.
@@ -191,8 +190,6 @@
llarena.arena_reserve(result, totalsize)
# GCFLAG_NO_YOUNG_PTRS is never set on young objs
self.init_gc_object(result, typeid, flags=0)
- if self.has_raw_mem_ptr(typeid):
- self.young_objects_with_raw_mem.append(result + size_gc_header)
self.nursery_free = result + totalsize
if contains_weakptr:
self.young_objects_with_weakrefs.append(result + size_gc_header)
@@ -270,7 +267,6 @@
def semispace_collect(self, size_changing=False):
self.reset_young_gcflags() # we are doing a full collection anyway
self.weakrefs_grow_older()
- self.raw_mem_grow_older()
self.ids_grow_older()
self.reset_nursery()
SemiSpaceGC.semispace_collect(self, size_changing)
@@ -305,11 +301,6 @@
obj = self.young_objects_with_weakrefs.pop()
self.objects_with_weakrefs.append(obj)
- def raw_mem_grow_older(self):
- while self.young_objects_with_raw_mem.non_empty():
- obj = self.young_objects_with_raw_mem.pop()
- self.objects_with_raw_mem.append(obj)
-
def collect_roots(self):
"""GenerationGC: collects all roots.
HybridGC: collects all roots, excluding the generation 3 ones.
@@ -369,8 +360,6 @@
self.invalidate_young_weakrefs()
if self.young_objects_with_id.length() > 0:
self.update_young_objects_with_id()
- if self.young_objects_with_raw_mem.non_empty():
- self.deal_with_young_objects_with_raw_mem()
# mark the nursery as free and fill it with zeroes again
llarena.arena_reset(self.nursery, self.nursery_size, 2)
debug_print("survived (fraction of the size):",
@@ -573,15 +562,6 @@
# minimal size, which is actually a good idea: a large, mostly-empty
# table is bad for the next call to 'foreach'.
- def deal_with_young_objects_with_raw_mem(self):
- while self.young_objects_with_raw_mem.non_empty():
- addr = self.young_objects_with_raw_mem.pop()
- if self.surviving(addr):
- self.objects_with_raw_mem.append(
- self.get_forwarding_address(addr))
- else:
- self._free_raw_mem_from(addr)
-
def ids_grow_older(self):
self.young_objects_with_id.foreach(self._id_grow_older, None)
self.young_objects_with_id.clear()
diff --git a/pypy/rpython/memory/gc/marksweep.py b/pypy/rpython/memory/gc/marksweep.py
--- a/pypy/rpython/memory/gc/marksweep.py
+++ b/pypy/rpython/memory/gc/marksweep.py
@@ -93,7 +93,8 @@
pass
def malloc_fixedsize(self, typeid16, size,
- has_finalizer=False, contains_weakptr=False):
+ has_finalizer=False, has_light_finalizer=False,
+ contains_weakptr=False):
self.maybe_collect()
size_gc_header = self.gcheaderbuilder.size_gc_header
try:
@@ -128,7 +129,9 @@
malloc_fixedsize._dont_inline_ = True
def malloc_fixedsize_clear(self, typeid16, size,
- has_finalizer=False, contains_weakptr=False):
+ has_finalizer=False,
+ has_light_finalizer=False,
+ contains_weakptr=False):
self.maybe_collect()
size_gc_header = self.gcheaderbuilder.size_gc_header
try:
diff --git a/pypy/rpython/memory/gc/minimark.py b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -297,10 +297,6 @@
# created after it.
self.young_objects_with_weakrefs = self.AddressStack()
self.old_objects_with_weakrefs = self.AddressStack()
- # This is a list for objects that are in the nursery and
- # own some raw memory. Note that young objects which are raw_malloced
- # won't go there
- self.young_objects_with_raw_mem = self.AddressStack()
#
# Support for id and identityhash: map nursery objects with
# GCFLAG_HAS_SHADOW to their future location at the next
@@ -505,9 +501,6 @@
# If it is a weakref, record it (check constant-folded).
if contains_weakptr:
self.young_objects_with_weakrefs.append(result+size_gc_header)
- if self.has_raw_mem_ptr(typeid):
- self.young_objects_with_raw_mem.append(result + size_gc_header)
- #
obj = result + size_gc_header
#
return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
@@ -1272,8 +1265,6 @@
# weakrefs' targets.
if self.young_objects_with_weakrefs.non_empty():
self.invalidate_young_weakrefs()
- if self.young_objects_with_raw_mem.non_empty():
- self.invalidate_young_raw_mem()
#
# Clear this mapping.
if self.nursery_objects_shadows.length() > 0:
@@ -1658,8 +1649,6 @@
self.header(obj).tid &= ~GCFLAG_VISITED
return False # survives
else:
- if self.has_raw_mem_ptr(self.get_type_id(obj)):
- self._free_raw_mem_from(obj)
return True # dies
def _reset_gcflag_visited(self, obj, ignored):
@@ -1689,8 +1678,6 @@
arena -= extra_words * WORD
allocsize += extra_words * WORD
#
- if self.has_raw_mem_ptr(self.get_type_id(obj)):
- self._free_raw_mem_from(obj)
llarena.arena_free(arena)
self.rawmalloced_total_size -= allocsize
@@ -1989,12 +1976,6 @@
self.old_objects_with_weakrefs.delete()
self.old_objects_with_weakrefs = new_with_weakref
- def invalidate_young_raw_mem(self):
- while self.young_objects_with_raw_mem.non_empty():
- addr = self.young_objects_with_raw_mem.pop()
- if self.header(addr).tid & GCFLAG_VISITED == 0:
- self._free_raw_mem_from(addr)
-
# ____________________________________________________________
diff --git a/pypy/rpython/memory/gctransform/framework.py b/pypy/rpython/memory/gctransform/framework.py
--- a/pypy/rpython/memory/gctransform/framework.py
+++ b/pypy/rpython/memory/gctransform/framework.py
@@ -268,6 +268,7 @@
[s_gc, s_typeid16,
annmodel.SomeInteger(nonneg=True),
annmodel.SomeBool(),
+ annmodel.SomeBool(),
annmodel.SomeBool()], s_gcref,
inline = False)
else:
More information about the pypy-commit
mailing list