* vm_eval.c (vm_catch_protect): accepts ec instead of th.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-29 15:03:33 +00:00
parent a034fc81a9
commit 9ffc0d19b7

View File

@ -1984,13 +1984,13 @@ rb_catch(const char *tag, VALUE (*func)(), VALUE data)
static VALUE static VALUE
vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data, vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
enum ruby_tag_type *stateptr, rb_thread_t *volatile th) enum ruby_tag_type *stateptr, rb_execution_context_t *volatile ec)
{ {
enum ruby_tag_type state; enum ruby_tag_type state;
VALUE val = Qnil; /* OK */ VALUE val = Qnil; /* OK */
rb_control_frame_t *volatile saved_cfp = th->ec->cfp; rb_control_frame_t *volatile saved_cfp = ec->cfp;
EC_PUSH_TAG(th->ec); EC_PUSH_TAG(ec);
_tag.tag = tag; _tag.tag = tag;
@ -1998,10 +1998,10 @@ vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
/* call with argc=1, argv = [tag], block = Qnil to insure compatibility */ /* call with argc=1, argv = [tag], block = Qnil to insure compatibility */
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 *)ec->errinfo) == tag) {
rb_vm_rewind_cfp(th->ec, saved_cfp); rb_vm_rewind_cfp(ec, saved_cfp);
val = th->ec->tag->retval; val = ec->tag->retval;
th->ec->errinfo = Qnil; ec->errinfo = Qnil;
state = 0; state = 0;
} }
EC_POP_TAG(); EC_POP_TAG();
@ -2014,16 +2014,16 @@ vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
VALUE VALUE
rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr) rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr)
{ {
return vm_catch_protect(t, func, data, stateptr, GET_THREAD()); return vm_catch_protect(t, func, data, stateptr, GET_EC());
} }
VALUE VALUE
rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data) rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data)
{ {
enum ruby_tag_type state; enum ruby_tag_type state;
rb_thread_t *th = GET_THREAD(); rb_execution_context_t *ec = GET_EC();
VALUE val = vm_catch_protect(t, (rb_block_call_func *)func, data, &state, th); VALUE val = vm_catch_protect(t, (rb_block_call_func *)func, data, &state, ec);
if (state) EC_JUMP_TAG(th->ec, state); if (state) EC_JUMP_TAG(ec, state);
return val; return val;
} }