From 157401a9a1c921ebd5c77e23cd10fd90c1d3e26f Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 18 Apr 2016 08:15:33 +0000 Subject: merge revision(s) 54484: [Backport #12095] * 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/branches/ruby_2_3@54633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 58ed56b993..92e61fa632 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 */ @@ -2170,8 +2175,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); } -- cgit v1.2.3