Author: Armin Rigo <[email protected]>
Branch: gc-del-3
Changeset: r84192:db5aabaa5d41
Date: 2016-05-04 18:26 +0200
http://bitbucket.org/pypy/pypy/changeset/db5aabaa5d41/
Log: Fixes
diff --git a/rpython/memory/gc/base.py b/rpython/memory/gc/base.py
--- a/rpython/memory/gc/base.py
+++ b/rpython/memory/gc/base.py
@@ -427,9 +427,7 @@
i += 1
while self.run_old_style_finalizers.non_empty():
obj = self.run_old_style_finalizers.popleft()
- typeid = self.get_type_id(obj)
- finalizer = self.destructor_or_custom_trace(typeid)
- finalizer(obj)
+ self.call_destructor(obj)
finally:
self.finalizer_lock = False
diff --git a/rpython/memory/gc/generation.py b/rpython/memory/gc/generation.py
--- a/rpython/memory/gc/generation.py
+++ b/rpython/memory/gc/generation.py
@@ -355,6 +355,7 @@
scan = beginning = self.free
self.collect_oldrefs_to_nursery()
self.collect_roots_in_nursery()
+ self.collect_young_objects_with_finalizers()
scan = self.scan_objects_just_copied_out_of_nursery(scan)
# at this point, all static and old objects have got their
# GCFLAG_NO_YOUNG_PTRS set again by trace_and_drag_out_of_nursery
@@ -422,6 +423,19 @@
if self.is_in_nursery(obj):
root.address[0] = self.copy(obj)
+ def collect_young_objects_with_finalizers(self):
+ # XXX always walk the whole 'objects_with_finalizers' list here
+ new = self.AddressDeque()
+ while self.objects_with_finalizers.non_empty():
+ obj = self.objects_with_finalizers.popleft()
+ fq_nr = self.objects_with_finalizers.popleft()
+ if self.is_in_nursery(obj):
+ obj = self.copy(obj)
+ new.append(obj)
+ new.append(fq_nr)
+ self.objects_with_finalizers.delete()
+ self.objects_with_finalizers = new
+
def scan_objects_just_copied_out_of_nursery(self, scan):
while scan < self.free:
curr = scan + self.size_gc_header()
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -619,14 +619,12 @@
# The following check should be constant-folded.
if needs_finalizer and not is_finalizer_light:
# old-style finalizers only!
- from rpython.rtyper.lltypesystem import rffi
ll_assert(not contains_weakptr,
"'needs_finalizer' and 'contains_weakptr' both specified")
obj = self.external_malloc(typeid, 0, alloc_young=False)
- self.old_objects_with_finalizers.append(obj)
- self.old_objects_with_finalizers.append(
- rffi.cast(llmemory.Address, -1))
- return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
+ res = llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
+ self.register_finalizer(-1, res)
+ return res
#
# If totalsize is greater than nonlarge_max (which should never be
# the case in practice), ask for a rawmalloc. The following check
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit