From 3ec2b843c8d393d26a6248788199f2daa7bbdcb0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 14 Jun 2011 12:57:50 +0000 Subject: * cont.c (cont_save_thread): add new utility function. rb_context_t::saved_thread.machine_stack_start and machine_stack_end should be cleared immediately after a snapshot of current thread is stored to saved_thread. this change aims to get rid of unnecessary GC mark at machine stack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- cont.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'cont.c') diff --git a/cont.c b/cont.c index 770cfeb1b4..15f33e85a9 100644 --- a/cont.c +++ b/cont.c @@ -366,11 +366,6 @@ cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont) MEMCPY(cont->machine_register_stack, cont->machine_register_stack_src, VALUE, size); #endif - - sth->machine_stack_start = sth->machine_stack_end = 0; -#ifdef __ia64 - sth->machine_register_stack_start = sth->machine_register_stack_end = 0; -#endif } static const rb_data_type_t cont_data_type = { @@ -379,12 +374,26 @@ static const rb_data_type_t cont_data_type = { }; static void -cont_init(rb_context_t *cont, rb_thread_t *th) +cont_save_thread(rb_context_t *cont, rb_thread_t *th) { /* save thread context */ cont->saved_thread = *th; + /* saved_thread->machine_stack_(start|end) should be NULL */ + /* because it may happen GC afterward */ + cont->saved_thread.machine_stack_start = 0; + cont->saved_thread.machine_stack_end = 0; +#ifdef __ia64 + cont->saved_thread.machine_register_stack_start = 0 + cont->saved_thread.machine_register_stack_end = 0 +#endif +} + +static void +cont_init(rb_context_t *cont, rb_thread_t *th) +{ + /* save thread context */ + cont_save_thread(cont, th); cont->saved_thread.local_storage = 0; - cont->saved_thread.machine_stack_start = cont->saved_thread.machine_stack_end = 0; } static rb_context_t * @@ -1006,9 +1015,6 @@ fiber_init(VALUE fibval, VALUE proc) fiber_link_join(fib); - /*cont->machine_stack, th->machine_stack_start and th->machine_stack_end should be NULL*/ - /*because it may happen GC at th->stack allocation*/ - th->machine_stack_start = th->machine_stack_end = 0; th->stack_size = FIBER_VM_STACK_SIZE; th->stack = ALLOC_N(VALUE, th->stack_size); @@ -1175,7 +1181,7 @@ fiber_store(rb_fiber_t *next_fib) if (th->fiber) { GetFiberPtr(th->fiber, fib); - fib->cont.saved_thread = *th; + cont_save_thread(&fib->cont, th); } else { /* create current fiber */ -- cgit v1.2.3