[前][次][番号順一覧][スレッド一覧]

ruby-changes:46254

From: nobu <ko1@a...>
Date: Mon, 17 Apr 2017 11:08:45 +0900 (JST)
Subject: [ruby-changes:46254] nobu:r58379 (trunk): vm_insnhelper.c: rb_threadptr_stack_overflow

nobu	2017-04-17 11:08:41 +0900 (Mon, 17 Apr 2017)

  New Revision: 58379

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58379

  Log:
    vm_insnhelper.c: rb_threadptr_stack_overflow
    
    * vm_insnhelper.c (rb_threadptr_stack_overflow): move from
      thread.c and integrate with vm_stackoverflow.

  Modified files:
    trunk/signal.c
    trunk/thread.c
    trunk/vm_insnhelper.c
Index: thread.c
===================================================================
--- thread.c	(revision 58378)
+++ thread.c	(revision 58379)
@@ -2165,20 +2165,6 @@ rb_threadptr_signal_exit(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/thread.c#L2165
 #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)
 {
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 58378)
+++ vm_insnhelper.c	(revision 58379)
@@ -30,12 +30,40 @@ ruby_vm_special_exception_copy(VALUE exc https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L30
     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)
Index: signal.c
===================================================================
--- signal.c	(revision 58378)
+++ signal.c	(revision 58379)
@@ -761,7 +761,7 @@ static const char *received_signal; https://github.com/ruby/ruby/blob/trunk/signal.c#L761
 #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_ https://github.com/ruby/ruby/blob/trunk/signal.c#L792
 	rb_bug_errno(STRINGIZE(ruby_sigunmask)":unblock", errno);
     }
 #endif
-    ruby_thread_stack_overflow(th);
+    rb_threadptr_stack_overflow(th);
 }
 
 # ifdef USE_UCONTEXT_REG

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]