1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

th -> ec for rb_vm_rewind_cfp.

* vm.c (rb_vm_rewind_cfp): accepts `ec` instead of `th`.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-28 10:43:30 +00:00
parent 796e1990be
commit 9ca5088428
4 changed files with 28 additions and 28 deletions

40
eval.c
View file

@ -896,13 +896,13 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
VALUE (* r_proc) (ANYARGS), VALUE data2, ...) VALUE (* r_proc) (ANYARGS), VALUE data2, ...)
{ {
enum ruby_tag_type state; enum ruby_tag_type state;
rb_thread_t * volatile th = GET_THREAD(); rb_execution_context_t * volatile ec = GET_EC();
rb_control_frame_t *volatile cfp = th->ec->cfp; rb_control_frame_t *volatile cfp = ec->cfp;
volatile VALUE result = Qfalse; volatile VALUE result = Qfalse;
volatile VALUE e_info = th->ec->errinfo; volatile VALUE e_info = ec->errinfo;
va_list args; va_list args;
EC_PUSH_TAG(th->ec); EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) { if ((state = EC_EXEC_TAG()) == TAG_NONE) {
retry_entry: retry_entry:
result = (*b_proc) (data1); result = (*b_proc) (data1);
@ -911,13 +911,13 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
/* escape from r_proc */ /* escape from r_proc */
if (state == TAG_RETRY) { if (state == TAG_RETRY) {
state = 0; state = 0;
th->ec->errinfo = Qnil; ec->errinfo = Qnil;
result = Qfalse; result = Qfalse;
goto retry_entry; goto retry_entry;
} }
} }
else { else {
rb_vm_rewind_cfp(th, cfp); rb_vm_rewind_cfp(ec, cfp);
if (state == TAG_RAISE) { if (state == TAG_RAISE) {
int handle = FALSE; int handle = FALSE;
@ -925,7 +925,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
va_init_list(args, data2); va_init_list(args, data2);
while ((eclass = va_arg(args, VALUE)) != 0) { while ((eclass = va_arg(args, VALUE)) != 0) {
if (rb_obj_is_kind_of(th->ec->errinfo, eclass)) { if (rb_obj_is_kind_of(ec->errinfo, eclass)) {
handle = TRUE; handle = TRUE;
break; break;
} }
@ -936,15 +936,15 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
result = Qnil; result = Qnil;
state = 0; state = 0;
if (r_proc) { if (r_proc) {
result = (*r_proc) (data2, th->ec->errinfo); result = (*r_proc) (data2, ec->errinfo);
} }
th->ec->errinfo = e_info; ec->errinfo = e_info;
} }
} }
} }
EC_POP_TAG(); EC_POP_TAG();
if (state) if (state)
EC_JUMP_TAG(th->ec, state); EC_JUMP_TAG(ec, state);
return result; return result;
} }
@ -993,24 +993,24 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate)
{ {
volatile VALUE result = Qnil; volatile VALUE result = Qnil;
volatile enum ruby_tag_type state; volatile enum ruby_tag_type state;
rb_thread_t * volatile th = GET_THREAD(); rb_execution_context_t * volatile ec = GET_EC();
rb_control_frame_t *volatile cfp = th->ec->cfp; rb_control_frame_t *volatile cfp = ec->cfp;
struct rb_vm_protect_tag protect_tag; struct rb_vm_protect_tag protect_tag;
rb_jmpbuf_t org_jmpbuf; rb_jmpbuf_t org_jmpbuf;
protect_tag.prev = th->ec->protect_tag; protect_tag.prev = ec->protect_tag;
EC_PUSH_TAG(th->ec); EC_PUSH_TAG(ec);
th->ec->protect_tag = &protect_tag; ec->protect_tag = &protect_tag;
MEMCPY(&org_jmpbuf, &(th)->root_jmpbuf, rb_jmpbuf_t, 1); MEMCPY(&org_jmpbuf, &rb_ec_thread_ptr(ec)->root_jmpbuf, rb_jmpbuf_t, 1);
if ((state = EC_EXEC_TAG()) == TAG_NONE) { if ((state = EC_EXEC_TAG()) == TAG_NONE) {
SAVE_ROOT_JMPBUF(th, result = (*proc) (data)); SAVE_ROOT_JMPBUF(rb_ec_thread_ptr(ec), result = (*proc) (data));
} }
else { else {
rb_vm_rewind_cfp(th, cfp); rb_vm_rewind_cfp(ec, cfp);
} }
MEMCPY(&(th)->root_jmpbuf, &org_jmpbuf, rb_jmpbuf_t, 1); MEMCPY(&rb_ec_thread_ptr(ec)->root_jmpbuf, &org_jmpbuf, rb_jmpbuf_t, 1);
th->ec->protect_tag = protect_tag.prev; ec->protect_tag = protect_tag.prev;
EC_POP_TAG(); EC_POP_TAG();
if (pstate != NULL) *pstate = state; if (pstate != NULL) *pstate = state;

10
vm.c
View file

@ -542,15 +542,15 @@ rb_vm_pop_cfunc_frame(void)
} }
void void
rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp) rb_vm_rewind_cfp(rb_execution_context_t *ec, rb_control_frame_t *cfp)
{ {
/* check skipped frame */ /* check skipped frame */
while (th->ec->cfp != cfp) { while (ec->cfp != cfp) {
#if VMDEBUG #if VMDEBUG
printf("skipped frame: %s\n", vm_frametype_name(th->ec->cfp)); printf("skipped frame: %s\n", vm_frametype_name(ec->cfp));
#endif #endif
if (VM_FRAME_TYPE(th->ec->cfp) != VM_FRAME_MAGIC_CFUNC) { if (VM_FRAME_TYPE(ec->cfp) != VM_FRAME_MAGIC_CFUNC) {
rb_vm_pop_frame(th->ec); rb_vm_pop_frame(ec);
} }
else { /* unlikely path */ else { /* unlikely path */
rb_vm_pop_cfunc_frame(); rb_vm_pop_cfunc_frame();

View file

@ -1547,7 +1547,7 @@ VALUE rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method);
void rb_vm_stack_to_heap(rb_thread_t *th); void rb_vm_stack_to_heap(rb_thread_t *th);
void ruby_thread_init_stack(rb_thread_t *th); void ruby_thread_init_stack(rb_thread_t *th);
int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp); int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp);
void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp); void rb_vm_rewind_cfp(rb_execution_context_t *ec, rb_control_frame_t *cfp);
VALUE rb_vm_bh_to_procval(rb_execution_context_t *ec, VALUE block_handler); VALUE rb_vm_bh_to_procval(rb_execution_context_t *ec, VALUE block_handler);
void rb_vm_register_special_exception_str(enum ruby_special_exceptions sp, VALUE exception_class, VALUE mesg); void rb_vm_register_special_exception_str(enum ruby_special_exceptions sp, VALUE exception_class, VALUE mesg);

View file

@ -1136,7 +1136,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
const rb_control_frame_t *const escape_cfp = THROW_DATA_CATCH_FRAME(err); const rb_control_frame_t *const escape_cfp = THROW_DATA_CATCH_FRAME(err);
if (cfp == escape_cfp) { if (cfp == escape_cfp) {
rb_vm_rewind_cfp(th, cfp); rb_vm_rewind_cfp(th->ec, cfp);
state = 0; state = 0;
th->ec->tag->state = TAG_NONE; th->ec->tag->state = TAG_NONE;
@ -1995,7 +1995,7 @@ vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil); val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil);
} }
else if (state == TAG_THROW && THROW_DATA_VAL((struct vm_throw_data *)th->ec->errinfo) == tag) { else if (state == TAG_THROW && THROW_DATA_VAL((struct vm_throw_data *)th->ec->errinfo) == tag) {
rb_vm_rewind_cfp(th, saved_cfp); rb_vm_rewind_cfp(th->ec, saved_cfp);
val = th->ec->tag->retval; val = th->ec->tag->retval;
th->ec->errinfo = Qnil; th->ec->errinfo = Qnil;
state = 0; state = 0;