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

ruby-changes:71887

From: Koichi <ko1@a...>
Date: Fri, 20 May 2022 17:38:10 +0900 (JST)
Subject: [ruby-changes:71887] 37ea07d59b (master): setup vm->main_ractor before `Init_native_thread()`

https://git.ruby-lang.org/ruby.git/commit/?id=37ea07d59b

From 37ea07d59be53bd447d2d87d9cd56f94d41a40dd Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Fri, 20 May 2022 16:04:10 +0900
Subject: setup vm->main_ractor before `Init_native_thread()`

---
 vm.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/vm.c b/vm.c
index 67189987f1..3b478d848a 100644
--- a/vm.c
+++ b/vm.c
@@ -3249,11 +3249,9 @@ rb_ec_clear_vm_stack(rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/vm.c#L3249
 }
 
 static void
-th_init(rb_thread_t *th, VALUE self, rb_vm_t *vm, rb_ractor_t *r)
+th_init(rb_thread_t *th, VALUE self, rb_vm_t *vm)
 {
     th->self = self;
-    th->vm = vm;
-    th->ractor = r;
 
     rb_threadptr_root_fiber_setup(th);
 
@@ -3304,7 +3302,8 @@ rb_thread_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/vm.c#L3302
 {
     VALUE self = thread_alloc(klass);
     rb_thread_t *target_th = rb_thread_ptr(self);
-    th_init(target_th, self, GET_VM(), GET_RACTOR());
+    target_th->ractor = GET_RACTOR();
+    th_init(target_th, self, target_th->vm = GET_VM());
     return self;
 }
 
@@ -3955,8 +3954,10 @@ Init_BareVM(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L3954
 
     // setup main thread
     th->nt = ZALLOC(struct rb_native_thread);
+    th->vm = vm;
+    th->ractor = vm->ractor.main_ractor = rb_ractor_main_alloc();
     Init_native_thread(th);
-    th_init(th, 0, vm, vm->ractor.main_ractor = rb_ractor_main_alloc());
+    th_init(th, 0, vm);
 
     rb_ractor_set_current_ec(th->ractor, th->ec);
     ruby_thread_init_stack(th);
-- 
cgit v1.2.1


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

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