summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--eval.c14
-rw-r--r--gc.c2
-rw-r--r--load.c2
-rw-r--r--proc.c2
-rw-r--r--signal.c2
-rw-r--r--thread.c4
-rw-r--r--vm.c4
-rw-r--r--vm_backtrace.c2
-rw-r--r--vm_eval.c41
-rw-r--r--vm_trace.c2
11 files changed, 48 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 488d797..9fdca79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu May 5 12:22:17 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* random.c (fill_random_bytes_syscall): use arc4random_buf if
diff --git a/eval.c b/eval.c
index fca073f..475d6ca 100644
--- a/eval.c
+++ b/eval.c
@@ -477,7 +477,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
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, volatile VALUE mesg, VALUE cause)
}
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, VALUE cause)
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)
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), VALUE data1,
}
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), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
(*ensure_list.entry.e_proc)(ensure_list.entry.data2);
th->errinfo = errinfo;
if (state)
- JUMP_TAG(state);
+ TH_JUMP_TAG(th, state);
return result;
}
diff --git a/gc.c b/gc.c
index d9f495b..6923ccd 100644
--- a/gc.c
+++ b/gc.c
@@ -7572,7 +7572,7 @@ rb_memerror(void)
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);
diff --git a/load.c b/load.c
index 1ae2fcb..9c8d2b1 100644
--- a/load.c
+++ b/load.c
@@ -646,7 +646,7 @@ rb_load_internal(VALUE fname, int wrap)
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);
}
}
diff --git a/proc.c b/proc.c
index 9a252f4..d3f94e4 100644
--- a/proc.c
+++ b/proc.c
@@ -1985,7 +1985,7 @@ call_method_data_safe(rb_thread_t *th, const struct METHOD *data,
TH_POP_TAG();
rb_set_safe_level_force(safe);
if (state)
- JUMP_TAG(state);
+ TH_JUMP_TAG(th, state);
return result;
}
diff --git a/signal.c b/signal.c
index 492e682..ec5687b 100644
--- a/signal.c
+++ b/signal.c
@@ -980,7 +980,7 @@ signal_exec(VALUE cmd, int safe, int sig)
if (state) {
/* XXX: should be replaced with rb_threadptr_pending_interrupt_enque() */
- JUMP_TAG(state);
+ TH_JUMP_TAG(cur_th, state);
}
}
diff --git a/thread.c b/thread.c
index ac31da5..884bb01 100644
--- a/thread.c
+++ b/thread.c
@@ -1422,7 +1422,7 @@ rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd)
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, VALUE mask_arg)
RUBY_VM_CHECK_INTS(th);
if (state) {
- JUMP_TAG(state);
+ TH_JUMP_TAG(th, state);
}
return r;
diff --git a/vm.c b/vm.c
index 94fbfdd..edc3f20 100644
--- a/vm.c
+++ b/vm.c
@@ -1047,7 +1047,7 @@ vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
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)
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);
diff --git a/vm_backtrace.c b/vm_backtrace.c
index 31ca10f..bdc996d 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -1191,7 +1191,7 @@ rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
/* invalidate bindings? */
if (state) {
- JUMP_TAG(state);
+ TH_JUMP_TAG(th, state);
}
return result;
diff --git a/vm_eval.c b/vm_eval.c
index 2011502..93dbfb7 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1397,7 +1397,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
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 *state)
*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 level)
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)
}
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)(), VALUE data)
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);
diff --git a/vm_trace.c b/vm_trace.c
index a84821e..ebf8e69 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -416,7 +416,7 @@ rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
if (!tracing) th->vm->trace_running--;
if (state) {
- JUMP_TAG(state);
+ TH_JUMP_TAG(th, state);
}
th->state = outer_state;