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 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) 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) 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) 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, 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, 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 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 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 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 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) 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) 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,9 +450,7 @@ rb_iseq_mark(const rb_iseq_t *iseq) if (ISEQ_BODY(iseq)) { const struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq); - if (FL_TEST((VALUE)iseq, ISEQ_MARKABLE_ISEQ)) { - rb_iseq_each_value(iseq, each_insn_value, NULL); - } + rb_iseq_each_value(iseq, each_insn_value, NULL); rb_gc_mark_movable(body->variable.coverage); rb_gc_mark_movable(body->variable.pc2branchindex); diff --git a/iseq.h b/iseq.h index 46a8b1b010..1ca77a34d9 100644 --- a/iseq.h +++ b/iseq.h @@ -90,7 +90,6 @@ ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size) #define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1 #define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2 #define ISEQ_TRANSLATED IMEMO_FL_USER3 -#define ISEQ_MARKABLE_ISEQ IMEMO_FL_USER4 #define ISEQ_EXECUTABLE_P(iseq) (FL_TEST_RAW(((VALUE)iseq), ISEQ_NOT_LOADED_YET | ISEQ_USE_COMPILE_DATA) == 0)