vm.c: fetch retval iff necessary

* vm.c (rb_vm_make_jump_tag_but_local_jump): get rid of fetching
  retval when it is not used.  it is necessary for local jump
  state only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-09-25 21:51:56 +00:00
Родитель 4ea46ca0f5
Коммит d352d0a0a7
2 изменённых файлов: 25 добавлений и 23 удалений

2
load.c
Просмотреть файл

@ -627,6 +627,8 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
th->top_wrapper = wrapper;
if (state) {
/* usually state == TAG_RAISE only, except for
* rb_iseq_load_iseq case */
VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef);
if (NIL_P(exc)) return state;
th->ec.errinfo = exc;

46
vm.c
Просмотреть файл

@ -1421,33 +1421,33 @@ rb_vm_localjump_error(const char *mesg, VALUE value, int reason)
VALUE
rb_vm_make_jump_tag_but_local_jump(int state, VALUE val)
{
VALUE result = Qnil;
const char *mesg;
switch (state) {
case TAG_RETURN:
mesg = "unexpected return";
break;
case TAG_BREAK:
mesg = "unexpected break";
break;
case TAG_NEXT:
mesg = "unexpected next";
break;
case TAG_REDO:
mesg = "unexpected redo";
val = Qnil;
break;
case TAG_RETRY:
mesg = "retry outside of rescue clause";
val = Qnil;
break;
default:
return Qnil;
}
if (val == Qundef) {
val = GET_THREAD()->ec.tag->retval;
}
switch (state) {
case 0:
break;
case TAG_RETURN:
result = make_localjump_error("unexpected return", val, state);
break;
case TAG_BREAK:
result = make_localjump_error("unexpected break", val, state);
break;
case TAG_NEXT:
result = make_localjump_error("unexpected next", val, state);
break;
case TAG_REDO:
result = make_localjump_error("unexpected redo", Qnil, state);
break;
case TAG_RETRY:
result = make_localjump_error("retry outside of rescue clause", Qnil, state);
break;
default:
break;
}
return result;
return make_localjump_error(mesg, val, state);
}
void