summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--gc.c33
2 files changed, 27 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 729dde69da..5647e92dc6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jan 23 18:51:57 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc_call_finalizer_at_exit): should finalize objects in
+ deferred_final_list too.
+
Tue Jan 23 16:10:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (os_live_obj): do not list terminated object.
diff --git a/gc.c b/gc.c
index 25a9095026..abc8e69919 100644
--- a/gc.c
+++ b/gc.c
@@ -717,7 +717,7 @@ gc_sweep()
during_gc = 0;
/* clear finalization list */
- if (need_call_final && final_list) {
+ if (final_list) {
RVALUE *tmp;
if (rb_prohibit_interrupt || ruby_in_compile) {
@@ -1213,9 +1213,9 @@ run_final(obj)
args[0] = RARRAY(finalizers)->ptr[i];
rb_protect(run_single_final, (VALUE)args, &status);
}
- if (finalizer_table && st_lookup(finalizer_table, obj, &table)) {
- st_delete(finalizer_table, &obj, 0);
+ if (finalizer_table && st_delete(finalizer_table, &obj, &table)) {
for (i=0; i<RARRAY(table)->len; i++) {
+ printf("n finals=>%d\n", finalizer_table->num_entries);
args[0] = RARRAY(table)->ptr[i];
rb_protect(run_single_final, (VALUE)args, &status);
}
@@ -1229,15 +1229,26 @@ rb_gc_call_finalizer_at_exit()
int i;
/* run finalizers */
- for (i = 0; i < heaps_used; i++) {
- p = heaps[i]; pend = p + HEAP_SLOTS;
- while (p < pend) {
- if (FL_TEST(p, FL_FINALIZE)) {
- FL_UNSET(p, FL_FINALIZE);
- p->as.basic.klass = 0;
- run_final((VALUE)p);
+ if (need_call_final) {
+ if (deferred_final_list) {
+ p = deferred_final_list;
+ while (p) {
+ RVALUE *tmp = p;
+ p = p->as.free.next;
+ run_final((VALUE)tmp);
+ }
+ }
+ for (i = 0; i < heaps_used; i++) {
+ p = heaps[i]; pend = p + HEAP_SLOTS;
+ while (p < pend) {
+ if (FL_TEST(p, FL_FINALIZE)) {
+ FL_UNSET(p, FL_FINALIZE);
+ p->as.basic.klass = 0;
+ printf("%p\n", p);
+ run_final((VALUE)p);
+ }
+ p++;
}
- p++;
}
}
/* run data object's finaliers */