aboutsummaryrefslogtreecommitdiffstats
path: root/vm.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-04 14:37:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-04 14:37:07 +0000
commitb0b09327293b2996f86990be354f3a63e255e77e (patch)
tree102fdc5902f973f5ea68075bedca9b89225da423 /vm.c
parente6edab6f7e80f548389641cce801b664c8f1bfa7 (diff)
downloadruby-b0b09327293b2996f86990be354f3a63e255e77e.tar.gz
at_exit list
* vm_core.h (rb_vm_struct): make at_exit a single linked list but not RArray, not to mark the registered functions by the write barrier. based on the patches by Evan Phoenix. [ruby-core:73908] [Bug #12095] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/vm.c b/vm.c
index a518e950cb..64081b49e5 100644
--- a/vm.c
+++ b/vm.c
@@ -468,20 +468,25 @@ rb_frame_pop(void)
void
ruby_vm_at_exit(void (*func)(rb_vm_t *))
{
- rb_ary_push((VALUE)&GET_VM()->at_exit, (VALUE)func);
+ rb_vm_t *vm = GET_VM();
+ rb_at_exit_list *nl = ALLOC(rb_at_exit_list);
+ nl->func = func;
+ nl->next = vm->at_exit;
+ vm->at_exit = nl;
}
static void
ruby_vm_run_at_exit_hooks(rb_vm_t *vm)
{
- VALUE hook = (VALUE)&vm->at_exit;
+ rb_at_exit_list *l = vm->at_exit;
- while (RARRAY_LEN(hook) > 0) {
- typedef void rb_vm_at_exit_func(rb_vm_t*);
- rb_vm_at_exit_func *func = (rb_vm_at_exit_func*)rb_ary_pop(hook);
+ while (l) {
+ rb_at_exit_list* t = l->next;
+ rb_vm_at_exit_func *func = l->func;
+ free(l);
+ l = t;
(*func)(vm);
}
- rb_ary_free(hook);
}
/* Env */
@@ -2172,8 +2177,6 @@ vm_init2(rb_vm_t *vm)
MEMZERO(vm, rb_vm_t, 1);
rb_vm_living_threads_init(vm);
vm->src_encoding_index = -1;
- vm->at_exit.basic.flags = (T_ARRAY | RARRAY_EMBED_FLAG) & ~RARRAY_EMBED_LEN_MASK; /* len set 0 */
- rb_obj_hide((VALUE)&vm->at_exit);
vm_default_params_setup(vm);
}