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

ruby-changes:48561

From: ko1 <ko1@a...>
Date: Tue, 7 Nov 2017 13:01:18 +0900 (JST)
Subject: [ruby-changes:48561] ko1:r60676 (trunk): th->ec: rb_threadptr_reset_raised()

ko1	2017-11-07 13:01:13 +0900 (Tue, 07 Nov 2017)

  New Revision: 60676

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

  Log:
    th->ec: rb_threadptr_reset_raised()
    
    * thread.c (rb_threadptr_reset_raised): rename to `rb_ec_reset_raised`
      and accepts `ec`.
    
    * vm_trace.c: the following functions accept `ec` instead of `th`
      * exec_hooks_body
      * exec_hooks_precheck
      * exec_hooks_unprotected
      * exec_hooks_protected

  Modified files:
    trunk/eval.c
    trunk/eval_error.c
    trunk/eval_intern.h
    trunk/thread.c
    trunk/vm_trace.c
Index: thread.c
===================================================================
--- thread.c	(revision 60675)
+++ thread.c	(revision 60676)
@@ -2177,12 +2177,12 @@ rb_threadptr_set_raised(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/thread.c#L2177
 }
 
 int
-rb_threadptr_reset_raised(rb_thread_t *th)
+rb_ec_reset_raised(rb_execution_context_t *ec)
 {
-    if (!(th->ec->raised_flag & RAISED_EXCEPTION)) {
+    if (!(ec->raised_flag & RAISED_EXCEPTION)) {
 	return 0;
     }
-    th->ec->raised_flag &= ~RAISED_EXCEPTION;
+    ec->raised_flag &= ~RAISED_EXCEPTION;
     return 1;
 }
 
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 60675)
+++ eval_error.c	(revision 60676)
@@ -324,6 +324,6 @@ error_handle(int ex) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L324
 	unknown_longjmp_status(ex);
 	break;
     }
-    rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
+    rb_ec_reset_raised(ec);
     return status;
 }
Index: vm_trace.c
===================================================================
--- vm_trace.c	(revision 60675)
+++ vm_trace.c	(revision 60676)
@@ -238,7 +238,7 @@ clean_hooks(rb_hook_list_t *list) https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L238
 }
 
 static void
-exec_hooks_body(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
+exec_hooks_body(const rb_execution_context_t *ec, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
 {
     rb_event_hook_t *hook;
 
@@ -255,10 +255,10 @@ exec_hooks_body(rb_thread_t *th, rb_hook https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L255
 }
 
 static int
-exec_hooks_precheck(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
+exec_hooks_precheck(const rb_execution_context_t *ec, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
 {
     if (UNLIKELY(list->need_clean != FALSE)) {
-	if (th->vm->trace_running <= 1) { /* only running this hooks */
+	if (rb_ec_vm_ptr(ec)->trace_running <= 1) { /* only running this hooks */
 	    clean_hooks(list);
 	}
     }
@@ -267,32 +267,32 @@ exec_hooks_precheck(rb_thread_t *th, rb_ https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L267
 }
 
 static void
-exec_hooks_unprotected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
+exec_hooks_unprotected(const rb_execution_context_t *ec, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
 {
-    if (exec_hooks_precheck(th, list, trace_arg) == 0) return;
-    exec_hooks_body(th, list, trace_arg);
+    if (exec_hooks_precheck(ec, list, trace_arg) == 0) return;
+    exec_hooks_body(ec, list, trace_arg);
 }
 
 static int
-exec_hooks_protected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
+exec_hooks_protected(rb_execution_context_t *ec, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
 {
     enum ruby_tag_type state;
     volatile int raised;
 
-    if (exec_hooks_precheck(th, list, trace_arg) == 0) return 0;
+    if (exec_hooks_precheck(ec, list, trace_arg) == 0) return 0;
 
-    raised = rb_threadptr_reset_raised(th);
+    raised = rb_ec_reset_raised(ec);
 
     /* TODO: Support !RUBY_EVENT_HOOK_FLAG_SAFE hooks */
 
-    EC_PUSH_TAG(th->ec);
+    EC_PUSH_TAG(ec);
     if ((state = EC_EXEC_TAG()) == TAG_NONE) {
-	exec_hooks_body(th, list, trace_arg);
+	exec_hooks_body(ec, list, trace_arg);
     }
     EC_POP_TAG();
 
     if (raised) {
-	rb_threadptr_set_raised(th);
+	rb_threadptr_set_raised(rb_ec_thread_ptr(ec));
     }
 
     return state;
@@ -302,8 +302,8 @@ static void https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L302
 rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
 {
     rb_execution_context_t *ec = trace_arg->ec;
-    rb_thread_t *th = rb_ec_thread_ptr(ec);
-    rb_vm_t *vm = th->vm;
+    rb_vm_t *vm = rb_ec_vm_ptr(ec);
+    rb_hook_list_t *th_event_hooks = &rb_ec_thread_ptr(ec)->event_hooks;
 
     if (trace_arg->event & RUBY_INTERNAL_EVENT_MASK) {
 	if (ec->trace_arg && (ec->trace_arg->event & RUBY_INTERNAL_EVENT_MASK)) {
@@ -313,8 +313,8 @@ rb_threadptr_exec_event_hooks_orig(rb_tr https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L313
 	    rb_trace_arg_t *prev_trace_arg = ec->trace_arg;
 	    vm->trace_running++;
 	    ec->trace_arg = trace_arg;
-	    exec_hooks_unprotected(th, &th->event_hooks, trace_arg);
-	    exec_hooks_unprotected(th, &vm->event_hooks, trace_arg);
+	    exec_hooks_unprotected(ec, th_event_hooks, trace_arg);
+	    exec_hooks_unprotected(ec, &vm->event_hooks, trace_arg);
 	    ec->trace_arg = prev_trace_arg;
 	    vm->trace_running--;
 	}
@@ -333,11 +333,11 @@ rb_threadptr_exec_event_hooks_orig(rb_tr https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L333
 	    ec->trace_arg = trace_arg;
 	    {
 		/* thread local traces */
-		state = exec_hooks_protected(th, &th->event_hooks, trace_arg);
+		state = exec_hooks_protected(ec, th_event_hooks, trace_arg);
 		if (state) goto terminate;
 
 		/* vm global traces */
-		state = exec_hooks_protected(th, &vm->event_hooks, trace_arg);
+		state = exec_hooks_protected(ec, &vm->event_hooks, trace_arg);
 		if (state) goto terminate;
 
 		ec->errinfo = errinfo;
@@ -379,35 +379,35 @@ rb_suppress_tracing(VALUE (*func)(VALUE) https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L379
 {
     volatile int raised;
     VALUE result = Qnil;
-    rb_thread_t *volatile th = GET_THREAD();
+    rb_execution_context_t *ec = GET_EC();
     enum ruby_tag_type state;
-    const int volatile tracing = th->ec->trace_arg ? 1 : 0;
+    const int volatile tracing = ec->trace_arg ? 1 : 0;
     rb_trace_arg_t dummy_trace_arg;
     dummy_trace_arg.event = 0;
 
-    if (!tracing) th->vm->trace_running++;
-    if (!th->ec->trace_arg) th->ec->trace_arg = &dummy_trace_arg;
+    if (!tracing) rb_ec_vm_ptr(ec)->trace_running++;
+    if (!ec->trace_arg) ec->trace_arg = &dummy_trace_arg;
 
-    raised = rb_threadptr_reset_raised(th);
+    raised = rb_ec_reset_raised(ec);
 
-    EC_PUSH_TAG(th->ec);
+    EC_PUSH_TAG(ec);
     if ((state = EC_EXEC_TAG()) == TAG_NONE) {
 	result = (*func)(arg);
     }
     EC_POP_TAG();
 
     if (raised) {
-	rb_threadptr_set_raised(th);
+	rb_ec_reset_raised(ec);
     }
 
-    if (th->ec->trace_arg == &dummy_trace_arg) th->ec->trace_arg = 0;
-    if (!tracing) th->vm->trace_running--;
+    if (ec->trace_arg == &dummy_trace_arg) ec->trace_arg = NULL;
+    if (!tracing) rb_ec_vm_ptr(ec)->trace_running--;
 
     if (state) {
 #if defined RUBY_USE_SETJMPEX && RUBY_USE_SETJMPEX
 	RB_GC_GUARD(result);
 #endif
-	EC_JUMP_TAG(th->ec, state);
+	EC_JUMP_TAG(ec, state);
     }
 
     return result;
Index: eval_intern.h
===================================================================
--- eval_intern.h	(revision 60675)
+++ eval_intern.h	(revision 60676)
@@ -281,11 +281,11 @@ enum { https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L281
     RAISED_NOMEMORY = 4
 };
 int rb_threadptr_set_raised(rb_thread_t *th);
-int rb_threadptr_reset_raised(rb_thread_t *th);
 #define rb_thread_raised_set(th, f)   ((th)->ec->raised_flag |= (f))
 #define rb_thread_raised_reset(th, f) ((th)->ec->raised_flag &= ~(f))
 #define rb_thread_raised_p(th, f)     (((th)->ec->raised_flag & (f)) != 0)
 #define rb_thread_raised_clear(th)    ((th)->ec->raised_flag = 0)
+int rb_ec_reset_raised(rb_execution_context_t *th);
 int rb_ec_stack_check(rb_execution_context_t *ec);
 
 VALUE rb_f_eval(int argc, const VALUE *argv, VALUE self);
Index: eval.c
===================================================================
--- eval.c	(revision 60675)
+++ eval.c	(revision 60676)
@@ -524,7 +524,7 @@ setup_exception(rb_execution_context_t * https://github.com/ruby/ruby/blob/trunk/eval.c#L524
 		rb_ivar_set(mesg, idBt_locations, at);
 		set_backtrace(mesg, at);
 	    }
-	    rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
+	    rb_ec_reset_raised(ec);
 	}
 	EC_POP_TAG();
 	if (state) goto fatal;
@@ -563,7 +563,7 @@ setup_exception(rb_execution_context_t * https://github.com/ruby/ruby/blob/trunk/eval.c#L563
 	    ec->errinfo = mesg;
 	}
 	else if (state) {
-	    rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
+	    rb_ec_reset_raised(ec);
 	    EC_JUMP_TAG(ec, state);
 	}
     }
@@ -571,7 +571,7 @@ setup_exception(rb_execution_context_t * https://github.com/ruby/ruby/blob/trunk/eval.c#L571
     if (rb_threadptr_set_raised(rb_ec_thread_ptr(ec))) {
       fatal:
 	ec->errinfo = exception_error;
-	rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
+	rb_ec_reset_raised(ec);
 	EC_JUMP_TAG(ec, TAG_FATAL);
     }
 

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

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