ruby-changes:51138
From: nobu <ko1@a...>
Date: Mon, 7 May 2018 16:00:03 +0900 (JST)
Subject: [ruby-changes:51138] nobu:r63344 (trunk): cont.c: machine stack cache condition
nobu 2018-05-07 15:59:55 +0900 (Mon, 07 May 2018) New Revision: 63344 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63344 Log: cont.c: machine stack cache condition * cont.c (fiber_store, rb_fiber_terminate): separate the condition to cache machine stacks, which is not directly restricted to the platforms, and may be used on Windows too in the future. Modified files: trunk/cont.c Index: cont.c =================================================================== --- cont.c (revision 63343) +++ cont.c (revision 63344) @@ -1600,12 +1600,10 @@ fiber_store(rb_fiber_t *next_fib, rb_thr https://github.com/ruby/ruby/blob/trunk/cont.c#L1600 #if FIBER_USE_NATIVE fiber_setcontext(next_fib, fib); /* restored */ -#ifndef _WIN32 +#ifdef MAX_MACHINE_STACK_CACHE if (terminated_machine_stack.ptr) { if (machine_stack_cache_index < MAX_MACHINE_STACK_CACHE) { - machine_stack_cache[machine_stack_cache_index].ptr = terminated_machine_stack.ptr; - machine_stack_cache[machine_stack_cache_index].size = terminated_machine_stack.size; - machine_stack_cache_index++; + machine_stack_cache[machine_stack_cache_index++] = terminated_machine_stack; } else { if (terminated_machine_stack.ptr != fib->cont.machine.stack) { @@ -1743,11 +1741,13 @@ rb_fiber_terminate(rb_fiber_t *fib, int https://github.com/ruby/ruby/blob/trunk/cont.c#L1741 rb_fiber_close(fib); #if FIBER_USE_NATIVE && !defined(_WIN32) + fib->context.uc_stack.ss_sp = NULL; +#endif +#ifdef MAX_MACHINE_STACK_CACHE /* Ruby must not switch to other thread until storing terminated_machine_stack */ terminated_machine_stack.ptr = fib->ss_sp; terminated_machine_stack.size = fib->ss_size / sizeof(VALUE); fib->ss_sp = NULL; - fib->context.uc_stack.ss_sp = NULL; fib->cont.machine.stack = NULL; fib->cont.machine.stack_size = 0; #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/