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

ruby-changes:48350

From: ko1 <ko1@a...>
Date: Fri, 27 Oct 2017 10:13:44 +0900 (JST)
Subject: [ruby-changes:48350] ko1:r60464 (trunk): refactoring (rb_|)threadptr_stack_overflow.

ko1	2017-10-27 10:13:35 +0900 (Fri, 27 Oct 2017)

  New Revision: 60464

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

  Log:
    refactoring (rb_|)threadptr_stack_overflow.
    
    * vm_insnhelper.c (ec_stack_overflow): renamed from threadptr_stack_overflow
      and also rb_ec_stack_overflow is from rb_threadptr_stack_overflow
      because they accept `ec` instead of `th`.

  Modified files:
    trunk/signal.c
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
Index: signal.c
===================================================================
--- signal.c	(revision 60463)
+++ signal.c	(revision 60464)
@@ -759,7 +759,7 @@ static const char *received_signal; https://github.com/ruby/ruby/blob/trunk/signal.c#L759
 #endif
 
 #if defined(USE_SIGALTSTACK) || defined(_WIN32)
-NORETURN(void rb_threadptr_stack_overflow(rb_thread_t *th, int crit));
+NORETURN(void rb_ec_stack_overflow(rb_execution_context_t *ec, int crit));
 # if defined __HAIKU__
 #   define USE_UCONTEXT_REG 1
 # elif !(defined(HAVE_UCONTEXT_H) && (defined __i386__ || defined __x86_64__ || defined __amd64__))
@@ -838,17 +838,17 @@ check_stack_overflow(int sig, const uint https://github.com/ruby/ruby/blob/trunk/signal.c#L838
      * the fault page can be the next. */
     if (sp_page == fault_page || sp_page == fault_page + 1 ||
 	sp_page <= fault_page && fault_page <= bp_page) {
-	rb_thread_t *th = ruby_current_thread();
+	rb_execution_context_t *ec = GET_EC();
 	int crit = FALSE;
-	if ((uintptr_t)th->ec->tag->buf / pagesize <= fault_page + 1) {
+	if ((uintptr_t)ec->tag->buf / pagesize <= fault_page + 1) {
 	    /* drop the last tag if it is close to the fault,
 	     * otherwise it can cause stack overflow again at the same
 	     * place. */
-	    th->ec->tag = th->ec->tag->prev;
+	    ec->tag = ec->tag->prev;
 	    crit = TRUE;
 	}
 	reset_sigmask(sig);
-	rb_threadptr_stack_overflow(th, crit);
+	rb_ec_stack_overflow(ec, crit);
     }
 }
 # else
@@ -856,10 +856,10 @@ static void https://github.com/ruby/ruby/blob/trunk/signal.c#L856
 check_stack_overflow(int sig, const void *addr)
 {
     int ruby_stack_overflowed_p(const rb_thread_t *, const void *);
-    rb_thread_t *th = GET_THREAD();
-    if (ruby_stack_overflowed_p(th, addr)) {
+    rb_execution_context_t *ec = GET_EC();
+    if (ruby_stack_overflowed_p(ec, addr)) {
 	reset_sigmask(sig);
-	rb_threadptr_stack_overflow(th, FALSE);
+	rb_ec_stack_overflow(ec, FALSE);
     }
 }
 # endif
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 60463)
+++ vm_insnhelper.c	(revision 60464)
@@ -30,41 +30,41 @@ 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));
+NORETURN(static void ec_stack_overflow(rb_execution_context_t *ec, int));
 static void
-threadptr_stack_overflow(rb_thread_t *th, int setup)
+ec_stack_overflow(rb_execution_context_t *ec, int setup)
 {
-    VALUE mesg = th->vm->special_exceptions[ruby_error_sysstack];
-    th->ec->raised_flag = RAISED_STACKOVERFLOW;
+    VALUE mesg = rb_ec_vm_ptr(ec)->special_exceptions[ruby_error_sysstack];
+    ec->raised_flag = RAISED_STACKOVERFLOW;
     if (setup) {
-	VALUE at = rb_threadptr_backtrace_object(th);
+	VALUE at = rb_threadptr_backtrace_object(rb_ec_thread_ptr(ec));
 	mesg = ruby_vm_special_exception_copy(mesg);
 	rb_ivar_set(mesg, idBt, at);
 	rb_ivar_set(mesg, idBt_locations, at);
     }
-    th->ec->errinfo = mesg;
-    EC_JUMP_TAG(th->ec, TAG_RAISE);
+    ec->errinfo = mesg;
+    EC_JUMP_TAG(ec, TAG_RAISE);
 }
 
 static void
 vm_stackoverflow(void)
 {
-    threadptr_stack_overflow(GET_THREAD(), TRUE);
+    ec_stack_overflow(GET_EC(), TRUE);
 }
 
-NORETURN(void rb_threadptr_stack_overflow(rb_thread_t *th, int crit));
+NORETURN(void rb_ec_stack_overflow(rb_execution_context_t *ec, int crit));
 void
-rb_threadptr_stack_overflow(rb_thread_t *th, int crit)
+rb_ec_stack_overflow(rb_execution_context_t *ec, int crit)
 {
     if (crit || rb_during_gc()) {
-	th->ec->raised_flag = RAISED_STACKOVERFLOW;
-	th->ec->errinfo = th->vm->special_exceptions[ruby_error_stackfatal];
-	EC_JUMP_TAG(th->ec, TAG_RAISE);
+	ec->raised_flag = RAISED_STACKOVERFLOW;
+	ec->errinfo = rb_ec_vm_ptr(ec)->special_exceptions[ruby_error_stackfatal];
+	EC_JUMP_TAG(ec, TAG_RAISE);
     }
 #ifdef USE_SIGALTSTACK
-    threadptr_stack_overflow(th, TRUE);
+    ec_stack_overflow(ec, TRUE);
 #else
-    threadptr_stack_overflow(th, FALSE);
+    ec_stack_overflow(ec, FALSE);
 #endif
 }
 
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 60463)
+++ vm_eval.c	(revision 60464)
@@ -258,7 +258,7 @@ stack_check(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L258
     if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW) &&
 	rb_threadptr_stack_check(th)) {
 	rb_thread_raised_set(th, RAISED_STACKOVERFLOW);
-	rb_threadptr_stack_overflow(th, FALSE);
+	rb_ec_stack_overflow(th->ec, FALSE);
     }
 }
 

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

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