From d352d0a0a7851bc3a8d0352bf25a15836ee92e93 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 25 Sep 2017 21:51:56 +0000 Subject: [PATCH] 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 --- load.c | 2 ++ vm.c | 46 +++++++++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/load.c b/load.c index eec5e98947..d2ed55fed2 100644 --- a/load.c +++ b/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; diff --git a/vm.c b/vm.c index a807d01140..aec75da9ef 100644 --- a/vm.c +++ b/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