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

ruby-changes:66472

From: Nobuyoshi <ko1@a...>
Date: Mon, 14 Jun 2021 14:12:24 +0900 (JST)
Subject: [ruby-changes:66472] 635e1c5282 (master): Pack values to preserve

https://git.ruby-lang.org/ruby.git/commit/?id=635e1c5282

From 635e1c5282a4207281ad8ed698e77547648b2ce9 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 14 Jun 2021 13:52:26 +0900
Subject: Pack values to preserve

---
 load.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/load.c b/load.c
index b4c73e1..e8deb40 100644
--- a/load.c
+++ b/load.c
@@ -1028,9 +1028,11 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception) https://github.com/ruby/ruby/blob/trunk/load.c#L1028
 {
     volatile int result = -1;
     rb_thread_t *th = rb_ec_thread_ptr(ec);
-    volatile VALUE wrapper = th->top_wrapper;
-    volatile VALUE self = th->top_self;
-    volatile VALUE errinfo = ec->errinfo;
+    volatile const struct {
+        VALUE wrapper, self, errinfo;
+    } saved = {
+        th->top_wrapper, th->top_self, ec->errinfo,
+    };
     enum ruby_tag_type state;
     char *volatile ftptr = 0;
     VALUE path;
@@ -1082,8 +1084,8 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception) https://github.com/ruby/ruby/blob/trunk/load.c#L1084
     EC_POP_TAG();
 
     rb_thread_t *th2 = rb_ec_thread_ptr(ec);
-    th2->top_self = self;
-    th2->top_wrapper = wrapper;
+    th2->top_self = saved.self;
+    th2->top_wrapper = saved.wrapper;
     if (reset_ext_config) ext_config_pop(th2, &prev_ext_config);
 
     if (ftptr) load_unlock(RSTRING_PTR(path), !state);
@@ -1112,7 +1114,7 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception) https://github.com/ruby/ruby/blob/trunk/load.c#L1114
     }
 
     if (result == TAG_RETURN) rb_provide_feature(path);
-    ec->errinfo = errinfo;
+    ec->errinfo = saved.errinfo;
 
     RUBY_DTRACE_HOOK(REQUIRE_RETURN, RSTRING_PTR(fname));
 
-- 
cgit v1.1


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

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