diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-01-23 09:55:10 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-01-23 09:55:10 +0000 |
commit | e111bdb9d389af5d1c23ff54749f56cc8282b825 (patch) | |
tree | 6aacc96628e5e1d762b86865c1d60e5ca39a5ad3 /gc.c | |
parent | 2455b077df103f3ffd55474acd8af42cc4b5f709 (diff) |
* gc.c (rb_gc_call_finalizer_at_exit): should finalize objects in
deferred_final_list too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 33 |
1 files changed, 22 insertions, 11 deletions
@@ -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 */ |