mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
introduce EC_*_TAG() instead of TH_*_TAG()
* eval_intern.h: introduce EC_*_TAG() macros instead of TH_*_TAG() macros. * TH_PUSH_TAG() -> EC_PUSH_TAG() * TH_POP_TAG() -> EC_POP_TAG() * TH_TMPPOP_TAG() -> EC_TMPPOP_TAG() * TH_REPUSH_TAG() -> EC_REPUSH_TAG() * TH_EXEC_TAG() -> EC_EXEC_TAG() * TH_JUMP_TAG() -> EC_JUMP_TAG() rb_threadptr_tag_state() , rb_ec_tag_jump() also accept `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
24044b2f63
commit
4552f74715
16 changed files with 124 additions and 123 deletions
4
cont.c
4
cont.c
|
@ -1408,7 +1408,7 @@ rb_fiber_start(void)
|
|||
VM_ASSERT(th->ec == ruby_current_execution_context_ptr);
|
||||
VM_ASSERT(FIBER_RESUMED_P(fib));
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
rb_context_t *cont = &VAR_FROM_MEMORY(fib)->cont;
|
||||
int argc;
|
||||
|
@ -1423,7 +1423,7 @@ rb_fiber_start(void)
|
|||
EXEC_EVENT_HOOK(th, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil);
|
||||
cont->value = rb_vm_invoke_proc(th, proc, argc, argv, VM_BLOCK_HANDLER_NONE);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
if (state) {
|
||||
VM_ASSERT(FIBER_RESUMED_P(fib));
|
||||
|
|
44
eval.c
44
eval.c
|
@ -169,7 +169,7 @@ ruby_cleanup(volatile int ex)
|
|||
|
||||
rb_threadptr_interrupt(th);
|
||||
rb_threadptr_check_signal(th);
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); });
|
||||
|
||||
|
@ -224,7 +224,7 @@ ruby_cleanup(volatile int ex)
|
|||
|
||||
/* unlock again if finalizer took mutexes. */
|
||||
rb_threadptr_unlock_all_locking_mutexes(GET_THREAD());
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
rb_thread_stop_timer_thread();
|
||||
ruby_vm_destruct(GET_VM());
|
||||
if (state) ruby_default_signal(state);
|
||||
|
@ -241,13 +241,13 @@ ruby_exec_internal(void *n)
|
|||
|
||||
if (!n) return 0;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
SAVE_ROOT_JMPBUF(th, {
|
||||
rb_iseq_eval_main(iseq);
|
||||
});
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
return state;
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ exc_setup_message(rb_thread_t *th, VALUE mesg, VALUE *cause)
|
|||
|
||||
if (NIL_P(mesg)) {
|
||||
mesg = th->ec->errinfo;
|
||||
if (INTERNAL_EXCEPTION_P(mesg)) TH_JUMP_TAG(th, TAG_FATAL);
|
||||
if (INTERNAL_EXCEPTION_P(mesg)) EC_JUMP_TAG(th->ec, TAG_FATAL);
|
||||
nocause = 1;
|
||||
}
|
||||
if (NIL_P(mesg)) {
|
||||
|
@ -508,7 +508,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
if ((file && !NIL_P(mesg)) || (cause != Qundef)) {
|
||||
volatile int state = 0;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if (EXEC_TAG() == TAG_NONE && !(state = rb_threadptr_set_raised(th))) {
|
||||
VALUE bt = rb_get_backtrace(mesg);
|
||||
if (!NIL_P(bt) || cause == Qundef) {
|
||||
|
@ -526,7 +526,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
}
|
||||
rb_threadptr_reset_raised(th);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
if (state) goto fatal;
|
||||
}
|
||||
|
||||
|
@ -539,7 +539,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
enum ruby_tag_type state;
|
||||
|
||||
mesg = e;
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
th->ec->errinfo = Qnil;
|
||||
e = rb_obj_as_string(mesg);
|
||||
|
@ -558,13 +558,13 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
}
|
||||
warn_print_str(e);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
if (state == TAG_FATAL && th->ec->errinfo == exception_error) {
|
||||
th->ec->errinfo = mesg;
|
||||
}
|
||||
else if (state) {
|
||||
rb_threadptr_reset_raised(th);
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -572,7 +572,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
fatal:
|
||||
th->ec->errinfo = exception_error;
|
||||
rb_threadptr_reset_raised(th);
|
||||
TH_JUMP_TAG(th, TAG_FATAL);
|
||||
EC_JUMP_TAG(th->ec, TAG_FATAL);
|
||||
}
|
||||
|
||||
if (tag != TAG_FATAL) {
|
||||
|
@ -599,7 +599,7 @@ rb_longjmp(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
mesg = exc_setup_message(th, mesg, &cause);
|
||||
setup_exception(th, tag, mesg, cause);
|
||||
rb_thread_raised_clear(th);
|
||||
TH_JUMP_TAG(th, tag);
|
||||
EC_JUMP_TAG(th->ec, tag);
|
||||
}
|
||||
|
||||
static VALUE make_exception(int argc, const VALUE *argv, int isstr);
|
||||
|
@ -902,8 +902,8 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
|
|||
volatile VALUE e_info = th->ec->errinfo;
|
||||
va_list args;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
|
||||
retry_entry:
|
||||
result = (*b_proc) (data1);
|
||||
}
|
||||
|
@ -942,9 +942,9 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
|
|||
}
|
||||
}
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
if (state)
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1000,10 +1000,10 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate)
|
|||
|
||||
protect_tag.prev = th->ec->protect_tag;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
th->ec->protect_tag = &protect_tag;
|
||||
MEMCPY(&org_jmpbuf, &(th)->root_jmpbuf, rb_jmpbuf_t, 1);
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
|
||||
SAVE_ROOT_JMPBUF(th, result = (*proc) (data));
|
||||
}
|
||||
else {
|
||||
|
@ -1011,7 +1011,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate)
|
|||
}
|
||||
MEMCPY(&(th)->root_jmpbuf, &org_jmpbuf, rb_jmpbuf_t, 1);
|
||||
th->ec->protect_tag = protect_tag.prev;
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
if (pstate != NULL) *pstate = state;
|
||||
return result;
|
||||
|
@ -1044,11 +1044,11 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
|
|||
ensure_list.entry.data2 = data2;
|
||||
ensure_list.next = th->ec->ensure_list;
|
||||
th->ec->ensure_list = &ensure_list;
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
result = (*b_proc) (data1);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
errinfo = th->ec->errinfo;
|
||||
if (!NIL_P(errinfo) && !RB_TYPE_P(errinfo, T_OBJECT)) {
|
||||
th->ec->errinfo = Qnil;
|
||||
|
@ -1057,7 +1057,7 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
|
|||
(*ensure_list.entry.e_proc)(ensure_list.entry.data2);
|
||||
th->ec->errinfo = errinfo;
|
||||
if (state)
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -174,8 +174,8 @@ rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo)
|
|||
return;
|
||||
rb_thread_raised_clear(th);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if (TH_EXEC_TAG() == TAG_NONE) {
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if (EC_EXEC_TAG() == TAG_NONE) {
|
||||
errat = rb_get_backtrace(errinfo);
|
||||
}
|
||||
else if (errat == Qundef) {
|
||||
|
@ -201,7 +201,7 @@ rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo)
|
|||
print_backtrace(eclass, errat, FALSE);
|
||||
}
|
||||
error:
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
th->ec->errinfo = errinfo;
|
||||
rb_thread_raised_set(th, raised_flag);
|
||||
}
|
||||
|
|
|
@ -128,24 +128,24 @@ LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *);
|
|||
rb_fiber_start(); \
|
||||
} while (0)
|
||||
|
||||
#define TH_PUSH_TAG(th) do { \
|
||||
rb_thread_t * const _th = (th); \
|
||||
#define EC_PUSH_TAG(ec) do { \
|
||||
rb_execution_context_t * const _ec = (ec); \
|
||||
struct rb_vm_tag _tag; \
|
||||
_tag.state = TAG_NONE; \
|
||||
_tag.tag = Qundef; \
|
||||
_tag.prev = _th->ec->tag;
|
||||
_tag.prev = _ec->tag;
|
||||
|
||||
#define TH_POP_TAG() \
|
||||
_th->ec->tag = _tag.prev; \
|
||||
#define EC_POP_TAG() \
|
||||
_ec->tag = _tag.prev; \
|
||||
} while (0)
|
||||
|
||||
#define TH_TMPPOP_TAG() \
|
||||
_th->ec->tag = _tag.prev
|
||||
#define EC_TMPPOP_TAG() \
|
||||
_ec->tag = _tag.prev
|
||||
|
||||
#define TH_REPUSH_TAG() (void)(_th->ec->tag = &_tag)
|
||||
#define EC_REPUSH_TAG() (void)(_ec->tag = &_tag)
|
||||
|
||||
#define PUSH_TAG() TH_PUSH_TAG(GET_THREAD())
|
||||
#define POP_TAG() TH_POP_TAG()
|
||||
#define PUSH_TAG() EC_PUSH_TAG(GET_EC())
|
||||
#define POP_TAG() EC_POP_TAG()
|
||||
|
||||
#if defined __GNUC__ && __GNUC__ == 4 && (__GNUC_MINOR__ >= 6 && __GNUC_MINOR__ <= 8)
|
||||
# define VAR_FROM_MEMORY(var) __extension__(*(__typeof__(var) volatile *)&(var))
|
||||
|
@ -176,34 +176,34 @@ LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *);
|
|||
|
||||
/* clear th->ec->tag->state, and return the value */
|
||||
static inline int
|
||||
rb_threadptr_tag_state(rb_thread_t *th)
|
||||
rb_threadptr_tag_state(const rb_execution_context_t *ec)
|
||||
{
|
||||
enum ruby_tag_type state = th->ec->tag->state;
|
||||
th->ec->tag->state = TAG_NONE;
|
||||
enum ruby_tag_type state = ec->tag->state;
|
||||
ec->tag->state = TAG_NONE;
|
||||
return state;
|
||||
}
|
||||
|
||||
NORETURN(static inline void rb_threadptr_tag_jump(rb_thread_t *, enum ruby_tag_type st));
|
||||
NORETURN(static inline void rb_ec_tag_jump(rb_execution_context_t *ec, enum ruby_tag_type st));
|
||||
static inline void
|
||||
rb_threadptr_tag_jump(rb_thread_t *th, enum ruby_tag_type st)
|
||||
rb_ec_tag_jump(rb_execution_context_t *ec, enum ruby_tag_type st)
|
||||
{
|
||||
th->ec->tag->state = st;
|
||||
ruby_longjmp(th->ec->tag->buf, 1);
|
||||
ec->tag->state = st;
|
||||
ruby_longjmp(ec->tag->buf, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
setjmp() in assignment expression rhs is undefined behavior
|
||||
[ISO/IEC 9899:1999] 7.13.1.1
|
||||
*/
|
||||
#define TH_EXEC_TAG() \
|
||||
(ruby_setjmp(_tag.buf) ? rb_threadptr_tag_state(VAR_FROM_MEMORY(_th)) : (TH_REPUSH_TAG(), 0))
|
||||
#define EC_EXEC_TAG() \
|
||||
(ruby_setjmp(_tag.buf) ? rb_threadptr_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0))
|
||||
|
||||
#define EXEC_TAG() \
|
||||
TH_EXEC_TAG()
|
||||
EC_EXEC_TAG()
|
||||
|
||||
#define TH_JUMP_TAG(th, st) rb_threadptr_tag_jump(th, st)
|
||||
#define EC_JUMP_TAG(ec, st) rb_ec_tag_jump(ec, st)
|
||||
|
||||
#define JUMP_TAG(st) TH_JUMP_TAG(GET_THREAD(), (st))
|
||||
#define JUMP_TAG(st) EC_JUMP_TAG(GET_EC(), (st))
|
||||
|
||||
#define INTERNAL_EXCEPTION_P(exc) FIXNUM_P(exc)
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ rb_exec_end_proc(void)
|
|||
rb_thread_t *th = GET_THREAD();
|
||||
volatile VALUE errinfo = th->ec->errinfo;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
again:
|
||||
exec_end_procs_chain(&ephemeral_end_procs, &th->ec->errinfo);
|
||||
|
@ -126,13 +126,13 @@ rb_exec_end_proc(void)
|
|||
}
|
||||
else {
|
||||
VAR_INITIALIZED(th);
|
||||
TH_TMPPOP_TAG();
|
||||
EC_TMPPOP_TAG();
|
||||
error_handle(state);
|
||||
if (!NIL_P(th->ec->errinfo)) errinfo = th->ec->errinfo;
|
||||
TH_REPUSH_TAG();
|
||||
EC_REPUSH_TAG();
|
||||
goto again;
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
rb_set_safe_level_force(safe);
|
||||
th->ec->errinfo = errinfo;
|
||||
|
|
8
gc.c
8
gc.c
|
@ -2803,8 +2803,8 @@ run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table)
|
|||
saved.cfp = th->ec->cfp;
|
||||
saved.finished = 0;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
state = TH_EXEC_TAG();
|
||||
EC_PUSH_TAG(th->ec);
|
||||
state = EC_EXEC_TAG();
|
||||
if (state != TAG_NONE) {
|
||||
++saved.finished; /* skip failed finalizer */
|
||||
}
|
||||
|
@ -2813,7 +2813,7 @@ run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table)
|
|||
saved.finished = ++i) {
|
||||
run_single_final(RARRAY_AREF(table, i), saved.objid);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
#undef RESTORE_FINALIZER
|
||||
}
|
||||
|
||||
|
@ -7720,7 +7720,7 @@ rb_memerror(void)
|
|||
exc = ruby_vm_special_exception_copy(exc);
|
||||
}
|
||||
th->ec->errinfo = exc;
|
||||
TH_JUMP_TAG(th, TAG_RAISE);
|
||||
EC_JUMP_TAG(th->ec, TAG_RAISE);
|
||||
}
|
||||
|
||||
static void *
|
||||
|
|
10
load.c
10
load.c
|
@ -599,7 +599,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
|
|||
rb_extend_object(th->top_self, th->top_wrapper);
|
||||
}
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
state = EXEC_TAG();
|
||||
if (state == TAG_NONE) {
|
||||
NODE *node;
|
||||
|
@ -617,7 +617,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
|
|||
}
|
||||
rb_iseq_eval(iseq);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
#if !defined __GNUC__
|
||||
th = th0;
|
||||
|
@ -649,7 +649,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->ec->errinfo);
|
||||
TH_JUMP_TAG(curr_th, state);
|
||||
EC_JUMP_TAG(curr_th->ec, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -975,7 +975,7 @@ rb_require_internal(VALUE fname, int safe)
|
|||
path = rb_str_encode_ospath(fname);
|
||||
RUBY_DTRACE_HOOK(REQUIRE_ENTRY, RSTRING_PTR(fname));
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
saved.safe = rb_safe_level();
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
long handle;
|
||||
|
@ -1014,7 +1014,7 @@ rb_require_internal(VALUE fname, int safe)
|
|||
}
|
||||
}
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
load_unlock(ftptr, !state);
|
||||
|
||||
rb_set_safe_level_force(saved.safe);
|
||||
|
|
8
proc.c
8
proc.c
|
@ -2114,16 +2114,16 @@ call_method_data_safe(rb_thread_t *th, const struct METHOD *data,
|
|||
VALUE result = Qnil; /* OK */
|
||||
enum ruby_tag_type state;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
|
||||
/* result is used only if state == 0, no exceptions is caught. */
|
||||
/* otherwise it doesn't matter even if clobbered. */
|
||||
NO_CLOBBERED(result) = call_method_data(th, data, argc, argv, passed_procval);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
rb_set_safe_level_force(safe);
|
||||
if (state)
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
6
signal.c
6
signal.c
|
@ -1001,18 +1001,18 @@ signal_exec(VALUE cmd, int safe, int sig)
|
|||
return;
|
||||
|
||||
cur_th->interrupt_mask |= TRAP_INTERRUPT_MASK;
|
||||
TH_PUSH_TAG(cur_th);
|
||||
EC_PUSH_TAG(cur_th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
VALUE signum = INT2NUM(sig);
|
||||
rb_eval_cmd(cmd, rb_ary_new3(1, signum), safe);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
cur_th = GET_THREAD();
|
||||
cur_th->interrupt_mask = old_interrupt_mask;
|
||||
|
||||
if (state) {
|
||||
/* XXX: should be replaced with rb_threadptr_pending_interrupt_enque() */
|
||||
TH_JUMP_TAG(cur_th, state);
|
||||
EC_JUMP_TAG(cur_th->ec, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
24
thread.c
24
thread.c
|
@ -490,8 +490,8 @@ rb_thread_terminate_all(void)
|
|||
/* unlock all locking mutexes */
|
||||
rb_threadptr_unlock_all_locking_mutexes(th);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if (TH_EXEC_TAG() == TAG_NONE) {
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if (EC_EXEC_TAG() == TAG_NONE) {
|
||||
retry:
|
||||
thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th);
|
||||
terminate_all(vm, th);
|
||||
|
@ -518,7 +518,7 @@ rb_thread_terminate_all(void)
|
|||
goto retry;
|
||||
}
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -625,7 +625,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
|
|||
thread_debug("thread start (get lock): %p\n", (void *)th);
|
||||
rb_thread_set_current(th);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
SAVE_ROOT_JMPBUF(th, thread_do_start(th, args));
|
||||
}
|
||||
|
@ -666,7 +666,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
|
|||
/* treat with normal error object */
|
||||
rb_threadptr_raise(main_th, 1, &errinfo);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
/* locking_mutex must be Qfalse */
|
||||
if (th->locking_mutex != Qfalse) {
|
||||
|
@ -1445,20 +1445,20 @@ rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd)
|
|||
wfd.th = th;
|
||||
list_add(&vm->waiting_fds, &wfd.wfd_node);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
BLOCKING_REGION({
|
||||
val = func(data1);
|
||||
saved_errno = errno;
|
||||
}, ubf_select, th, FALSE);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
/* must be deleted before jump */
|
||||
list_del(&wfd.wfd_node);
|
||||
|
||||
if (state) {
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
/* TODO: check func() */
|
||||
RUBY_VM_CHECK_INTS_BLOCKING(th);
|
||||
|
@ -1878,11 +1878,11 @@ rb_thread_s_handle_interrupt(VALUE self, VALUE mask_arg)
|
|||
RUBY_VM_SET_INTERRUPT(th);
|
||||
}
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
r = rb_yield(Qnil);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
rb_ary_pop(th->pending_interrupt_mask_stack);
|
||||
if (!rb_threadptr_pending_interrupt_empty_p(th)) {
|
||||
|
@ -1893,7 +1893,7 @@ rb_thread_s_handle_interrupt(VALUE self, VALUE mask_arg)
|
|||
RUBY_VM_CHECK_INTS(th);
|
||||
|
||||
if (state) {
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
@ -2008,7 +2008,7 @@ rb_threadptr_to_kill(rb_thread_t *th)
|
|||
th->status = THREAD_RUNNABLE;
|
||||
th->to_kill = 1;
|
||||
th->ec->errinfo = INT2FIX(TAG_FATAL);
|
||||
TH_JUMP_TAG(th, TAG_FATAL);
|
||||
EC_JUMP_TAG(th->ec, TAG_FATAL);
|
||||
}
|
||||
|
||||
static inline rb_atomic_t
|
||||
|
|
17
vm.c
17
vm.c
|
@ -1150,17 +1150,17 @@ vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
|
|||
enum ruby_tag_type state;
|
||||
volatile int stored_safe = th->ec->safe_level;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
th->ec->safe_level = proc->safe_level;
|
||||
val = invoke_block_from_c_proc(th, proc, self, argc, argv, passed_block_handler, proc->is_lambda);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
th->ec->safe_level = stored_safe;
|
||||
|
||||
if (state) {
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -1487,7 +1487,7 @@ vm_iter_break(rb_thread_t *th, VALUE val)
|
|||
#endif
|
||||
|
||||
th->ec->errinfo = (VALUE)THROW_DATA_NEW(val, target_cfp, TAG_BREAK);
|
||||
TH_JUMP_TAG(th, TAG_BREAK);
|
||||
EC_JUMP_TAG(th->ec, TAG_BREAK);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1791,7 +1791,8 @@ vm_exec(rb_thread_t *th)
|
|||
VALUE initial = 0;
|
||||
struct vm_throw_data *err;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
|
||||
_tag.retval = Qnil;
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
vm_loop_start:
|
||||
|
@ -2010,8 +2011,8 @@ vm_exec(rb_thread_t *th)
|
|||
if (VM_FRAME_FINISHED_P(th->ec->cfp)) {
|
||||
rb_vm_pop_frame(th->ec);
|
||||
th->ec->errinfo = (VALUE)err;
|
||||
TH_TMPPOP_TAG();
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_TMPPOP_TAG();
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
else {
|
||||
rb_vm_pop_frame(th->ec);
|
||||
|
@ -2020,7 +2021,7 @@ vm_exec(rb_thread_t *th)
|
|||
}
|
||||
}
|
||||
finish_vme:
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1182,16 +1182,16 @@ rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
|
|||
dbg_context.backtrace_size = RARRAY_LEN(dbg_context.backtrace);
|
||||
dbg_context.contexts = collect_caller_bindings(th);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
result = (*func)(&dbg_context, data);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
/* invalidate bindings? */
|
||||
|
||||
if (state) {
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -686,7 +686,7 @@ enum rb_thread_status {
|
|||
typedef RUBY_JMP_BUF rb_jmpbuf_t;
|
||||
|
||||
/*
|
||||
the members which are written in TH_PUSH_TAG() should be placed at
|
||||
the members which are written in EC_PUSH_TAG() should be placed at
|
||||
the beginning and the end, so that entire region is accessible.
|
||||
*/
|
||||
struct rb_vm_tag {
|
||||
|
|
36
vm_eval.c
36
vm_eval.c
|
@ -1114,8 +1114,8 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
|
|||
volatile VALUE retval = Qnil;
|
||||
rb_control_frame_t *const cfp = th->ec->cfp;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
state = TH_EXEC_TAG();
|
||||
EC_PUSH_TAG(th->ec);
|
||||
state = EC_EXEC_TAG();
|
||||
if (state == 0) {
|
||||
iter_retry:
|
||||
{
|
||||
|
@ -1151,10 +1151,10 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
|
|||
SDR(); fprintf(stderr, "%p, %p\n", cfp, escape_cfp);
|
||||
}
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
if (state) {
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -1349,17 +1349,17 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
|
|||
return vm_exec(th);
|
||||
}
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
|
||||
result = vm_exec(th);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
if (state) {
|
||||
if (state == TAG_RAISE) {
|
||||
adjust_backtrace_in_eval(th, th->ec->errinfo);
|
||||
}
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1505,7 +1505,7 @@ rb_eval_string_wrap(const char *str, int *pstate)
|
|||
*pstate = state;
|
||||
}
|
||||
else if (state != TAG_NONE) {
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -1522,9 +1522,9 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
|
|||
level = RUBY_SAFE_LEVEL_MAX;
|
||||
}
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
rb_set_safe_level_force(level);
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
|
||||
if (!RB_TYPE_P(cmd, T_STRING)) {
|
||||
val = rb_funcallv(cmd, idCall, RARRAY_LENINT(arg),
|
||||
RARRAY_CONST_PTR(arg));
|
||||
|
@ -1533,10 +1533,10 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
|
|||
val = eval_string(rb_vm_top_self(), cmd, Qnil, 0, 0);
|
||||
}
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
rb_set_safe_level_force(safe);
|
||||
if (state) TH_JUMP_TAG(th, state);
|
||||
if (state) EC_JUMP_TAG(th->ec, state);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -1893,7 +1893,7 @@ rb_throw_obj(VALUE tag, VALUE value)
|
|||
}
|
||||
|
||||
th->ec->errinfo = (VALUE)THROW_DATA_NEW(tag, NULL, TAG_THROW);
|
||||
TH_JUMP_TAG(th, TAG_THROW);
|
||||
EC_JUMP_TAG(th->ec, TAG_THROW);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1988,11 +1988,11 @@ vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
|
|||
VALUE val = Qnil; /* OK */
|
||||
rb_control_frame_t *volatile saved_cfp = th->ec->cfp;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
|
||||
_tag.tag = tag;
|
||||
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
|
||||
/* call with argc=1, argv = [tag], block = Qnil to insure compatibility */
|
||||
val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil);
|
||||
}
|
||||
|
@ -2002,7 +2002,7 @@ vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
|
|||
th->ec->errinfo = Qnil;
|
||||
state = 0;
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
if (stateptr)
|
||||
*stateptr = state;
|
||||
|
||||
|
@ -2021,7 +2021,7 @@ rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data)
|
|||
enum ruby_tag_type state;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
VALUE val = vm_catch_protect(t, (rb_block_call_func *)func, data, &state, th);
|
||||
if (state) TH_JUMP_TAG(th, state);
|
||||
if (state) EC_JUMP_TAG(th->ec, state);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ threadptr_stack_overflow(rb_thread_t *th, int setup)
|
|||
rb_ivar_set(mesg, idBt_locations, at);
|
||||
}
|
||||
th->ec->errinfo = mesg;
|
||||
TH_JUMP_TAG(th, TAG_RAISE);
|
||||
EC_JUMP_TAG(th->ec, TAG_RAISE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -59,7 +59,7 @@ rb_threadptr_stack_overflow(rb_thread_t *th, int crit)
|
|||
if (crit || rb_during_gc()) {
|
||||
th->ec->raised_flag = RAISED_STACKOVERFLOW;
|
||||
th->ec->errinfo = th->vm->special_exceptions[ruby_error_stackfatal];
|
||||
TH_JUMP_TAG(th, TAG_RAISE);
|
||||
EC_JUMP_TAG(th->ec, TAG_RAISE);
|
||||
}
|
||||
#ifdef USE_SIGALTSTACK
|
||||
threadptr_stack_overflow(th, TRUE);
|
||||
|
|
20
vm_trace.c
20
vm_trace.c
|
@ -285,11 +285,11 @@ exec_hooks_protected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t
|
|||
|
||||
/* TODO: Support !RUBY_EVENT_HOOK_FLAG_SAFE hooks */
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
|
||||
exec_hooks_body(th, list, trace_arg);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
if (raised) {
|
||||
rb_threadptr_set_raised(th);
|
||||
|
@ -354,7 +354,7 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
|
|||
}
|
||||
rb_vm_pop_frame(th->ec);
|
||||
}
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -388,11 +388,11 @@ rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
|
|||
|
||||
raised = rb_threadptr_reset_raised(th);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
|
||||
result = (*func)(arg);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
|
||||
if (raised) {
|
||||
rb_threadptr_set_raised(th);
|
||||
|
@ -405,7 +405,7 @@ rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
|
|||
#if defined RUBY_USE_SETJMPEX && RUBY_USE_SETJMPEX
|
||||
RB_GC_GUARD(result);
|
||||
#endif
|
||||
TH_JUMP_TAG(th, state);
|
||||
EC_JUMP_TAG(th->ec, state);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1600,7 +1600,7 @@ rb_postponed_job_flush(rb_vm_t *vm)
|
|||
/* mask POSTPONED_JOB dispatch */
|
||||
th->interrupt_mask |= block_mask;
|
||||
{
|
||||
TH_PUSH_TAG(th);
|
||||
EC_PUSH_TAG(th->ec);
|
||||
if (EXEC_TAG() == TAG_NONE) {
|
||||
int index;
|
||||
while ((index = vm->postponed_job_index) > 0) {
|
||||
|
@ -1610,7 +1610,7 @@ rb_postponed_job_flush(rb_vm_t *vm)
|
|||
}
|
||||
}
|
||||
}
|
||||
TH_POP_TAG();
|
||||
EC_POP_TAG();
|
||||
}
|
||||
/* restore POSTPONED_JOB mask */
|
||||
th->interrupt_mask &= ~(saved_mask ^ block_mask);
|
||||
|
|
Loading…
Reference in a new issue