ruby-changes:36684
From: ko1 <ko1@a...>
Date: Thu, 11 Dec 2014 04:35:21 +0900 (JST)
Subject: [ruby-changes:36684] ko1:r48765 (trunk): * vm_core.h: introduce new field
ko1 2014-12-11 04:35:07 +0900 (Thu, 11 Dec 2014) New Revision: 48765 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48765 Log: * 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. Modified files: trunk/ChangeLog trunk/cont.c trunk/vm.c trunk/vm_core.h trunk/vm_trace.c Index: ChangeLog =================================================================== --- ChangeLog (revision 48764) +++ ChangeLog (revision 48765) @@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Dec 11 04:27:24 2014 Koichi Sasada <ko1@a...> + + * 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 <nobu@r...> * struct.c (define_aref_method, define_aset_method): use iseq Index: vm_core.h =================================================================== --- vm_core.h (revision 48764) +++ vm_core.h (revision 48765) @@ -691,6 +691,7 @@ typedef struct rb_thread_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L691 /* storage */ st_table *local_storage; VALUE local_storage_recursive_hash; + VALUE local_storage_recursive_hash_for_trace; rb_thread_list_t *join_list; Index: vm_trace.c =================================================================== --- vm_trace.c (revision 48764) +++ vm_trace.c (revision 48765) @@ -332,7 +332,7 @@ rb_threadptr_exec_event_hooks_orig(rb_tr https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L332 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_tr https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L352 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) { Index: cont.c =================================================================== --- cont.c (revision 48764) +++ cont.c (revision 48765) @@ -460,6 +460,7 @@ cont_init(rb_context_t *cont, rb_thread_ https://github.com/ruby/ruby/blob/trunk/cont.c#L460 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) https://github.com/ruby/ruby/blob/trunk/cont.c#L566 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) https://github.com/ruby/ruby/blob/trunk/cont.c#L1213 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; Index: vm.c =================================================================== --- vm.c (revision 48764) +++ vm.c (revision 48765) @@ -2063,6 +2063,7 @@ rb_thread_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2063 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) https://github.com/ruby/ruby/blob/trunk/vm.c#L2198 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/