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

ruby-changes:42840

From: nobu <ko1@a...>
Date: Thu, 5 May 2016 11:25:44 +0900 (JST)
Subject: [ruby-changes:42840] nobu:r54914 (trunk): use TH_JUMP_TAG

nobu	2016-05-05 12:22:20 +0900 (Thu, 05 May 2016)

  New Revision: 54914

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

  Log:
    use TH_JUMP_TAG
    
    * vm_eval.c (rb_eval_cmd, rb_catch_obj): use TH_JUMP_TAG with the
      same rb_thread_t used for TH_PUSH_TAG, instead of JUMP_TAG with
      the current thread global variable.

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
    trunk/gc.c
    trunk/load.c
    trunk/proc.c
    trunk/signal.c
    trunk/thread.c
    trunk/vm.c
    trunk/vm_backtrace.c
    trunk/vm_eval.c
    trunk/vm_trace.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54913)
+++ ChangeLog	(revision 54914)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu May  5 12:22:17 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_eval.c (rb_eval_cmd, rb_catch_obj): use TH_JUMP_TAG with the
+	  same rb_thread_t used for TH_PUSH_TAG, instead of JUMP_TAG with
+	  the current thread global variable.
+
 Thu May  5 10:49:33 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* random.c (fill_random_bytes_syscall): use arc4random_buf if
Index: vm_trace.c
===================================================================
--- vm_trace.c	(revision 54913)
+++ vm_trace.c	(revision 54914)
@@ -416,7 +416,7 @@ rb_suppress_tracing(VALUE (*func)(VALUE) https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L416
     if (!tracing) th->vm->trace_running--;
 
     if (state) {
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
     }
 
     th->state = outer_state;
Index: signal.c
===================================================================
--- signal.c	(revision 54913)
+++ signal.c	(revision 54914)
@@ -980,7 +980,7 @@ signal_exec(VALUE cmd, int safe, int sig https://github.com/ruby/ruby/blob/trunk/signal.c#L980
 
     if (state) {
 	/* XXX: should be replaced with rb_threadptr_pending_interrupt_enque() */
-	JUMP_TAG(state);
+	TH_JUMP_TAG(cur_th, state);
     }
 }
 
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 54913)
+++ vm_eval.c	(revision 54914)
@@ -1397,7 +1397,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1397
 	if (state == TAG_RAISE) {
 	    adjust_backtrace_in_eval(th, th->errinfo);
 	}
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
     }
     return result;
 }
@@ -1543,7 +1543,7 @@ rb_eval_string_wrap(const char *str, int https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1543
 	*state = status;
     }
     else if (status) {
-	JUMP_TAG(status);
+	TH_JUMP_TAG(th, status);
     }
     return val;
 }
@@ -1554,35 +1554,36 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int le https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1554
     int state;
     volatile VALUE val = Qnil;		/* OK */
     volatile int safe = rb_safe_level();
+    rb_thread_t *th = GET_THREAD();
 
     if (OBJ_TAINTED(cmd)) {
 	level = RUBY_SAFE_LEVEL_MAX;
     }
 
     if (!RB_TYPE_P(cmd, T_STRING)) {
-	PUSH_TAG();
+	TH_PUSH_TAG(th);
 	rb_set_safe_level_force(level);
-	if ((state = EXEC_TAG()) == 0) {
+	if ((state = TH_EXEC_TAG()) == 0) {
 	    val = rb_funcall2(cmd, idCall, RARRAY_LENINT(arg),
 			      RARRAY_CONST_PTR(arg));
 	}
-	POP_TAG();
+	TH_POP_TAG();
 
 	rb_set_safe_level_force(safe);
 
 	if (state)
-	    JUMP_TAG(state);
+	    TH_JUMP_TAG(th, state);
 	return val;
     }
 
-    PUSH_TAG();
-    if ((state = EXEC_TAG()) == 0) {
+    TH_PUSH_TAG(th);
+    if ((state = TH_EXEC_TAG()) == 0) {
 	val = eval_string(rb_vm_top_self(), cmd, Qnil, 0, 0);
     }
-    POP_TAG();
+    TH_POP_TAG();
 
     rb_set_safe_level_force(safe);
-    if (state) JUMP_TAG(state);
+    if (state) TH_JUMP_TAG(th, state);
     return val;
 }
 
@@ -1910,7 +1911,7 @@ rb_throw_obj(VALUE tag, VALUE value) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1911
     }
 
     th->errinfo = (VALUE)THROW_DATA_NEW(tag, NULL, TAG_THROW);
-    JUMP_TAG(TAG_THROW);
+    TH_JUMP_TAG(th, TAG_THROW);
 }
 
 void
@@ -1997,24 +1998,32 @@ rb_catch(const char *tag, VALUE (*func)( https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1998
     return rb_catch_obj(vtag, func, data);
 }
 
+static VALUE vm_catch_protect(VALUE, rb_block_call_func *, VALUE, int *, rb_thread_t *);
+
 VALUE
 rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data)
 {
     int state;
-    VALUE val = rb_catch_protect(t, (rb_block_call_func *)func, data, &state);
+    rb_thread_t *th = GET_THREAD();
+    VALUE val = vm_catch_protect(t, (rb_block_call_func *)func, data, &state, th);
     if (state)
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
     return val;
 }
 
 VALUE
 rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr)
 {
+    return vm_catch_protect(t, func, data, stateptr, GET_THREAD());
+}
+
+static VALUE
+vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
+		 int *stateptr, rb_thread_t *th)
+{
     int state;
-    volatile VALUE val = Qnil;		/* OK */
-    rb_thread_t *th = GET_THREAD();
+    VALUE val = Qnil;		/* OK */
     rb_control_frame_t *saved_cfp = th->cfp;
-    volatile VALUE tag = t;
 
     TH_PUSH_TAG(th);
 
Index: gc.c
===================================================================
--- gc.c	(revision 54913)
+++ gc.c	(revision 54914)
@@ -7572,7 +7572,7 @@ rb_memerror(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L7572
     if (rb_thread_raised_p(th, RAISED_NOMEMORY)) {
 	rb_thread_raised_clear(th);
 	GET_THREAD()->errinfo = nomem_error;
-	JUMP_TAG(TAG_RAISE);
+	TH_JUMP_TAG(th, TAG_RAISE);
     }
     rb_thread_raised_set(th, RAISED_NOMEMORY);
     rb_exc_raise(nomem_error);
Index: load.c
===================================================================
--- load.c	(revision 54913)
+++ load.c	(revision 54914)
@@ -646,7 +646,7 @@ rb_load_internal(VALUE fname, int wrap) https://github.com/ruby/ruby/blob/trunk/load.c#L646
     int state = rb_load_internal0(curr_th, fname, wrap);
     if (state) {
 	if (state == TAG_RAISE) rb_exc_raise(curr_th->errinfo);
-	JUMP_TAG(state);
+	TH_JUMP_TAG(curr_th, state);
     }
 }
 
Index: proc.c
===================================================================
--- proc.c	(revision 54913)
+++ proc.c	(revision 54914)
@@ -1985,7 +1985,7 @@ call_method_data_safe(rb_thread_t *th, c https://github.com/ruby/ruby/blob/trunk/proc.c#L1985
     TH_POP_TAG();
     rb_set_safe_level_force(safe);
     if (state)
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
     return result;
 }
 
Index: vm_backtrace.c
===================================================================
--- vm_backtrace.c	(revision 54913)
+++ vm_backtrace.c	(revision 54914)
@@ -1191,7 +1191,7 @@ rb_debug_inspector_open(rb_debug_inspect https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L1191
     /* invalidate bindings? */
 
     if (state) {
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
     }
 
     return result;
Index: vm.c
===================================================================
--- vm.c	(revision 54913)
+++ vm.c	(revision 54914)
@@ -1047,7 +1047,7 @@ vm_invoke_proc(rb_thread_t *th, rb_proc_ https://github.com/ruby/ruby/blob/trunk/vm.c#L1047
     th->safe_level = stored_safe;
 
     if (state) {
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
     }
     return val;
 }
@@ -1859,7 +1859,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1859
 		vm_pop_frame(th);
 		th->errinfo = (VALUE)err;
 		TH_TMPPOP_TAG();
-		JUMP_TAG(state);
+		TH_JUMP_TAG(th, state);
 	    }
 	    else {
 		th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);
Index: eval.c
===================================================================
--- eval.c	(revision 54913)
+++ eval.c	(revision 54914)
@@ -477,7 +477,7 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L477
 
     if (NIL_P(mesg)) {
 	mesg = th->errinfo;
-	if (INTERNAL_EXCEPTION_P(mesg)) JUMP_TAG(TAG_FATAL);
+	if (INTERNAL_EXCEPTION_P(mesg)) TH_JUMP_TAG(th, TAG_FATAL);
 	nocause = 1;
     }
     if (NIL_P(mesg)) {
@@ -551,14 +551,14 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L551
 	}
 	else if (status) {
 	    rb_threadptr_reset_raised(th);
-	    JUMP_TAG(status);
+	    TH_JUMP_TAG(th, status);
 	}
     }
 
     if (rb_threadptr_set_raised(th)) {
 	th->errinfo = exception_error;
 	rb_threadptr_reset_raised(th);
-	JUMP_TAG(TAG_FATAL);
+	TH_JUMP_TAG(th, TAG_FATAL);
     }
 
     if (tag != TAG_FATAL) {
@@ -573,7 +573,7 @@ rb_longjmp(int tag, volatile VALUE mesg, https://github.com/ruby/ruby/blob/trunk/eval.c#L573
     rb_thread_t *th = GET_THREAD();
     setup_exception(th, tag, mesg, cause);
     rb_thread_raised_clear(th);
-    JUMP_TAG(tag);
+    TH_JUMP_TAG(th, tag);
 }
 
 static VALUE make_exception(int argc, const VALUE *argv, int isstr);
@@ -743,7 +743,7 @@ rb_raise_jump(VALUE mesg, VALUE cause) https://github.com/ruby/ruby/blob/trunk/eval.c#L743
     setup_exception(th, TAG_RAISE, mesg, cause);
 
     rb_thread_raised_clear(th);
-    JUMP_TAG(TAG_RAISE);
+    TH_JUMP_TAG(th, TAG_RAISE);
 }
 
 void
@@ -837,7 +837,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), V https://github.com/ruby/ruby/blob/trunk/eval.c#L837
     }
     TH_POP_TAG();
     if (state)
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
 
     return result;
 }
@@ -905,7 +905,7 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALU https://github.com/ruby/ruby/blob/trunk/eval.c#L905
     (*ensure_list.entry.e_proc)(ensure_list.entry.data2);
     th->errinfo = errinfo;
     if (state)
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
     return result;
 }
 
Index: thread.c
===================================================================
--- thread.c	(revision 54913)
+++ thread.c	(revision 54914)
@@ -1422,7 +1422,7 @@ rb_thread_io_blocking_region(rb_blocking https://github.com/ruby/ruby/blob/trunk/thread.c#L1422
     th->waiting_fd = -1;
 
     if (state) {
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
     }
     /* TODO: check func() */
     RUBY_VM_CHECK_INTS_BLOCKING(th);
@@ -1853,7 +1853,7 @@ rb_thread_s_handle_interrupt(VALUE self, https://github.com/ruby/ruby/blob/trunk/thread.c#L1853
     RUBY_VM_CHECK_INTS(th);
 
     if (state) {
-	JUMP_TAG(state);
+	TH_JUMP_TAG(th, state);
     }
 
     return r;

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

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