From 1de3e801c40e5a0121198ae08cd5b32dd92a42a2 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 10 Dec 2014 19:35:07 +0000 Subject: [PATCH] * vm_core.h: introduce new field rb_thread_t::local_storage_recursive_hash_for_trace to store recursive hash to avoid creating new recursive (nested) hashes for each trace events. [Bug #10511] * vm_trace.c (rb_threadptr_exec_event_hooks_orig): use it. * cont.c: catch up this fix. * vm.c (rb_thread_mark): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++++++++ cont.c | 3 +++ vm.c | 2 ++ vm_core.h | 1 + vm_trace.c | 4 +++- 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8c6f436832..ef60876f26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Dec 11 04:27:24 2014 Koichi Sasada + + * vm_core.h: introduce new field + rb_thread_t::local_storage_recursive_hash_for_trace to store + recursive hash to avoid creating new recursive (nested) hashes + for each trace events. + [Bug #10511] + + * vm_trace.c (rb_threadptr_exec_event_hooks_orig): use it. + + * cont.c: catch up this fix. + + * vm.c (rb_thread_mark): ditto. + Wed Dec 10 13:39:27 2014 Nobuyoshi Nakada * struct.c (define_aref_method, define_aset_method): use iseq diff --git a/cont.c b/cont.c index 035cfba71d..78ae0892b0 100644 --- a/cont.c +++ b/cont.c @@ -460,6 +460,7 @@ cont_init(rb_context_t *cont, rb_thread_t *th) cont->saved_thread.fiber = th->fiber; cont->saved_thread.local_storage = 0; cont->saved_thread.local_storage_recursive_hash = Qnil; + cont->saved_thread.local_storage_recursive_hash_for_trace = Qnil; } static rb_context_t * @@ -565,6 +566,7 @@ cont_restore_thread(rb_context_t *cont) th->stack_size = sth->stack_size; th->local_storage = sth->local_storage; th->local_storage_recursive_hash = sth->local_storage_recursive_hash; + th->local_storage_recursive_hash_for_trace = sth->local_storage_recursive_hash_for_trace; th->fiber = (rb_fiber_t*)cont; } @@ -1211,6 +1213,7 @@ fiber_init(VALUE fibval, VALUE proc) th->tag = 0; th->local_storage = st_init_numtable(); th->local_storage_recursive_hash = Qnil; + th->local_storage_recursive_hash_for_trace = Qnil; th->first_proc = proc; diff --git a/vm.c b/vm.c index c710263628..8551b0dc0e 100644 --- a/vm.c +++ b/vm.c @@ -2063,6 +2063,7 @@ rb_thread_mark(void *ptr) rb_mark_tbl(th->local_storage); RUBY_MARK_UNLESS_NULL(th->local_storage_recursive_hash); + RUBY_MARK_UNLESS_NULL(th->local_storage_recursive_hash_for_trace); if (GET_THREAD() != th && th->machine.stack_start && th->machine.stack_end) { rb_gc_mark_machine_stack(th); @@ -2197,6 +2198,7 @@ th_init(rb_thread_t *th, VALUE self) th->waiting_fd = -1; th->root_svar = Qnil; th->local_storage_recursive_hash = Qnil; + th->local_storage_recursive_hash_for_trace = Qnil; #ifdef NON_SCALAR_THREAD_ID th->thread_id_string[0] = '\0'; #endif diff --git a/vm_core.h b/vm_core.h index 95808809c5..9ab23b2087 100644 --- a/vm_core.h +++ b/vm_core.h @@ -691,6 +691,7 @@ typedef struct rb_thread_struct { /* storage */ st_table *local_storage; VALUE local_storage_recursive_hash; + VALUE local_storage_recursive_hash_for_trace; rb_thread_list_t *join_list; diff --git a/vm_trace.c b/vm_trace.c index 978850a00a..a11ee7789e 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -332,7 +332,7 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p) const VALUE old_recursive = th->local_storage_recursive_hash; int state = 0; - th->local_storage_recursive_hash = Qnil; + th->local_storage_recursive_hash = th->local_storage_recursive_hash_for_trace; th->state = 0; th->errinfo = Qnil; @@ -352,6 +352,8 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p) terminate: th->trace_arg = 0; th->vm->trace_running--; + + th->local_storage_recursive_hash_for_trace = th->local_storage_recursive_hash; th->local_storage_recursive_hash = old_recursive; if (state) {