From 8da1219d459a5d42c2814a1c50c451e3a2f5b63f Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 7 May 2018 06:59:55 +0000 Subject: 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- cont.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cont.c b/cont.c index 5171b28fb7..a748b4e098 100644 --- a/cont.c +++ b/cont.c @@ -1600,12 +1600,10 @@ fiber_store(rb_fiber_t *next_fib, rb_thread_t *th) #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 need_interrupt) 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 -- cgit v1.2.3