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

ruby-changes:66150

From: Aaron <ko1@a...>
Date: Wed, 12 May 2021 05:31:28 +0900 (JST)
Subject: [ruby-changes:66150] 07f055bb13 (master): Revert "Filling cache values on cvar write"

https://git.ruby-lang.org/ruby.git/commit/?id=07f055bb13

From 07f055bb132f21fd71af2720382ad8d2e8f69e47 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Tue, 11 May 2021 13:30:40 -0700
Subject: Revert "Filling cache values on cvar write"

This reverts commit 08de37f9fa3469365e6b5c964689ae2bae0eb9f3.
This reverts commit e8ae922b62adb00a80d3d4c49f7d7b0e6026eaba.
---
 benchmark/vm_cvar.yml                   | 20 -------
 class.c                                 |  6 ---
 common.mk                               |  1 -
 compile.c                               | 10 ++--
 debug_counter.h                         |  6 ---
 gc.c                                    | 36 -------------
 id_table.c                              |  6 +--
 include/ruby/internal/intern/variable.h |  1 -
 insns.def                               | 10 ++--
 internal/class.h                        |  8 ---
 variable.c                              | 92 +++------------------------------
 vm.c                                    |  5 +-
 vm_core.h                               |  5 --
 vm_insnhelper.c                         | 84 +-----------------------------
 vm_insnhelper.h                         |  3 --
 15 files changed, 22 insertions(+), 271 deletions(-)
 delete mode 100644 benchmark/vm_cvar.yml

diff --git a/benchmark/vm_cvar.yml b/benchmark/vm_cvar.yml
deleted file mode 100644
index 1d0e161..0000000
--- a/benchmark/vm_cvar.yml
+++ /dev/null
@@ -1,20 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/#L0
-prelude: |
-  class A
-    @@foo = 1
-
-    def self.foo
-      @@foo
-    end
-
-    ("A".."Z").each do |module_name|
-      eval <<-EOM
-        module #{module_name}
-        end
-
-        include #{module_name}
-      EOM
-    end
-  end
-benchmark:
-  vm_cvar: A.foo
-loop_count: 600000
diff --git a/class.c b/class.c
index ef3db6d..9ac2b3f 100644
--- a/class.c
+++ b/class.c
@@ -27,7 +27,6 @@ https://github.com/ruby/ruby/blob/trunk/class.c#L27
 #include <ctype.h>
 
 #include "constant.h"
-#include "debug_counter.h"
 #include "id_table.h"
 #include "internal.h"
 #include "internal/class.h"
@@ -44,8 +43,6 @@ https://github.com/ruby/ruby/blob/trunk/class.c#L43
 #define METACLASS_OF(k) RBASIC(k)->klass
 #define SET_METACLASS_OF(k, cls) RBASIC_SET_CLASS(k, cls)
 
-RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state;
-
 void
 rb_class_subclass_add(VALUE super, VALUE klass)
 {
@@ -960,7 +957,6 @@ rb_include_class_new(VALUE module, VALUE super) https://github.com/ruby/ruby/blob/trunk/class.c#L957
 	RCLASS_CONST_TBL(module) = rb_id_table_create(0);
     }
     RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
-    RCLASS_CVC_TBL(klass) = RCLASS_CVC_TBL(module);
     RCLASS_CONST_TBL(klass) = RCLASS_CONST_TBL(module);
 
     RCLASS_SET_SUPER(klass, super);
@@ -1089,8 +1085,6 @@ do_include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super https://github.com/ruby/ruby/blob/trunk/class.c#L1085
         VALUE super_class = RCLASS_SUPER(c);
 
         // invalidate inline method cache
-        RB_DEBUG_COUNTER_INC(cvar_include_invalidate);
-        ruby_vm_global_cvar_state++;
         tbl = RCLASS_M_TBL(module);
         if (tbl && rb_id_table_size(tbl)) {
             if (search_super) { // include
diff --git a/common.mk b/common.mk
index 5d8bad6..f3aa284 100644
--- a/common.mk
+++ b/common.mk
@@ -2458,7 +2458,6 @@ class.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h https://github.com/ruby/ruby/blob/trunk/common.mk#L2458
 class.$(OBJEXT): {$(VPATH)}class.c
 class.$(OBJEXT): {$(VPATH)}config.h
 class.$(OBJEXT): {$(VPATH)}constant.h
-class.$(OBJEXT): {$(VPATH)}debug_counter.h
 class.$(OBJEXT): {$(VPATH)}defines.h
 class.$(OBJEXT): {$(VPATH)}encoding.h
 class.$(OBJEXT): {$(VPATH)}id.h
diff --git a/compile.c b/compile.c
index fa6af03..a3a828f 100644
--- a/compile.c
+++ b/compile.c
@@ -8044,9 +8044,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in https://github.com/ruby/ruby/blob/trunk/compile.c#L8044
 	if (!popped) {
 	    ADD_INSN(ret, line_node, dup);
 	}
-        ADD_INSN2(ret, line_node, setclassvariable,
-                  ID2SYM(node->nd_vid),
-                  get_ivar_ic_value(iseq,node->nd_vid));
+	ADD_INSN1(ret, line_node, setclassvariable,
+		  ID2SYM(node->nd_vid));
 	break;
       }
       case NODE_OP_ASGN1: {
@@ -8669,9 +8668,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in https://github.com/ruby/ruby/blob/trunk/compile.c#L8668
       }
       case NODE_CVAR:{
 	if (!popped) {
-	    ADD_INSN2(ret, line_node, getclassvariable,
-		      ID2SYM(node->nd_vid),
-		      get_ivar_ic_value(iseq,node->nd_vid));
+	    ADD_INSN1(ret, line_node, getclassvariable,
+		      ID2SYM(node->nd_vid));
 	}
 	break;
       }
diff --git a/debug_counter.h b/debug_counter.h
index 3cf80cc..9452f4c 100644
--- a/debug_counter.h
+++ b/debug_counter.h
@@ -24,12 +24,6 @@ RB_DEBUG_COUNTER(mc_inline_miss_same_cme)    // IMC miss, but same CME https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L24
 RB_DEBUG_COUNTER(mc_inline_miss_same_def)    // IMC miss, but same definition
 RB_DEBUG_COUNTER(mc_inline_miss_diff)        // IMC miss, different methods
 
-RB_DEBUG_COUNTER(cvar_write_inline_hit)      // cvar cache hit on write
-RB_DEBUG_COUNTER(cvar_read_inline_hit)       // cvar cache hit on read
-RB_DEBUG_COUNTER(cvar_inline_miss)           // miss inline cache
-RB_DEBUG_COUNTER(cvar_class_invalidate)      // invalidate cvar cache when define a cvar that's defined on a subclass
-RB_DEBUG_COUNTER(cvar_include_invalidate)    // invalidate cvar cache on module include or prepend
-
 RB_DEBUG_COUNTER(mc_cme_complement)          // number of acquiring complement CME
 RB_DEBUG_COUNTER(mc_cme_complement_hit)      // number of cache hit for complemented CME
 
diff --git a/gc.c b/gc.c
index b0837c3..3adc526 100644
--- a/gc.c
+++ b/gc.c
@@ -3003,13 +3003,6 @@ cc_table_free(rb_objspace_t *objspace, VALUE klass, bool alive) https://github.com/ruby/ruby/blob/trunk/gc.c#L3003
     }
 }
 
-static enum rb_id_table_iterator_result
-cvar_table_free_i(VALUE value, void * ctx)
-{
-    xfree((void *) value);
-    return ID_TABLE_CONTINUE;
-}
-
 void
 rb_cc_table_free(VALUE klass)
 {
@@ -3121,10 +3114,6 @@ obj_free(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L3114
 	if (RCLASS_IV_INDEX_TBL(obj)) {
             iv_index_tbl_free(RCLASS_IV_INDEX_TBL(obj));
 	}
-	if (RCLASS_CVC_TBL(obj)) {
-            rb_id_table_foreach_values(RCLASS_CVC_TBL(obj), cvar_table_free_i, NULL);
-            rb_id_table_free(RCLASS_CVC_TBL(obj));
-	}
 	if (RCLASS_SUBCLASSES(obj)) {
 	    if (BUILTIN_TYPE(obj) == T_MODULE) {
 		rb_class_detach_module_subclasses(obj);
@@ -4568,9 +4557,6 @@ obj_memsize_of(VALUE obj, int use_all_types) https://github.com/ruby/ruby/blob/trunk/gc.c#L4557
 	    if (RCLASS_IV_TBL(obj)) {
 		size += st_memsize(RCLASS_IV_TBL(obj));
 	    }
-	    if (RCLASS_CVC_TBL(obj)) {
-		size += rb_id_table_memsize(RCLASS_CVC_TBL(obj));
-	    }
 	    if (RCLASS_IV_INDEX_TBL(obj)) {
                 // TODO: more correct value
 		size += st_memsize(RCLASS_IV_INDEX_TBL(obj));
@@ -9618,27 +9604,6 @@ update_cc_tbl(rb_objspace_t *objspace, VALUE klass) https://github.com/ruby/ruby/blob/trunk/gc.c#L9604
 }
 
 static enum rb_id_table_iterator_result
-update_cvc_tbl_i(ID id, VALUE cvc_entry, void *data)
-{
-    struct rb_cvar_class_tbl_entry *entry;
-
-    entry = (struct rb_cvar_class_tbl_entry *)cvc_entry;
-
-    entry->class_value = rb_gc_location(entry->class_value);
-
-    return ID_TABLE_CONTINUE;
-}
-
-static void
-update_cvc_tbl(rb_objspace_t *objspace, VALUE klass)
-{
-    struct rb_id_table *tbl = RCLASS_CVC_TBL(klass);
-    if (tbl) {
-        rb_id_table_foreach_with_replace(tbl, update_cvc_tbl_i, 0, objspace);
-    }
-}
-
-static enum rb_id_table_iterator_result
 update_const_table(VALUE value, void *data)
 {
     rb_const_entry_t *ce = (rb_const_entry_t *)value;
@@ -9709,7 +9674,6 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L9674
         if (!RCLASS_EXT(obj)) break;
         update_m_tbl(objspace, RCLASS_M_TBL(obj));
         update_cc_tbl(objspace, obj);
-        update_cvc_tbl(objspace, obj);
 
         gc_update_tbl_refs(objspace, RCLASS_IV_TBL(obj));
 
diff --git a/id_table.c b/id_table.c
index 149f52c..840ab46 100644
--- a/id_table.c
+++ b/id_table.c
@@ -92,7 +92,7 @@ rb_id_table_init(struct rb_id_table *tbl, int capa) https://github.com/ruby/ruby/blob/trunk/id_table.c#L92
     return tbl;
 }
 
-MJIT_FUNC_EXPORTED struct rb_id_table *
+struct rb_id_table *
 rb_id_table_create(size_t capa)
 {
     struct rb_id_table *tbl = ALLOC(struct rb_id_table);
@@ -223,7 +223,7 @@ hash_table_show(struct rb_id_table *tbl) https://github.com/ruby/ruby/blob/trunk/id_table.c#L223
 }
 #endif
 
-MJIT_FUNC_EXPORTED int
+int
 rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp)
 {
     id_key_t key = id2key(id);
@@ -253,7 +253,7 @@ rb_id_table_insert_key(struct rb_id_table *tbl, const id_key_t key, const VALUE https://github.com/ruby/ruby/blob/trunk/id_table.c#L253
     return TRUE;
 }
 
-MJIT_FUNC_EXPORTED int
+int
 rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val)
 {
     return rb_id_table_insert_key(tbl, id2key(id), val);
diff --git a/include/ruby/internal/intern/variable.h b/include/ruby/internal/intern/variable.h
index faa0cc0..8210662 100644
--- a/include/ruby/internal/intern/variable.h
+++ b/include/ruby/internal/intern/variable.h
@@ -72,7 +72,6 @@ VALUE rb_mod_const_missing(VALUE,VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/intern/variable.h#L72
 VALUE rb_cvar_defined(VALUE, ID);
 void rb_cvar_set(VALUE, ID, VALUE);
 VALUE rb_cvar_get(VALUE, ID);
-VALUE rb_cvar_find(VALUE, ID, VALUE*);
 void rb_cv_set(VALUE, const char*, VALUE);
 VALUE rb_cv_get(VALUE, const char*);
 void rb_define_class_variable(VALUE, const char*, VALUE);
diff --git a/insns.def b/insns.def
index e1e4577..8d60992 100644
--- a/insns.d (... truncated)

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

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