summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-06-06 11:04:24 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-06-19 20:39:10 +1200
commit561c9bcf3a1ce33e51c2c03e88aa3103d42f5af9 (patch)
treea7e903a1d0f7b614e0aab9e4d06face0d4c1345a /thread.c
parent7cc7269b3d3e3aff518a6cd05971422351253957 (diff)
Make sure `alloca` fast path is used (inline assembler).
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index bc2e6c58fb..758b6faf03 100644
--- a/thread.c
+++ b/thread.c
@@ -77,6 +77,11 @@
#include "mjit.h"
#include "hrtime.h"
+#ifdef __linux__
+// Normally, gcc(1) translates calls to alloca() with inlined code. This is not done when either the -ansi, -std=c89, -std=c99, or the -std=c11 option is given and the header <alloca.h> is not included.
+#include <alloca.h>
+#endif
+
#ifndef USE_NATIVE_THREAD_PRIORITY
#define USE_NATIVE_THREAD_PRIORITY 0
#define RUBY_THREAD_PRIORITY_MAX 3
@@ -714,8 +719,8 @@ 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;
- VALUE * vm_stack = NULL;
size_t size = th->vm->default_params.thread_vm_stack_size / sizeof(VALUE);
+ VALUE * vm_stack = NULL;
if (th == th->vm->main_thread) {
rb_bug("thread_start_func_2 must not be used for main thread");
@@ -723,7 +728,6 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
vm_stack = alloca(size * sizeof(VALUE));
rb_ec_set_vm_stack(th->ec, vm_stack, size);
-
th->ec->cfp = (void *)(th->ec->vm_stack + th->ec->vm_stack_size);
rb_vm_push_frame(th->ec,