mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* gc.c (run_final): reduce unnecessary object allocation during
finalization. * gc.c (rb_gc_call_finalizer_at_exit): deferred finalizers list should be cleared before calling them. fixed: [ruby-talk:145790] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3adc6a6d3d
commit
c8b7f0cef9
2 changed files with 15 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
Sun Jun 19 14:09:07 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* gc.c (run_final): reduce unnecessary object allocation during
|
||||
finalization.
|
||||
|
||||
* gc.c (rb_gc_call_finalizer_at_exit): deferred finalizers list should
|
||||
be cleared before calling them. fixed: [ruby-talk:145790]
|
||||
|
||||
Sat Jun 18 01:15:36 2005 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* ext/readline/readline.c (readline_readline): do not set
|
||||
|
|
9
gc.c
9
gc.c
|
@ -1773,17 +1773,20 @@ run_final(obj)
|
|||
int status, critical_save = rb_thread_critical;
|
||||
VALUE args[3], table;
|
||||
|
||||
objid = rb_obj_id(obj); /* make obj into id */
|
||||
rb_thread_critical = Qtrue;
|
||||
args[1] = rb_ary_new3(1, rb_obj_id(obj)); /* make obj into id */
|
||||
args[1] = 0;
|
||||
args[2] = (VALUE)ruby_safe_level;
|
||||
for (i=0; i<RARRAY(finalizers)->len; i++) {
|
||||
args[0] = RARRAY(finalizers)->ptr[i];
|
||||
if (!args[1]) args[1] = rb_ary_new3(1, objid);
|
||||
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
|
||||
}
|
||||
if (finalizer_table && st_delete(finalizer_table, (st_data_t*)&obj, &table)) {
|
||||
for (i=0; i<RARRAY(table)->len; i++) {
|
||||
VALUE final = RARRAY(table)->ptr[i];
|
||||
args[0] = RARRAY(final)->ptr[1];
|
||||
if (!args[1]) args[1] = rb_ary_new3(1, objid);
|
||||
args[2] = FIX2INT(RARRAY(final)->ptr[0]);
|
||||
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
|
||||
}
|
||||
|
@ -1811,7 +1814,9 @@ rb_gc_call_finalizer_at_exit()
|
|||
|
||||
/* run finalizers */
|
||||
if (need_call_final) {
|
||||
finalize_list(deferred_final_list);
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue