summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-20 21:38:27 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-20 21:38:27 +0000
commit475b4aa40b6cf83e57176a063d368d55bf779e7c (patch)
tree569c6a6db871c4e762b293038ed456afbcf36c1c /vm.c
parente72a86fc9373e4477b6e275735fecdf4eac9944a (diff)
simplify altstack and enable reuse with thread cache
Instead of allocating and registering the altstack in different places, do it together to reduce code and improve readability. When thread cache is enabled, storing altstack in rb_thread_t is wasteful and we may reuse altstack in the same pthread. This also lets us clearly allow use of xmalloc to allow GC to recover from ENOMEM. [ruby-core:85621] [Feature #14487] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/vm.c b/vm.c
index 1a57f2c6d1..dd67062ee5 100644
--- a/vm.c
+++ b/vm.c
@@ -2216,6 +2216,7 @@ ruby_vm_destruct(rb_vm_t *vm)
vm->frozen_strings = 0;
}
rb_vm_gvl_destroy(vm);
+ RB_ALTSTACK_FREE(vm->main_altstack);
if (objspace) {
rb_objspace_free(objspace);
}
@@ -2473,9 +2474,6 @@ thread_free(void *ptr)
RUBY_GC_INFO("main thread\n");
}
else {
-#ifdef USE_SIGALTSTACK
- free(th->altstack);
-#endif
ruby_xfree(ptr);
}
@@ -2535,11 +2533,6 @@ th_init(rb_thread_t *th, VALUE self)
th->self = self;
rb_threadptr_root_fiber_setup(th);
- /* allocate thread stack */
-#ifdef USE_SIGALTSTACK
- /* altstack of main thread is reallocated in another place */
- th->altstack = malloc(rb_sigaltstack_size());
-#endif
{
/* vm_stack_size is word number.
* th->vm->default_params.thread_vm_stack_size is byte size. */