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

ruby-changes:62647

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Wed, 19 Aug 2020 15:11:19 +0900 (JST)
Subject: [ruby-changes:62647] 99093e1600 (master): RHASH_TBL: is now ext-only

https://git.ruby-lang.org/ruby.git/commit/?id=99093e1600

From 99093e1600ccef17ab99356b689573fcfd336ecc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Mon, 17 Aug 2020 11:12:23 +0900
Subject: RHASH_TBL: is now ext-only

It seems almost no internal codes use RHASH_TBL any longer.  Why not
just eliminate it entirely, so that the macro can be purely ext-only.

diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c
index 49f7ffa..5b29ea2 100644
--- a/ext/coverage/coverage.c
+++ b/ext/coverage/coverage.c
@@ -252,7 +252,8 @@ rb_coverage_peek_result(VALUE klass) https://github.com/ruby/ruby/blob/trunk/ext/coverage/coverage.c#L252
     if (!RTEST(coverages)) {
 	rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
     }
-    st_foreach(RHASH_TBL(coverages), coverage_peek_result_i, ncoverages);
+    OBJ_WB_UNPROTECT(coverages);
+    st_foreach(RHASH_TBL_RAW(coverages), coverage_peek_result_i, ncoverages);
 
     if (current_mode & COVERAGE_TARGET_METHODS) {
 	rb_objspace_each_objects(method_coverage_i, &ncoverages);
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index a9b1e64..262640d 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -141,7 +141,8 @@ setup_hash(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace.c#L141
         hash = rb_hash_new();
     }
     else if (!RHASH_EMPTY_P(hash)) {
-        st_foreach(RHASH_TBL(hash), set_zero_i, hash);
+        /* WB: no new reference */
+        st_foreach(RHASH_TBL_RAW(hash), set_zero_i, hash);
     }
 
     return hash;
diff --git a/hash.c b/hash.c
index a3853e8..2d22f8a 100644
--- a/hash.c
+++ b/hash.c
@@ -1620,23 +1620,16 @@ rb_hash_modify_check(VALUE hash) https://github.com/ruby/ruby/blob/trunk/hash.c#L1620
 }
 
 MJIT_FUNC_EXPORTED struct st_table *
-#if RHASH_CONVERT_TABLE_DEBUG
 rb_hash_tbl_raw(VALUE hash, const char *file, int line)
 {
     return ar_force_convert_table(hash, file, line);
 }
-#else
-rb_hash_tbl_raw(VALUE hash)
-{
-    return ar_force_convert_table(hash, NULL, 0);
-}
-#endif
 
 struct st_table *
 rb_hash_tbl(VALUE hash, const char *file, int line)
 {
     OBJ_WB_UNPROTECT(hash);
-    return RHASH_TBL_RAW(hash);
+    return rb_hash_tbl_raw(hash, file, line);
 }
 
 static void
diff --git a/internal.h b/internal.h
index 9d4478b..d033bc5 100644
--- a/internal.h
+++ b/internal.h
@@ -46,6 +46,7 @@ https://github.com/ruby/ruby/blob/trunk/internal.h#L46
 /* internal/hash.h */
 #undef RHASH_IFNONE
 #undef RHASH_SIZE
+#undef RHASH_TBL
 
 /* internal/object.h */
 #undef ROBJECT_IV_INDEX_TBL
diff --git a/internal/hash.h b/internal/hash.h
index f771025..73d71de 100644
--- a/internal/hash.h
+++ b/internal/hash.h
@@ -107,13 +107,8 @@ VALUE rb_hash_keys(VALUE hash); https://github.com/ruby/ruby/blob/trunk/internal/hash.h#L107
 VALUE rb_hash_has_key(VALUE hash, VALUE key);
 VALUE rb_hash_compare_by_id_p(VALUE hash);
 
-#if RHASH_CONVERT_TABLE_DEBUG
 st_table *rb_hash_tbl_raw(VALUE hash, const char *file, int line);
 #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
-#else
-st_table *rb_hash_tbl_raw(VALUE hash);
-#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
-#endif
 MJIT_SYMBOL_EXPORT_END
 
 #if 0 /* for debug */
diff --git a/struct.c b/struct.c
index bc89ec5..d62b6ca 100644
--- a/struct.c
+++ b/struct.c
@@ -388,9 +388,10 @@ struct_make_members_list(va_list ar) https://github.com/ruby/ruby/blob/trunk/struct.c#L388
 {
     char *mem;
     VALUE ary, list = rb_ident_hash_new();
-    st_table *tbl = RHASH_TBL(list);
+    st_table *tbl = RHASH_TBL_RAW(list);
 
     RBASIC_CLEAR_CLASS(list);
+    OBJ_WB_UNPROTECT(list);
     while ((mem = va_arg(ar, char*)) != 0) {
 	VALUE sym = rb_sym_intern_ascii_cstr(mem);
 	if (st_insert(tbl, sym, Qtrue)) {
@@ -583,7 +584,8 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass) https://github.com/ruby/ruby/blob/trunk/struct.c#L584
 
     rest = rb_ident_hash_new();
     RBASIC_CLEAR_CLASS(rest);
-    tbl = RHASH_TBL(rest);
+    OBJ_WB_UNPROTECT(rest);
+    tbl = RHASH_TBL_RAW(rest);
     for (i=0; i<argc; i++) {
 	VALUE mem = rb_to_symbol(argv[i]);
         if (rb_is_attrset_sym(mem)) {
-- 
cgit v0.10.2


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

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