ruby-changes:6879
From: nobu <ko1@a...>
Date: Thu, 7 Aug 2008 05:10:40 +0900 (JST)
Subject: [ruby-changes:6879] Ruby:r18397 (ruby_1_8): * gc.c (run_final): runs finalizers with the object terminated.
nobu 2008-08-07 05:05:48 +0900 (Thu, 07 Aug 2008) New Revision: 18397 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18397 Log: * gc.c (run_final): runs finalizers with the object terminated. * gc.c (rb_gc_call_finalizer_at_exit): ObjectSpace::finalizers needs to scan whole object space, although deprecated. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/gc.c branches/ruby_1_8/version.h Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 18396) +++ ruby_1_8/ChangeLog (revision 18397) @@ -1,3 +1,10 @@ +Thu Aug 7 05:05:46 2008 Nobuyoshi Nakada <nobu@r...> + + * gc.c (run_final): runs finalizers with the object terminated. + + * gc.c (rb_gc_call_finalizer_at_exit): ObjectSpace::finalizers needs + to scan whole object space, although deprecated. + Wed Aug 6 21:25:45 2008 Nobuyoshi Nakada <nobu@r...> * gc.c (chain_finalized_object): deletes finalizers to be invoked from Index: ruby_1_8/version.h =================================================================== --- ruby_1_8/version.h (revision 18396) +++ ruby_1_8/version.h (revision 18397) @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2008-08-06" +#define RUBY_RELEASE_DATE "2008-08-07" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20080806 +#define RUBY_RELEASE_CODE 20080807 #define RUBY_PATCHLEVEL 5000 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 7 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DAY 7 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; Index: ruby_1_8/gc.c =================================================================== --- ruby_1_8/gc.c (revision 18396) +++ ruby_1_8/gc.c (revision 18397) @@ -1218,7 +1218,7 @@ rb_gc_force_recycle(p) VALUE p; { - add_freelist(p); + add_freelist(RANY(p)); } static inline void @@ -1919,6 +1919,7 @@ VALUE args[3], table, objid; objid = rb_obj_id(obj); /* make obj into id */ + RBASIC(obj)->klass = 0; rb_thread_critical = Qtrue; args[1] = 0; args[2] = (VALUE)ruby_safe_level; @@ -1951,22 +1952,6 @@ } } -static int -chain_finalized_object(st_data_t key, st_data_t val, st_data_t arg) -{ - RVALUE *p = (RVALUE *)key, **final_list = (RVALUE **)arg; - if ((p->as.basic.flags & (FL_FINALIZE|FL_MARK)) == FL_FINALIZE) { - if (BUILTIN_TYPE(p) != T_DEFERRED) { - p->as.free.flags = FL_MARK | T_DEFERRED; /* remain marked */ - RDATA(p)->dfree = 0; - } - p->as.free.next = *final_list; - *final_list = p; - return ST_DELETE; - } - return ST_CONTINUE; -} - void rb_gc_call_finalizer_at_exit() { @@ -1975,20 +1960,23 @@ /* run finalizers */ if (need_call_final) { - do { - p = deferred_final_list; - deferred_final_list = 0; - finalize_list(p); - mark_tbl(finalizer_table, 0); - st_foreach(finalizer_table, chain_finalized_object, - (st_data_t)&deferred_final_list); - } while (deferred_final_list); - if (finalizer_table->num_entries) { - rb_warning("%d finalizer%s left not-invoked due to self-reference", - finalizer_table->num_entries, - finalizer_table->num_entries > 1 ? "s" : ""); + p = deferred_final_list; + deferred_final_list = 0; + finalize_list(p); + for (i = 0; i < heaps_used; i++) { + p = heaps[i].slot; pend = p + heaps[i].limit; + while (p < pend) { + if (FL_TEST(p, FL_FINALIZE)) { + FL_UNSET(p, FL_FINALIZE); + run_final((VALUE)p); + } + p++; + } } - st_free_table(finalizer_table); + if (finalizer_table) { + st_free_table(finalizer_table); + finalizer_table = 0; + } } /* run data object's finalizers */ for (i = 0; i < heaps_used; i++) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/