diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-17 02:08:41 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-17 02:08:41 +0000 |
commit | e97ac02f8466275732a33f704480c03da722f485 (patch) | |
tree | a39fb1712d7a18a31963649e24f36d5f32128e8a | |
parent | 158c742b51556ff416d2934fcb215ef77e7d0c7e (diff) |
vm_insnhelper.c: rb_threadptr_stack_overflow
* vm_insnhelper.c (rb_threadptr_stack_overflow): move from
thread.c and integrate with vm_stackoverflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | signal.c | 4 | ||||
-rw-r--r-- | thread.c | 14 | ||||
-rw-r--r-- | vm_insnhelper.c | 30 |
3 files changed, 31 insertions, 17 deletions
@@ -761,7 +761,7 @@ static const char *received_signal; #endif #if defined(USE_SIGALTSTACK) || defined(_WIN32) -NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); +NORETURN(void rb_threadptr_stack_overflow(rb_thread_t *th)); # if defined __HAIKU__ # define USE_UCONTEXT_REG 1 # elif !(defined(HAVE_UCONTEXT_H) && (defined __i386__ || defined __x86_64__ || defined __amd64__)) @@ -792,7 +792,7 @@ raise_stack_overflow(int sig, rb_thread_t *th) rb_bug_errno(STRINGIZE(ruby_sigunmask)":unblock", errno); } #endif - ruby_thread_stack_overflow(th); + rb_threadptr_stack_overflow(th); } # ifdef USE_UCONTEXT_REG @@ -2165,20 +2165,6 @@ rb_threadptr_signal_exit(rb_thread_t *th) #define USE_SIGALTSTACK #endif -NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); -void -ruby_thread_stack_overflow(rb_thread_t *th) -{ - th->raised_flag = 0; -#ifdef USE_SIGALTSTACK - if (!rb_threadptr_during_gc(th)) { - rb_exc_raise(sysstack_error); - } -#endif - th->errinfo = sysstack_error; - TH_JUMP_TAG(th, TAG_RAISE); -} - int rb_threadptr_set_raised(rb_thread_t *th) { diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 6006b5d579..fd259fd428 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -30,12 +30,40 @@ ruby_vm_special_exception_copy(VALUE exc) return e; } +NORETURN(static void threadptr_stack_overflow(rb_thread_t *, int)); +static void +threadptr_stack_overflow(rb_thread_t *th, int setup) +{ + VALUE mesg = th->vm->special_exceptions[ruby_error_sysstack]; + th->raised_flag = 0; + if (setup) { + VALUE at = rb_threadptr_backtrace_object(th); + mesg = ruby_vm_special_exception_copy(mesg); + rb_ivar_set(mesg, idBt, at); + rb_ivar_set(mesg, idBt_locations, at); + } + th->errinfo = mesg; + TH_JUMP_TAG(th, TAG_RAISE); +} + static void vm_stackoverflow(void) { - rb_exc_raise(ruby_vm_special_exception_copy(sysstack_error)); + threadptr_stack_overflow(GET_THREAD(), TRUE); +} + +NORETURN(void rb_threadptr_stack_overflow(rb_thread_t *th)); +void +rb_threadptr_stack_overflow(rb_thread_t *th) +{ +#ifdef USE_SIGALTSTACK + threadptr_stack_overflow(th, !rb_threadptr_during_gc(th)); +#else + threadptr_stack_overflow(th, FALSE); +#endif } + #if VM_CHECK_MODE > 0 static int callable_class_p(VALUE klass) |