diff options
-rw-r--r-- | thread.c | 25 | ||||
-rw-r--r-- | thread_pthread.c | 2 | ||||
-rw-r--r-- | vm.c | 19 |
3 files changed, 27 insertions, 19 deletions
@@ -714,22 +714,25 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s rb_thread_list_t *join_list; rb_thread_t *main_th; VALUE errinfo = Qnil; - size_t vm_stack_size = th->vm->default_params.thread_vm_stack_size; if (th == th->vm->main_thread) { rb_bug("thread_start_func_2 must not be used for main thread"); } - rb_ec_set_vm_stack(th->ec, alloca(vm_stack_size), vm_stack_size / sizeof(VALUE)); - th->ec->cfp = (void *)(th->ec->vm_stack + th->ec->vm_stack_size); + { + size_t size = th->vm->default_params.thread_vm_stack_size / sizeof(VALUE); + rb_ec_set_vm_stack(th->ec, alloca(size * sizeof(VALUE)), size); + + th->ec->cfp = (void *)(th->ec->vm_stack + th->ec->vm_stack_size); - rb_vm_push_frame(th->ec, - 0 /* dummy iseq */, - VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */, - Qnil /* dummy self */, VM_BLOCK_HANDLER_NONE /* dummy block ptr */, - 0 /* dummy cref/me */, - 0 /* dummy pc */, th->ec->vm_stack, 0, 0 - ); + rb_vm_push_frame(th->ec, + 0 /* dummy iseq */, + VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */, + Qnil /* dummy self */, VM_BLOCK_HANDLER_NONE /* dummy block ptr */, + 0 /* dummy cref/me */, + 0 /* dummy pc */, th->ec->vm_stack, 0, 0 + ); + } ruby_thread_set_native(th); @@ -817,7 +820,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s rb_threadptr_unlock_all_locking_mutexes(th); rb_check_deadlock(th->vm); - rb_fiber_close(th->ec->fiber_ptr); + // rb_fiber_close(th->ec->fiber_ptr); } thread_cleanup_func(th, FALSE); gvl_release(th->vm); diff --git a/thread_pthread.c b/thread_pthread.c index 515f13b1a5..5cbe9e041b 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1157,7 +1157,7 @@ native_thread_create(rb_thread_t *th) } else { pthread_attr_t attr; - const size_t stack_size = th->vm->default_params.thread_machine_stack_size; + const size_t stack_size = th->vm->default_params.thread_machine_stack_size + th->vm->default_params.thread_vm_stack_size; const size_t space = space_size(stack_size); th->ec->machine.stack_maxsize = stack_size - space; @@ -2625,7 +2625,7 @@ thread_free(void *ptr) rb_bug("thread_free: keeping_mutexes must be NULL (%p:%p)", (void *)th, (void *)th->keeping_mutexes); } - rb_threadptr_root_fiber_release(th); + //rb_threadptr_root_fiber_release(th); if (th->vm && th->vm->main_thread == th) { RUBY_GC_INFO("main thread\n"); @@ -2691,17 +2691,22 @@ th_init(rb_thread_t *th, VALUE self) th->self = self; rb_threadptr_root_fiber_setup(th); - // Initialize the main thread: if (self == 0) { size_t size = th->vm->default_params.thread_vm_stack_size / sizeof(VALUE); - VALUE * vm_stack = ALLOC_N(VALUE, size); - rb_ec_set_vm_stack(th->ec, vm_stack, size); + rb_ec_set_vm_stack(th->ec, ALLOC_N(VALUE, size), size); + th->ec->cfp = (void *)(th->ec->vm_stack + th->ec->vm_stack_size); - - vm_push_frame(th->ec, 0 /* dummy iseq */, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */, + + rb_vm_push_frame(th->ec, + 0 /* dummy iseq */, + VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */, Qnil /* dummy self */, VM_BLOCK_HANDLER_NONE /* dummy block ptr */, 0 /* dummy cref/me */, - 0 /* dummy pc */, th->ec->vm_stack, 0, 0); + 0 /* dummy pc */, th->ec->vm_stack, 0, 0 + ); + } else { + th->ec->cfp = NULL; + rb_ec_set_vm_stack(th->ec, NULL, 0); } th->status = THREAD_RUNNABLE; |