mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
use "enum ruby_tag_type" and TAG_NONE.
Return value of EXEC_TAG() is saved by "int state". Instead of "int", use "enum ruby_tag_type". First EXEC_TAG() value should be 0, so that define TAG_NONE (= 0) and use it. Some code used "status" instead of "state". To make them clear, rename them to state. We can change variable name from "state" to "tag_state", but this ticket doesn't contain it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1d248f0429
commit
2108e55c0b
16 changed files with 105 additions and 105 deletions
4
cont.c
4
cont.c
|
@ -1261,10 +1261,10 @@ rb_fiber_start(void)
|
|||
rb_thread_t *th = GET_THREAD();
|
||||
rb_fiber_t *fib = th->fiber;
|
||||
rb_proc_t *proc;
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
rb_context_t *cont = &VAR_FROM_MEMORY(fib)->cont;
|
||||
int argc;
|
||||
const VALUE *argv, args = cont->value;
|
||||
|
|
6
error.c
6
error.c
|
@ -1112,10 +1112,10 @@ exc_equal(VALUE exc, VALUE obj)
|
|||
if (exc == obj) return Qtrue;
|
||||
|
||||
if (rb_obj_class(exc) != rb_obj_class(obj)) {
|
||||
int status = 0;
|
||||
int state;
|
||||
|
||||
obj = rb_protect(try_convert_to_exception, obj, &status);
|
||||
if (status || obj == Qundef) {
|
||||
obj = rb_protect(try_convert_to_exception, obj, &state);
|
||||
if (state || obj == Qundef) {
|
||||
rb_set_errinfo(Qnil);
|
||||
return Qfalse;
|
||||
}
|
||||
|
|
47
eval.c
47
eval.c
|
@ -45,7 +45,7 @@ static ID id_cause;
|
|||
int
|
||||
ruby_setup(void)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
|
||||
if (GET_VM())
|
||||
return 0;
|
||||
|
@ -56,7 +56,7 @@ ruby_setup(void)
|
|||
Init_vm_objects();
|
||||
|
||||
PUSH_TAG();
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
rb_call_inits();
|
||||
ruby_prog_init();
|
||||
GET_VM()->running = 1;
|
||||
|
@ -94,12 +94,12 @@ ruby_init(void)
|
|||
void *
|
||||
ruby_options(int argc, char **argv)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
void *volatile iseq = 0;
|
||||
|
||||
ruby_init_stack((void *)&iseq);
|
||||
PUSH_TAG();
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
SAVE_ROOT_JMPBUF(GET_THREAD(), iseq = ruby_process_options(argc, argv));
|
||||
}
|
||||
else {
|
||||
|
@ -115,7 +115,7 @@ static void
|
|||
ruby_finalize_0(void)
|
||||
{
|
||||
PUSH_TAG();
|
||||
if (EXEC_TAG() == 0) {
|
||||
if (EXEC_TAG() == TAG_NONE) {
|
||||
rb_trap_exit();
|
||||
}
|
||||
POP_TAG();
|
||||
|
@ -168,7 +168,7 @@ ruby_cleanup(volatile int ex)
|
|||
rb_threadptr_interrupt(th);
|
||||
rb_threadptr_check_signal(th);
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); });
|
||||
|
||||
step_0: step++;
|
||||
|
@ -240,7 +240,7 @@ ruby_exec_internal(void *n)
|
|||
if (!n) return 0;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
SAVE_ROOT_JMPBUF(th, {
|
||||
rb_iseq_eval_main(iseq);
|
||||
});
|
||||
|
@ -492,10 +492,10 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
|
||||
file = rb_source_loc(&line);
|
||||
if ((file && !NIL_P(mesg)) || (cause != Qundef)) {
|
||||
int status;
|
||||
enum ruby_tag_type state;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if (EXEC_TAG() == 0 && !(status = rb_threadptr_set_raised(th))) {
|
||||
if (EXEC_TAG() == TAG_NONE && !(state = rb_threadptr_set_raised(th))) {
|
||||
VALUE bt = rb_get_backtrace(mesg);
|
||||
if (!NIL_P(bt) || cause == Qundef) {
|
||||
if (OBJ_FROZEN(mesg)) {
|
||||
|
@ -513,7 +513,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
rb_threadptr_reset_raised(th);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
if (status) goto fatal;
|
||||
if (state) goto fatal;
|
||||
}
|
||||
|
||||
if (!NIL_P(mesg)) {
|
||||
|
@ -522,11 +522,11 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
|
||||
if (RTEST(ruby_debug) && !NIL_P(e = th->errinfo) &&
|
||||
!rb_obj_is_kind_of(e, rb_eSystemExit)) {
|
||||
int status;
|
||||
enum ruby_tag_type state;
|
||||
|
||||
mesg = e;
|
||||
TH_PUSH_TAG(th);
|
||||
if ((status = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
th->errinfo = Qnil;
|
||||
e = rb_obj_as_string(mesg);
|
||||
th->errinfo = mesg;
|
||||
|
@ -545,12 +545,12 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
warn_print_str(e);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
if (status == TAG_FATAL && th->errinfo == exception_error) {
|
||||
if (state == TAG_FATAL && th->errinfo == exception_error) {
|
||||
th->errinfo = mesg;
|
||||
}
|
||||
else if (status) {
|
||||
else if (state) {
|
||||
rb_threadptr_reset_raised(th);
|
||||
TH_JUMP_TAG(th, status);
|
||||
TH_JUMP_TAG(th, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -793,7 +793,7 @@ VALUE
|
|||
rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
|
||||
VALUE (* r_proc) (ANYARGS), VALUE data2, ...)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *volatile cfp = th->ec.cfp;
|
||||
volatile VALUE result = Qfalse;
|
||||
|
@ -801,7 +801,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
|
|||
va_list args;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = TH_EXEC_TAG()) == 0) {
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
retry_entry:
|
||||
result = (*b_proc) (data1);
|
||||
}
|
||||
|
@ -856,10 +856,10 @@ rb_rescue(VALUE (* b_proc)(ANYARGS), VALUE data1,
|
|||
}
|
||||
|
||||
VALUE
|
||||
rb_protect(VALUE (* proc) (VALUE), VALUE data, int * state)
|
||||
rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate)
|
||||
{
|
||||
volatile VALUE result = Qnil;
|
||||
volatile int status;
|
||||
volatile enum ruby_tag_type state;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *volatile cfp = th->ec.cfp;
|
||||
struct rb_vm_protect_tag protect_tag;
|
||||
|
@ -870,7 +870,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int * state)
|
|||
TH_PUSH_TAG(th);
|
||||
th->protect_tag = &protect_tag;
|
||||
MEMCPY(&org_jmpbuf, &(th)->root_jmpbuf, rb_jmpbuf_t, 1);
|
||||
if ((status = TH_EXEC_TAG()) == 0) {
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
SAVE_ROOT_JMPBUF(th, result = (*proc) (data));
|
||||
}
|
||||
else {
|
||||
|
@ -880,10 +880,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int * state)
|
|||
th->protect_tag = protect_tag.prev;
|
||||
TH_POP_TAG();
|
||||
|
||||
if (state) {
|
||||
*state = status;
|
||||
}
|
||||
|
||||
if (pstate != NULL) *pstate = state;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -901,7 +898,7 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
|
|||
ensure_list.next = th->ensure_list;
|
||||
th->ensure_list = &ensure_list;
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
result = (*b_proc) (data1);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
|
|
|
@ -175,7 +175,7 @@ rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo)
|
|||
rb_thread_raised_clear(th);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if (TH_EXEC_TAG() == 0) {
|
||||
if (TH_EXEC_TAG() == TAG_NONE) {
|
||||
errat = rb_get_backtrace(errinfo);
|
||||
}
|
||||
else if (errat == Qundef) {
|
||||
|
|
|
@ -160,14 +160,14 @@ LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *);
|
|||
static inline int
|
||||
rb_threadptr_tag_state(rb_thread_t *th)
|
||||
{
|
||||
int state = th->state;
|
||||
enum ruby_tag_type state = th->state;
|
||||
th->state = 0;
|
||||
return state;
|
||||
}
|
||||
|
||||
NORETURN(static inline void rb_threadptr_tag_jump(rb_thread_t *, int));
|
||||
NORETURN(static inline void rb_threadptr_tag_jump(rb_thread_t *, enum ruby_tag_type st));
|
||||
static inline void
|
||||
rb_threadptr_tag_jump(rb_thread_t *th, int st)
|
||||
rb_threadptr_tag_jump(rb_thread_t *th, enum ruby_tag_type st)
|
||||
{
|
||||
th->state = st;
|
||||
ruby_longjmp(th->tag->buf, 1);
|
||||
|
|
|
@ -113,13 +113,13 @@ exec_end_procs_chain(struct end_proc_data *volatile *procs, VALUE *errp)
|
|||
void
|
||||
rb_exec_end_proc(void)
|
||||
{
|
||||
int status;
|
||||
enum ruby_tag_type state;
|
||||
volatile int safe = rb_safe_level();
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
volatile VALUE errinfo = th->errinfo;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((status = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
again:
|
||||
exec_end_procs_chain(&ephemeral_end_procs, &th->errinfo);
|
||||
exec_end_procs_chain(&end_procs, &th->errinfo);
|
||||
|
@ -127,7 +127,7 @@ rb_exec_end_proc(void)
|
|||
else {
|
||||
VAR_INITIALIZED(th);
|
||||
TH_TMPPOP_TAG();
|
||||
error_handle(status);
|
||||
error_handle(state);
|
||||
if (!NIL_P(th->errinfo)) errinfo = th->errinfo;
|
||||
TH_REPUSH_TAG();
|
||||
goto again;
|
||||
|
|
11
gc.c
11
gc.c
|
@ -2777,7 +2777,7 @@ static void
|
|||
run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table)
|
||||
{
|
||||
long i;
|
||||
int status;
|
||||
enum ruby_tag_type state;
|
||||
volatile struct {
|
||||
VALUE errinfo;
|
||||
VALUE objid;
|
||||
|
@ -2795,15 +2795,16 @@ run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table)
|
|||
saved.finished = 0;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
status = TH_EXEC_TAG();
|
||||
if (status) {
|
||||
++saved.finished; /* skip failed finalizer */
|
||||
}
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
for (i = saved.finished;
|
||||
RESTORE_FINALIZER(), i<RARRAY_LEN(table);
|
||||
saved.finished = ++i) {
|
||||
run_single_final(RARRAY_AREF(table, i), saved.objid);
|
||||
}
|
||||
}
|
||||
else {
|
||||
++saved.finished; /* skip failed finalizer */
|
||||
}
|
||||
TH_POP_TAG();
|
||||
#undef RESTORE_FINALIZER
|
||||
}
|
||||
|
|
20
load.c
20
load.c
|
@ -579,7 +579,7 @@ const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
|
|||
static int
|
||||
rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
volatile VALUE wrapper = th->top_wrapper;
|
||||
volatile VALUE self = th->top_self;
|
||||
#if !defined __GNUC__
|
||||
|
@ -600,7 +600,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
|
|||
|
||||
TH_PUSH_TAG(th);
|
||||
state = EXEC_TAG();
|
||||
if (state == 0) {
|
||||
if (state == TAG_NONE) {
|
||||
NODE *node;
|
||||
const rb_iseq_t *iseq;
|
||||
|
||||
|
@ -665,19 +665,19 @@ rb_load(VALUE fname, int wrap)
|
|||
}
|
||||
|
||||
void
|
||||
rb_load_protect(VALUE fname, int wrap, int *state)
|
||||
rb_load_protect(VALUE fname, int wrap, int *pstate)
|
||||
{
|
||||
int status;
|
||||
enum ruby_tag_type state;
|
||||
volatile VALUE path = 0;
|
||||
|
||||
PUSH_TAG();
|
||||
if ((status = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
path = file_to_load(fname);
|
||||
}
|
||||
POP_TAG();
|
||||
if (!status) status = rb_load_internal0(GET_THREAD(), path, wrap);
|
||||
if (state)
|
||||
*state = status;
|
||||
|
||||
if (state != TAG_NONE) state = rb_load_internal0(GET_THREAD(), path, wrap);
|
||||
if (state != TAG_NONE) *pstate = state;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -961,7 +961,7 @@ rb_require_internal(VALUE fname, int safe)
|
|||
volatile int result = -1;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
volatile VALUE errinfo = th->errinfo;
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
struct {
|
||||
int safe;
|
||||
} volatile saved;
|
||||
|
@ -974,7 +974,7 @@ rb_require_internal(VALUE fname, int safe)
|
|||
|
||||
TH_PUSH_TAG(th);
|
||||
saved.safe = rb_safe_level();
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
long handle;
|
||||
int found;
|
||||
|
||||
|
|
4
proc.c
4
proc.c
|
@ -2049,10 +2049,10 @@ call_method_data_safe(rb_thread_t *th, const struct METHOD *data,
|
|||
int safe)
|
||||
{
|
||||
VALUE result = Qnil; /* OK */
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = TH_EXEC_TAG()) == 0) {
|
||||
if ((state = TH_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);
|
||||
|
|
4
signal.c
4
signal.c
|
@ -991,7 +991,7 @@ signal_exec(VALUE cmd, int safe, int sig)
|
|||
{
|
||||
rb_thread_t *cur_th = GET_THREAD();
|
||||
volatile unsigned long old_interrupt_mask = cur_th->interrupt_mask;
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
|
||||
/*
|
||||
* workaround the following race:
|
||||
|
@ -1004,7 +1004,7 @@ signal_exec(VALUE cmd, int safe, int sig)
|
|||
|
||||
cur_th->interrupt_mask |= TRAP_INTERRUPT_MASK;
|
||||
TH_PUSH_TAG(cur_th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
VALUE signum = INT2NUM(sig);
|
||||
rb_eval_cmd(cmd, rb_ary_new3(1, signum), safe);
|
||||
}
|
||||
|
|
18
thread.c
18
thread.c
|
@ -490,7 +490,7 @@ rb_thread_terminate_all(void)
|
|||
rb_threadptr_unlock_all_locking_mutexes(th);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if (TH_EXEC_TAG() == 0) {
|
||||
if (TH_EXEC_TAG() == TAG_NONE) {
|
||||
retry:
|
||||
thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th);
|
||||
terminate_all(vm, th);
|
||||
|
@ -597,7 +597,7 @@ thread_do_start(rb_thread_t *th, VALUE args)
|
|||
static int
|
||||
thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
VALUE args = th->first_args;
|
||||
rb_thread_list_t *join_list;
|
||||
rb_thread_t *main_th;
|
||||
|
@ -625,7 +625,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
|
|||
rb_thread_set_current(th);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
SAVE_ROOT_JMPBUF(th, thread_do_start(th, args));
|
||||
}
|
||||
else {
|
||||
|
@ -1444,7 +1444,7 @@ rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd)
|
|||
rb_vm_t *vm = GET_VM();
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
volatile int saved_errno = 0;
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
struct waiting_fd wfd;
|
||||
|
||||
wfd.fd = fd;
|
||||
|
@ -1452,7 +1452,7 @@ rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd)
|
|||
list_add(&vm->waiting_fds, &wfd.wfd_node);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
BLOCKING_REGION({
|
||||
val = func(data1);
|
||||
saved_errno = errno;
|
||||
|
@ -1865,7 +1865,7 @@ rb_thread_s_handle_interrupt(VALUE self, VALUE mask_arg)
|
|||
VALUE mask;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
volatile VALUE r = Qnil;
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
|
||||
if (!rb_block_given_p()) {
|
||||
rb_raise(rb_eArgError, "block is needed.");
|
||||
|
@ -1885,7 +1885,7 @@ rb_thread_s_handle_interrupt(VALUE self, VALUE mask_arg)
|
|||
}
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
r = rb_yield(Qnil);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
|
@ -4689,7 +4689,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
|
|||
return (*func)(obj, arg, TRUE);
|
||||
}
|
||||
else {
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
|
||||
p.func = func;
|
||||
|
||||
|
@ -4708,7 +4708,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
|
|||
volatile VALUE ret = Qundef;
|
||||
recursive_push(p.list, p.objid, p.pairid);
|
||||
PUSH_TAG();
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
ret = (*func)(obj, arg, FALSE);
|
||||
}
|
||||
POP_TAG();
|
||||
|
|
16
vm.c
16
vm.c
|
@ -1138,11 +1138,11 @@ vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
|
|||
int argc, const VALUE *argv, VALUE passed_block_handler)
|
||||
{
|
||||
VALUE val = Qundef;
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
volatile int stored_safe = th->safe_level;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
th->safe_level = proc->safe_level;
|
||||
val = invoke_block_from_c_proc(th, proc, self, argc, argv, passed_block_handler, proc->is_lambda);
|
||||
}
|
||||
|
@ -1777,19 +1777,19 @@ hook_before_rewind(rb_thread_t *th, const rb_control_frame_t *cfp, int will_fini
|
|||
static VALUE
|
||||
vm_exec(rb_thread_t *th)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
VALUE result;
|
||||
VALUE initial = 0;
|
||||
struct vm_throw_data *err;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
_tag.retval = Qnil;
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
vm_loop_start:
|
||||
result = vm_exec_core(th, initial);
|
||||
if ((state = th->state) != 0) {
|
||||
if ((state = th->state) != TAG_NONE) {
|
||||
err = (struct vm_throw_data *)result;
|
||||
th->state = 0;
|
||||
th->state = TAG_NONE;
|
||||
goto exception_handler;
|
||||
}
|
||||
}
|
||||
|
@ -1939,7 +1939,7 @@ vm_exec(rb_thread_t *th)
|
|||
#endif
|
||||
}
|
||||
th->errinfo = Qnil;
|
||||
th->state = 0;
|
||||
th->state = TAG_NONE;
|
||||
goto vm_loop_start;
|
||||
}
|
||||
}
|
||||
|
@ -1989,7 +1989,7 @@ vm_exec(rb_thread_t *th)
|
|||
catch_iseq->body->stack_max);
|
||||
|
||||
state = 0;
|
||||
th->state = 0;
|
||||
th->state = TAG_NONE;
|
||||
th->errinfo = Qnil;
|
||||
goto vm_loop_start;
|
||||
}
|
||||
|
|
|
@ -1174,7 +1174,7 @@ rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
|
|||
{
|
||||
rb_debug_inspector_t dbg_context;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
volatile VALUE MAYBE_UNUSED(result);
|
||||
|
||||
dbg_context.th = th;
|
||||
|
@ -1184,7 +1184,7 @@ rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
|
|||
dbg_context.contexts = collect_caller_bindings(th);
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
result = (*func)(&dbg_context, data);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
typedef unsigned long rb_num_t;
|
||||
|
||||
enum ruby_tag_type {
|
||||
RUBY_TAG_NONE = 0x0,
|
||||
RUBY_TAG_RETURN = 0x1,
|
||||
RUBY_TAG_BREAK = 0x2,
|
||||
RUBY_TAG_NEXT = 0x3,
|
||||
|
@ -159,6 +160,8 @@ enum ruby_tag_type {
|
|||
RUBY_TAG_FATAL = 0x8,
|
||||
RUBY_TAG_MASK = 0xf
|
||||
};
|
||||
|
||||
#define TAG_NONE RUBY_TAG_NONE
|
||||
#define TAG_RETURN RUBY_TAG_RETURN
|
||||
#define TAG_BREAK RUBY_TAG_BREAK
|
||||
#define TAG_NEXT RUBY_TAG_NEXT
|
||||
|
@ -741,7 +744,7 @@ typedef struct rb_thread_struct {
|
|||
VALUE last_status; /* $? */
|
||||
|
||||
/* passing state */
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
|
||||
/* for rb_iterate */
|
||||
VALUE passed_block_handler;
|
||||
|
|
32
vm_eval.c
32
vm_eval.c
|
@ -1105,7 +1105,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
|
|||
const struct vm_ifunc *const ifunc,
|
||||
rb_thread_t *const th)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
volatile VALUE retval = Qnil;
|
||||
rb_control_frame_t *const cfp = th->ec.cfp;
|
||||
|
||||
|
@ -1136,7 +1136,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
|
|||
rb_vm_rewind_cfp(th, cfp);
|
||||
|
||||
state = 0;
|
||||
th->state = 0;
|
||||
th->state = TAG_NONE;
|
||||
th->errinfo = Qnil;
|
||||
|
||||
if (state == TAG_RETRY) goto iter_retry;
|
||||
|
@ -1328,7 +1328,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
|
|||
}
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = TH_EXEC_TAG()) == 0) {
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
result = vm_exec(th);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
|
@ -1445,9 +1445,9 @@ rb_eval_string(const char *str)
|
|||
* @return The evaluated result if succeeded, an undefined value if otherwise.
|
||||
*/
|
||||
VALUE
|
||||
rb_eval_string_protect(const char *str, int *state)
|
||||
rb_eval_string_protect(const char *str, int *pstate)
|
||||
{
|
||||
return rb_protect((VALUE (*)(VALUE))rb_eval_string, (VALUE)str, state);
|
||||
return rb_protect((VALUE (*)(VALUE))rb_eval_string, (VALUE)str, pstate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1462,9 +1462,9 @@ rb_eval_string_protect(const char *str, int *state)
|
|||
* @return The evaluated result if succeeded, an undefined value if otherwise.
|
||||
*/
|
||||
VALUE
|
||||
rb_eval_string_wrap(const char *str, int *state)
|
||||
rb_eval_string_wrap(const char *str, int *pstate)
|
||||
{
|
||||
int status;
|
||||
int state;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
VALUE self = th->top_self;
|
||||
VALUE wrapper = th->top_wrapper;
|
||||
|
@ -1474,16 +1474,16 @@ rb_eval_string_wrap(const char *str, int *state)
|
|||
th->top_self = rb_obj_clone(rb_vm_top_self());
|
||||
rb_extend_object(th->top_self, th->top_wrapper);
|
||||
|
||||
val = rb_eval_string_protect(str, &status);
|
||||
val = rb_eval_string_protect(str, &state);
|
||||
|
||||
th->top_self = self;
|
||||
th->top_wrapper = wrapper;
|
||||
|
||||
if (state) {
|
||||
*state = status;
|
||||
if (pstate) {
|
||||
*pstate = state;
|
||||
}
|
||||
else if (status) {
|
||||
TH_JUMP_TAG(th, status);
|
||||
else if (state != TAG_NONE) {
|
||||
TH_JUMP_TAG(th, state);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -1491,7 +1491,7 @@ rb_eval_string_wrap(const char *str, int *state)
|
|||
VALUE
|
||||
rb_eval_cmd(VALUE cmd, VALUE arg, int level)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
volatile VALUE val = Qnil; /* OK */
|
||||
const int VAR_NOCLOBBERED(safe) = rb_safe_level();
|
||||
rb_thread_t *const VAR_NOCLOBBERED(th) = GET_THREAD();
|
||||
|
@ -1502,7 +1502,7 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
|
|||
|
||||
TH_PUSH_TAG(th);
|
||||
rb_set_safe_level_force(level);
|
||||
if ((state = TH_EXEC_TAG()) == 0) {
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
if (!RB_TYPE_P(cmd, T_STRING)) {
|
||||
val = rb_funcallv(cmd, idCall, RARRAY_LENINT(arg),
|
||||
RARRAY_CONST_PTR(arg));
|
||||
|
@ -1981,7 +1981,7 @@ static VALUE
|
|||
vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
|
||||
int *stateptr, rb_thread_t *volatile th)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
VALUE val = Qnil; /* OK */
|
||||
rb_control_frame_t *volatile saved_cfp = th->ec.cfp;
|
||||
|
||||
|
@ -1989,7 +1989,7 @@ vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
|
|||
|
||||
_tag.tag = tag;
|
||||
|
||||
if ((state = TH_EXEC_TAG()) == 0) {
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
/* call with argc=1, argv = [tag], block = Qnil to insure compatibility */
|
||||
val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil);
|
||||
}
|
||||
|
|
19
vm_trace.c
19
vm_trace.c
|
@ -284,7 +284,7 @@ exec_hooks_unprotected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg
|
|||
static int
|
||||
exec_hooks_protected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
|
||||
{
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
volatile int raised;
|
||||
|
||||
if (exec_hooks_precheck(th, list, trace_arg) == 0) return 0;
|
||||
|
@ -294,7 +294,7 @@ 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()) == 0) {
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
exec_hooks_body(th, list, trace_arg);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
|
@ -329,12 +329,12 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
|
|||
if (th->trace_arg == 0 && /* check reentrant */
|
||||
trace_arg->self != rb_mRubyVMFrozenCore /* skip special methods. TODO: remove it. */) {
|
||||
const VALUE errinfo = th->errinfo;
|
||||
const int outer_state = th->state;
|
||||
const enum ruby_tag_type outer_state = th->state;
|
||||
const VALUE old_recursive = th->local_storage_recursive_hash;
|
||||
int state = 0;
|
||||
|
||||
th->local_storage_recursive_hash = th->local_storage_recursive_hash_for_trace;
|
||||
th->state = 0;
|
||||
th->state = TAG_NONE;
|
||||
th->errinfo = Qnil;
|
||||
|
||||
th->vm->trace_running++;
|
||||
|
@ -387,10 +387,10 @@ VALUE
|
|||
rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
|
||||
{
|
||||
volatile int raised;
|
||||
volatile int outer_state;
|
||||
volatile enum ruby_tag_type outer_state;
|
||||
VALUE result = Qnil;
|
||||
rb_thread_t *volatile th = GET_THREAD();
|
||||
int state;
|
||||
enum ruby_tag_type state;
|
||||
const int tracing = th->trace_arg ? 1 : 0;
|
||||
rb_trace_arg_t dummy_trace_arg;
|
||||
dummy_trace_arg.event = 0;
|
||||
|
@ -400,10 +400,10 @@ rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
|
|||
|
||||
raised = rb_threadptr_reset_raised(th);
|
||||
outer_state = th->state;
|
||||
th->state = 0;
|
||||
th->state = TAG_NONE;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = TH_EXEC_TAG()) == 0) {
|
||||
if ((state = TH_EXEC_TAG()) == TAG_NONE) {
|
||||
result = (*func)(arg);
|
||||
}
|
||||
TH_POP_TAG();
|
||||
|
@ -1615,8 +1615,7 @@ rb_postponed_job_flush(rb_vm_t *vm)
|
|||
th->interrupt_mask |= block_mask;
|
||||
{
|
||||
TH_PUSH_TAG(th);
|
||||
EXEC_TAG();
|
||||
{
|
||||
if (EXEC_TAG() == TAG_NONE) {
|
||||
int index;
|
||||
while ((index = vm->postponed_job_index) > 0) {
|
||||
if (ATOMIC_CAS(vm->postponed_job_index, index, index-1) == index) {
|
||||
|
|
Loading…
Reference in a new issue