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

ruby-changes:71622

From: Kevin <ko1@a...>
Date: Tue, 5 Apr 2022 03:41:22 +0900 (JST)
Subject: [ruby-changes:71622] 42000664be (master): Bring back RubyVM.stat(:global_constant_state)

https://git.ruby-lang.org/ruby.git/commit/?id=42000664be

From 42000664be43f8c70322557703003b9141cfb28f Mon Sep 17 00:00:00 2001
From: Kevin Newton <kddnewton@g...>
Date: Mon, 4 Apr 2022 12:24:06 -0400
Subject: Bring back RubyVM.stat(:global_constant_state)

This was removed as part of [Feature #18589]. But some applications were relying on this behavior. So bringing this back to make it better for backward compatibility going forward.
---
 vm.c            | 4 +++-
 vm_insnhelper.h | 1 +
 vm_method.c     | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/vm.c b/vm.c
index dcb863dd96..c02d502f37 100644
--- a/vm.c
+++ b/vm.c
@@ -529,7 +529,7 @@ vm_stat_constant_cache_i(ID id, VALUE table, void *constant_cache) https://github.com/ruby/ruby/blob/trunk/vm.c#L529
 static VALUE
 vm_stat(int argc, VALUE *argv, VALUE self)
 {
-    static VALUE sym_constant_cache, sym_class_serial, sym_global_cvar_state;
+    static VALUE sym_global_constant_state, sym_constant_cache, sym_class_serial, sym_global_cvar_state;
     VALUE arg = Qnil;
     VALUE hash = Qnil, key = Qnil;
 
@@ -547,6 +547,7 @@ vm_stat(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L547
     }
 
 #define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
+    S(global_constant_state);
 	S(constant_cache);
 	S(class_serial);
 	S(global_cvar_state);
@@ -558,6 +559,7 @@ vm_stat(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L559
     else if (hash != Qnil) \
 	rb_hash_aset(hash, sym_##name, SERIALT2NUM(attr));
 
+    SET(global_constant_state, ruby_vm_global_constant_state);
     SET(class_serial, ruby_vm_class_serial);
     SET(global_cvar_state, ruby_vm_global_cvar_state);
 #undef SET
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index e26ecfa77c..5506fca4d6 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -14,6 +14,7 @@ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L14
 MJIT_SYMBOL_EXPORT_BEGIN
 
 RUBY_EXTERN VALUE ruby_vm_const_missing_count;
+RUBY_EXTERN rb_serial_t ruby_vm_global_constant_state;
 RUBY_EXTERN rb_serial_t ruby_vm_class_serial;
 RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state;
 
diff --git a/vm_method.c b/vm_method.c
index 1f472efb91..81e88a32c1 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -147,6 +147,7 @@ rb_clear_constant_cache_for_id(ID id) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L147
     }
 
     rb_yjit_constant_state_changed();
+    ruby_vm_global_constant_state++;
 }
 
 static void
-- 
cgit v1.2.1


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

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