aboutsummaryrefslogtreecommitdiffstats
path: root/load.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-18 11:44:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-18 11:44:59 +0000
commit1998039ea4f867583d7e37ce200a88490707c330 (patch)
tree1ee4261d97284369547e0606255aa58dd86955d6 /load.c
parente9e08a5b105a3ea8ea54a856e977376d2dcd1ab9 (diff)
downloadruby-1998039ea4f867583d7e37ce200a88490707c330.tar.gz
load.c: reduce EXEC_TAGs
* load.c (rb_load_internal0): do not raise any exceptions but return the result tag state. * load.c (rb_load_protect): reduce nested EXEC_TAGs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'load.c')
-rw-r--r--load.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/load.c b/load.c
index 91122c73cc..8ce5a2fadb 100644
--- a/load.c
+++ b/load.c
@@ -573,7 +573,7 @@ rb_provide(const char *feature)
NORETURN(static void load_failed(VALUE));
-static inline void
+static int
rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
{
int state;
@@ -623,42 +623,59 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
if (!loaded && !FIXNUM_P(th->errinfo)) {
/* an error on loading don't include INT2FIX(TAG_FATAL) see r35625 */
- rb_exc_raise(th->errinfo);
+ return TAG_RAISE;
}
if (state) {
- rb_vm_jump_tag_but_local_jump(state);
+ VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef);
+ if (NIL_P(exc)) return state;
+ th->errinfo = exc;
+ return TAG_RAISE;
}
if (!NIL_P(th->errinfo)) {
/* exception during load */
- rb_exc_raise(th->errinfo);
+ return TAG_RAISE;
}
+ return state;
}
static void
rb_load_internal(VALUE fname, int wrap)
{
- rb_load_internal0(GET_THREAD(), fname, wrap);
+ rb_thread_t *curr_th = GET_THREAD();
+ int state = rb_load_internal0(curr_th, fname, wrap);
+ if (state) {
+ if (state == TAG_RAISE) rb_exc_raise(curr_th->errinfo);
+ JUMP_TAG(state);
+ }
}
-void
-rb_load(VALUE fname, int wrap)
+static VALUE
+file_to_load(VALUE fname)
{
VALUE tmp = rb_find_file(FilePathValue(fname));
if (!tmp) load_failed(fname);
- rb_load_internal(tmp, wrap);
+ return tmp;
+}
+
+void
+rb_load(VALUE fname, int wrap)
+{
+ rb_load_internal(file_to_load(fname), wrap);
}
void
rb_load_protect(VALUE fname, int wrap, int *state)
{
int status;
+ volatile VALUE path = 0;
PUSH_TAG();
if ((status = EXEC_TAG()) == 0) {
- rb_load(fname, wrap);
+ path = file_to_load(fname);
}
POP_TAG();
+ if (!status) status = rb_load_internal0(GET_THREAD(), path, wrap);
if (state)
*state = status;
}