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

ruby-changes:72462

From: Aaron <ko1@a...>
Date: Fri, 8 Jul 2022 03:56:37 +0900 (JST)
Subject: [ruby-changes:72462] 3cf2c2e4a1 (master): Remove ISEQ_MARKABLE_ISEQ flag

https://git.ruby-lang.org/ruby.git/commit/?id=3cf2c2e4a1

From 3cf2c2e4a111f621c3c23029a55edebf00bbe1b0 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Thu, 30 Jun 2022 10:38:48 -0700
Subject: Remove ISEQ_MARKABLE_ISEQ flag

We don't need this flag anymore.  We have all the info we need via the
bitmap and the is_entries list.
---
 compile.c | 11 ---------
 iseq.c    | 82 +++++++++++++++++++++++++++++++--------------------------------
 iseq.h    |  1 -
 3 files changed, 41 insertions(+), 53 deletions(-)

diff --git a/compile.c b/compile.c
index 8872d6f7e8..82bed47923 100644
--- a/compile.c
+++ b/compile.c
@@ -2241,7 +2241,6 @@ add_adjust_info(struct iseq_insn_info_entry *insns_info, unsigned int *positions https://github.com/ruby/ruby/blob/trunk/compile.c#L2241
 static int
 iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
 {
-    VALUE iseqv = (VALUE)iseq;
     struct iseq_insn_info_entry *insns_info;
     struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
     unsigned int *positions;
@@ -2396,7 +2395,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) https://github.com/ruby/ruby/blob/trunk/compile.c#L2395
 			    generated_iseq[code_index + 1 + j] = map;
                             ISEQ_MBITS_SET(mark_offset_bits, code_index + 1 + j);
 			    RB_OBJ_WRITTEN(iseq, Qundef, map);
-                            FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
                             needs_bitmap = true;
 			    break;
 			}
@@ -2413,7 +2411,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) https://github.com/ruby/ruby/blob/trunk/compile.c#L2411
 			    if (!SPECIAL_CONST_P(v)) {
 				RB_OBJ_WRITTEN(iseq, Qundef, v);
                                 ISEQ_MBITS_SET(mark_offset_bits, code_index + 1 + j);
-                                FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
                                 needs_bitmap = true;
 			    }
 			    break;
@@ -2433,7 +2430,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) https://github.com/ruby/ruby/blob/trunk/compile.c#L2430
                                               ic_index, ISEQ_IS_SIZE(body));
 			    }
 			    generated_iseq[code_index + 1 + j] = (VALUE)ic;
-                            FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
 
                             if (insn == BIN(opt_getinlinecache) && type == TS_IC) {
                                 // Store the instruction index for opt_getinlinecache on the IC for
@@ -10338,14 +10334,12 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor, https://github.com/ruby/ruby/blob/trunk/compile.c#L10334
                         if (NUM2UINT(op) >= ISEQ_BODY(iseq)->ise_size) {
                             ISEQ_BODY(iseq)->ise_size = NUM2INT(op) + 1;
                         }
-                        FL_SET((VALUE)iseq, ISEQ_MARKABLE_ISEQ);
                         break;
 		      case TS_IC:
 			argv[j] = op;
                         if (NUM2UINT(op) >= ISEQ_BODY(iseq)->ic_size) {
                             ISEQ_BODY(iseq)->ic_size = NUM2INT(op) + 1;
                         }
-                        FL_SET((VALUE)iseq, ISEQ_MARKABLE_ISEQ);
                         break;
                       case TS_IVC:  /* inline ivar cache */
                       case TS_ICVARC:  /* inline cvar cache */
@@ -10353,7 +10347,6 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor, https://github.com/ruby/ruby/blob/trunk/compile.c#L10347
                         if (NUM2UINT(op) >= ISEQ_BODY(iseq)->ivc_size) {
                             ISEQ_BODY(iseq)->ivc_size = NUM2INT(op) + 1;
                         }
-                        FL_SET((VALUE)iseq, ISEQ_MARKABLE_ISEQ);
 			break;
                       case TS_CALLDATA:
 			argv[j] = iseq_build_callinfo_from_hash(iseq, op);
@@ -11240,7 +11233,6 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod https://github.com/ruby/ruby/blob/trunk/compile.c#L11233
                     if (!SPECIAL_CONST_P(v)) {
                         RB_OBJ_WRITTEN(iseqv, Qundef, v);
                         ISEQ_MBITS_SET(mark_offset_bits, code_index);
-                        FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
                         needs_bitmap = true;
                     }
                     break;
@@ -11262,7 +11254,6 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod https://github.com/ruby/ruby/blob/trunk/compile.c#L11254
                     code[code_index] = v;
                     ISEQ_MBITS_SET(mark_offset_bits, code_index);
                     RB_OBJ_WRITTEN(iseqv, Qundef, v);
-                    FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
                     needs_bitmap = true;
                     break;
                 }
@@ -11274,7 +11265,6 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod https://github.com/ruby/ruby/blob/trunk/compile.c#L11265
                     if (!SPECIAL_CONST_P(v)) {
                         RB_OBJ_WRITTEN(iseqv, Qundef, v);
                         ISEQ_MBITS_SET(mark_offset_bits, code_index);
-                        FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
                         needs_bitmap = true;
                     }
                     break;
@@ -11295,7 +11285,6 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod https://github.com/ruby/ruby/blob/trunk/compile.c#L11285
                         ic->ic_cache.get_insn_idx = insn_index;
                     }
                 }
-                FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
                 break;
               case TS_CALLDATA:
                 {
diff --git a/iseq.c b/iseq.c
index fee2627525..36f625d1bb 100644
--- a/iseq.c
+++ b/iseq.c
@@ -273,52 +273,56 @@ rb_iseq_each_value(const rb_iseq_t *iseq, iseq_value_itr_t * func, void *data) https://github.com/ruby/ruby/blob/trunk/iseq.c#L273
 
     union iseq_inline_storage_entry *is_entries = body->is_entries;
 
-    // IVC and ICVARC entries
-    for (unsigned int i = 0; i < body->ivc_size; i++, is_entries++) {
-        IVC ivc = (IVC)is_entries;
-        if (ivc->entry) {
-            if (RB_TYPE_P(ivc->entry->class_value, T_NONE)) {
-                rb_bug("!! %u", ivc->entry->index);
-            }
+    if (body->is_entries) {
+        // IVC and ICVARC entries
+        for (unsigned int i = 0; i < body->ivc_size; i++, is_entries++) {
+            IVC ivc = (IVC)is_entries;
+            if (ivc->entry) {
+                if (RB_TYPE_P(ivc->entry->class_value, T_NONE)) {
+                    rb_bug("!! %u", ivc->entry->index);
+                }
 
-            VALUE nv = func(data, ivc->entry->class_value);
-            if (ivc->entry->class_value != nv) {
-                ivc->entry->class_value = nv;
+                VALUE nv = func(data, ivc->entry->class_value);
+                if (ivc->entry->class_value != nv) {
+                    ivc->entry->class_value = nv;
+                }
             }
         }
-    }
 
-    // ISE entries
-    for (unsigned int i = 0; i < body->ise_size; i++, is_entries++) {
-        union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)is_entries;
-        if (is->once.value) {
-            VALUE nv = func(data, is->once.value);
-            if (is->once.value != nv) {
-                is->once.value = nv;
+        // ISE entries
+        for (unsigned int i = 0; i < body->ise_size; i++, is_entries++) {
+            union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)is_entries;
+            if (is->once.value) {
+                VALUE nv = func(data, is->once.value);
+                if (is->once.value != nv) {
+                    is->once.value = nv;
+                }
             }
         }
-    }
 
-    // IC Entries
-    for (unsigned int i = 0; i < body->ic_size; i++, is_entries++) {
-        IC ic = (IC)is_entries;
-        if (ic->entry) {
-            VALUE nv = func(data, (VALUE)ic->entry);
-            if ((VALUE)ic->entry != nv) {
-                ic->entry = (void *)nv;
+        // IC Entries
+        for (unsigned int i = 0; i < body->ic_size; i++, is_entries++) {
+            IC ic = (IC)is_entries;
+            if (ic->entry) {
+                VALUE nv = func(data, (VALUE)ic->entry);
+                if ((VALUE)ic->entry != nv) {
+                    ic->entry = (void *)nv;
+                }
             }
         }
     }
 
     // Embedded VALUEs
-    if (ISEQ_MBITS_BUFLEN(size) == 1) {
-        iseq_scan_bits(0, body->mark_bits.single, code, func, data);
-    }
-    else {
-        if (body->mark_bits.list) {
-            for (unsigned int i = 0; i < ISEQ_MBITS_BUFLEN(size); i++) {
-                iseq_bits_t bits = body->mark_bits.list[i];
-                iseq_scan_bits(i, bits, code, func, data);
+    if (body->mark_bits.list) {
+        if (ISEQ_MBITS_BUFLEN(size) == 1) {
+            iseq_scan_bits(0, body->mark_bits.single, code, func, data);
+        }
+        else {
+            if (body->mark_bits.list) {
+                for (unsigned int i = 0; i < ISEQ_MBITS_BUFLEN(size); i++) {
+                    iseq_bits_t bits = body->mark_bits.list[i];
+                    iseq_scan_bits(i, bits, code, func, data);
+                }
             }
         }
     }
@@ -393,10 +397,8 @@ rb_iseq_update_references(rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L397
                 cds[i].cc = (struct rb_callcache *)rb_gc_location((VALUE)cds[i].cc);
             }
         }
-        if (FL_TEST((VALUE)iseq, ISEQ_MARKABLE_ISEQ)) {
-            VALUE *original_iseq = ISEQ_ORIGINAL_ISEQ(iseq);
-            rb_iseq_each_value(iseq, update_each_insn_value, (void *)original_iseq);
-        }
+        VALUE *original_iseq = ISEQ_ORIGINAL_ISEQ(iseq);
+        rb_iseq_each_value(iseq, update_each_insn_value, (void *)original_iseq);
 
         if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) {
             int i, j;
@@ -448 (... truncated)

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

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