[前][次][番号順一覧][スレッド一覧]

ruby-changes:39211

From: nobu <ko1@a...>
Date: Sat, 18 Jul 2015 20:45:16 +0900 (JST)
Subject: [ruby-changes:39211] nobu:r51292 (trunk): load.c: reduce EXEC_TAGs

nobu	2015-07-18 20:44:59 +0900 (Sat, 18 Jul 2015)

  New Revision: 51292

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51292

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/load.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51291)
+++ ChangeLog	(revision 51292)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jul 18 20:44:56 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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.
+
 Sat Jul 18 19:52:17 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* gc.c (run_finalizer): set and restore safe level here to reduce
Index: load.c
===================================================================
--- load.c	(revision 51291)
+++ load.c	(revision 51292)
@@ -573,7 +573,7 @@ rb_provide(const char *feature) https://github.com/ruby/ruby/blob/trunk/load.c#L573
 
 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 https://github.com/ruby/ruby/blob/trunk/load.c#L623
 
     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;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]