From 99310e3eb56fbc85bb45119285812eb959448d0c Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Tue, 20 Oct 2020 10:46:43 +0900 Subject: Some global variables can be accessed from ractors Some global variables should be used from non-main Ractors. [Bug #17268] ```ruby # ractor-local (derived from created ractor): debug '$DEBUG' => $DEBUG, '$-d' => $-d, # ractor-local (derived from created ractor): verbose '$VERBOSE' => $VERBOSE, '$-w' => $-w, '$-W' => $-W, '$-v' => $-v, # process-local (readonly): other commandline parameters '$-p' => $-p, '$-l' => $-l, '$-a' => $-a, # process-local (readonly): getpid '$$' => $$, # thread local: process result '$?' => $?, # scope local: match '$~' => $~.inspect, '$&' => $&, '$`' => $`, '$\'' => $', '$+' => $+, '$1' => $1, # scope local: last line '$_' => $_, # scope local: last backtrace '$@' => $@, '$!' => $!, # ractor local: stdin, out, err '$stdin' => $stdin.inspect, '$stdout' => $stdout.inspect, '$stderr' => $stderr.inspect, ``` --- vm.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 879814a14b..ada33ae87b 100644 --- a/vm.c +++ b/vm.c @@ -3515,28 +3515,18 @@ Init_top_self(void) rb_define_alias(rb_singleton_class(rb_vm_top_self()), "inspect", "to_s"); } -static VALUE * -ruby_vm_verbose_ptr(rb_vm_t *vm) -{ - return &vm->verbose; -} - -static VALUE * -ruby_vm_debug_ptr(rb_vm_t *vm) -{ - return &vm->debug; -} - VALUE * rb_ruby_verbose_ptr(void) { - return ruby_vm_verbose_ptr(GET_VM()); + rb_ractor_t *cr = GET_RACTOR(); + return &cr->verbose; } VALUE * rb_ruby_debug_ptr(void) { - return ruby_vm_debug_ptr(GET_VM()); + rb_ractor_t *cr = GET_RACTOR(); + return &cr->debug; } /* iseq.c */ -- cgit v1.2.3