From b78faa9b1e189ef87cb4614915d147febb71f98e Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 6 Sep 2017 02:46:59 +0000 Subject: rb_execution_context_mark. * vm.c (rb_execution_context_mark): separate from thread_mark(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/vm.c b/vm.c index 0bf3707f3a..3719ab8e9a 100644 --- a/vm.c +++ b/vm.c @@ -2365,18 +2365,15 @@ rb_thread_recycle_stack_release(VALUE *stack) void rb_fiber_mark_self(rb_fiber_t *fib); -void -rb_thread_mark(void *ptr) +static void +rb_execution_context_mark(const rb_execution_context_t *ec) { - rb_thread_t *th = ptr; - RUBY_MARK_ENTER("thread"); - /* mark VM stack */ - if (th->ec.vm_stack) { - VALUE *p = th->ec.vm_stack; - VALUE *sp = th->ec.cfp->sp; - rb_control_frame_t *cfp = th->ec.cfp; - rb_control_frame_t *limit_cfp = (void *)(th->ec.vm_stack + th->ec.vm_stack_size); + if (ec->vm_stack) { + VALUE *p = ec->vm_stack; + VALUE *sp = ec->cfp->sp; + rb_control_frame_t *cfp = ec->cfp; + rb_control_frame_t *limit_cfp = (void *)(ec->vm_stack + ec->vm_stack_size); rb_gc_mark_values((long)(sp - p), p); @@ -2393,6 +2390,21 @@ rb_thread_mark(void *ptr) } } + RUBY_MARK_UNLESS_NULL(ec->errinfo); + RUBY_MARK_UNLESS_NULL(ec->root_svar); + rb_mark_tbl(ec->local_storage); + RUBY_MARK_UNLESS_NULL(ec->local_storage_recursive_hash); + RUBY_MARK_UNLESS_NULL(ec->local_storage_recursive_hash_for_trace); +} + +void +rb_thread_mark(void *ptr) +{ + rb_thread_t *th = ptr; + RUBY_MARK_ENTER("thread"); + + rb_execution_context_mark(&th->ec); + /* mark machine stack */ if (GET_THREAD() != th && th->machine.stack_start && th->machine.stack_end) { rb_gc_mark_machine_stack(th); @@ -2407,25 +2419,16 @@ rb_thread_mark(void *ptr) RUBY_MARK_UNLESS_NULL(th->thgroup); RUBY_MARK_UNLESS_NULL(th->value); - RUBY_MARK_UNLESS_NULL(th->ec.errinfo); RUBY_MARK_UNLESS_NULL(th->pending_interrupt_queue); RUBY_MARK_UNLESS_NULL(th->pending_interrupt_mask_stack); - RUBY_MARK_UNLESS_NULL(th->ec.root_svar); RUBY_MARK_UNLESS_NULL(th->top_self); RUBY_MARK_UNLESS_NULL(th->top_wrapper); rb_fiber_mark_self(th->fiber); rb_fiber_mark_self(th->root_fiber); RUBY_MARK_UNLESS_NULL(th->stat_insn_usage); RUBY_MARK_UNLESS_NULL(th->last_status); - RUBY_MARK_UNLESS_NULL(th->locking_mutex); - - rb_mark_tbl(th->ec.local_storage); - RUBY_MARK_UNLESS_NULL(th->ec.local_storage_recursive_hash); - RUBY_MARK_UNLESS_NULL(th->ec.local_storage_recursive_hash_for_trace); - RUBY_MARK_UNLESS_NULL(th->name); - rb_vm_trace_mark_event_hooks(&th->event_hooks); RUBY_MARK_LEAVE("thread"); -- cgit v1.2.3