summaryrefslogtreecommitdiff
path: root/cont.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-07 06:59:55 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-07 06:59:55 (GMT)
commit8da1219d459a5d42c2814a1c50c451e3a2f5b63f (patch)
tree18c2bdbf896a19bd19ab1327271434c2c4b84bb1 /cont.c
parentfb2acec9439a023396cca3245d4dabb12a78f1da (diff)
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
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/cont.c b/cont.c
index 5171b28..a748b4e 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