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.
This commit is contained in:
Aaron Patterson 2022-06-30 10:38:48 -07:00 коммит произвёл Aaron Patterson
Родитель 621e5c568a
Коммит 3cf2c2e4a1
3 изменённых файлов: 41 добавлений и 53 удалений

Просмотреть файл

@ -2241,7 +2241,6 @@ add_adjust_info(struct iseq_insn_info_entry *insns_info, unsigned int *positions
static int static int
iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
{ {
VALUE iseqv = (VALUE)iseq;
struct iseq_insn_info_entry *insns_info; struct iseq_insn_info_entry *insns_info;
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq); struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
unsigned int *positions; 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; generated_iseq[code_index + 1 + j] = map;
ISEQ_MBITS_SET(mark_offset_bits, code_index + 1 + j); ISEQ_MBITS_SET(mark_offset_bits, code_index + 1 + j);
RB_OBJ_WRITTEN(iseq, Qundef, map); RB_OBJ_WRITTEN(iseq, Qundef, map);
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
needs_bitmap = true; needs_bitmap = true;
break; break;
} }
@ -2413,7 +2411,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
if (!SPECIAL_CONST_P(v)) { if (!SPECIAL_CONST_P(v)) {
RB_OBJ_WRITTEN(iseq, Qundef, v); RB_OBJ_WRITTEN(iseq, Qundef, v);
ISEQ_MBITS_SET(mark_offset_bits, code_index + 1 + j); ISEQ_MBITS_SET(mark_offset_bits, code_index + 1 + j);
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
needs_bitmap = true; needs_bitmap = true;
} }
break; break;
@ -2433,7 +2430,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
ic_index, ISEQ_IS_SIZE(body)); ic_index, ISEQ_IS_SIZE(body));
} }
generated_iseq[code_index + 1 + j] = (VALUE)ic; generated_iseq[code_index + 1 + j] = (VALUE)ic;
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
if (insn == BIN(opt_getinlinecache) && type == TS_IC) { if (insn == BIN(opt_getinlinecache) && type == TS_IC) {
// Store the instruction index for opt_getinlinecache on the IC for // 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) { if (NUM2UINT(op) >= ISEQ_BODY(iseq)->ise_size) {
ISEQ_BODY(iseq)->ise_size = NUM2INT(op) + 1; ISEQ_BODY(iseq)->ise_size = NUM2INT(op) + 1;
} }
FL_SET((VALUE)iseq, ISEQ_MARKABLE_ISEQ);
break; break;
case TS_IC: case TS_IC:
argv[j] = op; argv[j] = op;
if (NUM2UINT(op) >= ISEQ_BODY(iseq)->ic_size) { if (NUM2UINT(op) >= ISEQ_BODY(iseq)->ic_size) {
ISEQ_BODY(iseq)->ic_size = NUM2INT(op) + 1; ISEQ_BODY(iseq)->ic_size = NUM2INT(op) + 1;
} }
FL_SET((VALUE)iseq, ISEQ_MARKABLE_ISEQ);
break; break;
case TS_IVC: /* inline ivar cache */ case TS_IVC: /* inline ivar cache */
case TS_ICVARC: /* inline cvar 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) { if (NUM2UINT(op) >= ISEQ_BODY(iseq)->ivc_size) {
ISEQ_BODY(iseq)->ivc_size = NUM2INT(op) + 1; ISEQ_BODY(iseq)->ivc_size = NUM2INT(op) + 1;
} }
FL_SET((VALUE)iseq, ISEQ_MARKABLE_ISEQ);
break; break;
case TS_CALLDATA: case TS_CALLDATA:
argv[j] = iseq_build_callinfo_from_hash(iseq, op); 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)) { if (!SPECIAL_CONST_P(v)) {
RB_OBJ_WRITTEN(iseqv, Qundef, v); RB_OBJ_WRITTEN(iseqv, Qundef, v);
ISEQ_MBITS_SET(mark_offset_bits, code_index); ISEQ_MBITS_SET(mark_offset_bits, code_index);
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
needs_bitmap = true; needs_bitmap = true;
} }
break; 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; code[code_index] = v;
ISEQ_MBITS_SET(mark_offset_bits, code_index); ISEQ_MBITS_SET(mark_offset_bits, code_index);
RB_OBJ_WRITTEN(iseqv, Qundef, v); RB_OBJ_WRITTEN(iseqv, Qundef, v);
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
needs_bitmap = true; needs_bitmap = true;
break; 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)) { if (!SPECIAL_CONST_P(v)) {
RB_OBJ_WRITTEN(iseqv, Qundef, v); RB_OBJ_WRITTEN(iseqv, Qundef, v);
ISEQ_MBITS_SET(mark_offset_bits, code_index); ISEQ_MBITS_SET(mark_offset_bits, code_index);
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
needs_bitmap = true; needs_bitmap = true;
} }
break; 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; ic->ic_cache.get_insn_idx = insn_index;
} }
} }
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
break; break;
case TS_CALLDATA: case TS_CALLDATA:
{ {

82
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; union iseq_inline_storage_entry *is_entries = body->is_entries;
// IVC and ICVARC entries if (body->is_entries) {
for (unsigned int i = 0; i < body->ivc_size; i++, is_entries++) { // IVC and ICVARC entries
IVC ivc = (IVC)is_entries; for (unsigned int i = 0; i < body->ivc_size; i++, is_entries++) {
if (ivc->entry) { IVC ivc = (IVC)is_entries;
if (RB_TYPE_P(ivc->entry->class_value, T_NONE)) { if (ivc->entry) {
rb_bug("!! %u", ivc->entry->index); if (RB_TYPE_P(ivc->entry->class_value, T_NONE)) {
} rb_bug("!! %u", ivc->entry->index);
}
VALUE nv = func(data, ivc->entry->class_value); VALUE nv = func(data, ivc->entry->class_value);
if (ivc->entry->class_value != nv) { if (ivc->entry->class_value != nv) {
ivc->entry->class_value = nv; ivc->entry->class_value = nv;
}
} }
} }
}
// ISE entries // ISE entries
for (unsigned int i = 0; i < body->ise_size; i++, is_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; union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)is_entries;
if (is->once.value) { if (is->once.value) {
VALUE nv = func(data, is->once.value); VALUE nv = func(data, is->once.value);
if (is->once.value != nv) { if (is->once.value != nv) {
is->once.value = nv; is->once.value = nv;
}
} }
} }
}
// IC Entries // IC Entries
for (unsigned int i = 0; i < body->ic_size; i++, is_entries++) { for (unsigned int i = 0; i < body->ic_size; i++, is_entries++) {
IC ic = (IC)is_entries; IC ic = (IC)is_entries;
if (ic->entry) { if (ic->entry) {
VALUE nv = func(data, (VALUE)ic->entry); VALUE nv = func(data, (VALUE)ic->entry);
if ((VALUE)ic->entry != nv) { if ((VALUE)ic->entry != nv) {
ic->entry = (void *)nv; ic->entry = (void *)nv;
}
} }
} }
} }
// Embedded VALUEs // Embedded VALUEs
if (ISEQ_MBITS_BUFLEN(size) == 1) { if (body->mark_bits.list) {
iseq_scan_bits(0, body->mark_bits.single, code, func, data); if (ISEQ_MBITS_BUFLEN(size) == 1) {
} iseq_scan_bits(0, body->mark_bits.single, code, func, data);
else { }
if (body->mark_bits.list) { else {
for (unsigned int i = 0; i < ISEQ_MBITS_BUFLEN(size); i++) { if (body->mark_bits.list) {
iseq_bits_t bits = body->mark_bits.list[i]; for (unsigned int i = 0; i < ISEQ_MBITS_BUFLEN(size); i++) {
iseq_scan_bits(i, bits, code, func, data); 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); 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);
VALUE *original_iseq = ISEQ_ORIGINAL_ISEQ(iseq); rb_iseq_each_value(iseq, update_each_insn_value, (void *)original_iseq);
rb_iseq_each_value(iseq, update_each_insn_value, (void *)original_iseq);
}
if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) { if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) {
int i, j; int i, j;
@ -448,9 +450,7 @@ rb_iseq_mark(const rb_iseq_t *iseq)
if (ISEQ_BODY(iseq)) { if (ISEQ_BODY(iseq)) {
const struct rb_iseq_constant_body *const body = 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.coverage);
rb_gc_mark_movable(body->variable.pc2branchindex); rb_gc_mark_movable(body->variable.pc2branchindex);

1
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_NOT_LOADED_YET IMEMO_FL_USER1
#define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2 #define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2
#define ISEQ_TRANSLATED IMEMO_FL_USER3 #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) #define ISEQ_EXECUTABLE_P(iseq) (FL_TEST_RAW(((VALUE)iseq), ISEQ_NOT_LOADED_YET | ISEQ_USE_COMPILE_DATA) == 0)