Simplify code for YJIT const cache in compile.c
Since opt_getinlinecache and opt_setinlinecache point to the same cache struct, there is no need to track the index of the get instruction and then store it on the cache struct later when processing the set instruction. Setting it when processing the get instruction works just as well. This change reduces our diff.
This commit is contained in:
parent
28632ea7ba
commit
27358b6ee4
35
compile.c
35
compile.c
@ -2259,7 +2259,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
|
|||||||
VALUE *generated_iseq;
|
VALUE *generated_iseq;
|
||||||
rb_event_flag_t events = 0;
|
rb_event_flag_t events = 0;
|
||||||
long data = 0;
|
long data = 0;
|
||||||
long getinlinecache_idx = -1;
|
|
||||||
|
|
||||||
int insn_num, code_index, insns_info_index, sp = 0;
|
int insn_num, code_index, insns_info_index, sp = 0;
|
||||||
int stack_max = fix_sp_depth(iseq, anchor);
|
int stack_max = fix_sp_depth(iseq, anchor);
|
||||||
@ -2363,11 +2362,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
|
|||||||
types = insn_op_types(insn);
|
types = insn_op_types(insn);
|
||||||
len = insn_len(insn);
|
len = insn_len(insn);
|
||||||
|
|
||||||
if (insn == BIN(opt_getinlinecache)) {
|
|
||||||
assert(getinlinecache_idx < 0 && "one get per set, no nesting");
|
|
||||||
getinlinecache_idx = code_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; types[j]; j++) {
|
for (j = 0; types[j]; j++) {
|
||||||
char type = types[j];
|
char type = types[j];
|
||||||
/* printf("--> [%c - (%d-%d)]\n", type, k, j); */
|
/* printf("--> [%c - (%d-%d)]\n", type, k, j); */
|
||||||
@ -2426,11 +2420,10 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
|
|||||||
generated_iseq[code_index + 1 + j] = (VALUE)ic;
|
generated_iseq[code_index + 1 + j] = (VALUE)ic;
|
||||||
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
|
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
|
||||||
|
|
||||||
if (insn == BIN(opt_setinlinecache) && type == TS_IC) {
|
if (insn == BIN(opt_getinlinecache) && type == TS_IC) {
|
||||||
assert(getinlinecache_idx >= 0);
|
// Store the instruction index for opt_getinlinecache on the IC for
|
||||||
// Store index to the matching opt_getinlinecache on the IC for YJIT
|
// YJIT to invalidate code when opt_setinlinecache runs.
|
||||||
ic->get_insn_idx = (unsigned)getinlinecache_idx;
|
ic->get_insn_idx = (unsigned int)code_index;
|
||||||
getinlinecache_idx = -1;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -11120,7 +11113,6 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
|
|||||||
unsigned int code_index;
|
unsigned int code_index;
|
||||||
ibf_offset_t reading_pos = bytecode_offset;
|
ibf_offset_t reading_pos = bytecode_offset;
|
||||||
VALUE *code = ALLOC_N(VALUE, iseq_size);
|
VALUE *code = ALLOC_N(VALUE, iseq_size);
|
||||||
long getinlinecache_idx = -1;
|
|
||||||
|
|
||||||
struct rb_iseq_constant_body *load_body = iseq->body;
|
struct rb_iseq_constant_body *load_body = iseq->body;
|
||||||
struct rb_call_data *cd_entries = load_body->call_data;
|
struct rb_call_data *cd_entries = load_body->call_data;
|
||||||
@ -11129,20 +11121,16 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
|
|||||||
for (code_index=0; code_index<iseq_size;) {
|
for (code_index=0; code_index<iseq_size;) {
|
||||||
/* opcode */
|
/* opcode */
|
||||||
const VALUE insn = code[code_index] = ibf_load_small_value(load, &reading_pos);
|
const VALUE insn = code[code_index] = ibf_load_small_value(load, &reading_pos);
|
||||||
|
const unsigned int insn_index = code_index;
|
||||||
const char *types = insn_op_types(insn);
|
const char *types = insn_op_types(insn);
|
||||||
int op_index;
|
int op_index;
|
||||||
|
|
||||||
if (insn == BIN(opt_getinlinecache)) {
|
|
||||||
assert(getinlinecache_idx < 0 && "one get per set, no nesting");
|
|
||||||
getinlinecache_idx = code_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
code_index++;
|
code_index++;
|
||||||
|
|
||||||
/* operands */
|
/* operands */
|
||||||
for (op_index=0; types[op_index]; op_index++, code_index++) {
|
for (op_index=0; types[op_index]; op_index++, code_index++) {
|
||||||
char type = types[op_index];
|
const char operand_type = types[op_index];
|
||||||
switch (type) {
|
switch (operand_type) {
|
||||||
case TS_VALUE:
|
case TS_VALUE:
|
||||||
{
|
{
|
||||||
VALUE op = ibf_load_small_value(load, &reading_pos);
|
VALUE op = ibf_load_small_value(load, &reading_pos);
|
||||||
@ -11191,11 +11179,10 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
|
|||||||
VALUE op = ibf_load_small_value(load, &reading_pos);
|
VALUE op = ibf_load_small_value(load, &reading_pos);
|
||||||
code[code_index] = (VALUE)&is_entries[op];
|
code[code_index] = (VALUE)&is_entries[op];
|
||||||
|
|
||||||
if (insn == BIN(opt_setinlinecache) && type == TS_IC) {
|
if (insn == BIN(opt_getinlinecache) && operand_type == TS_IC) {
|
||||||
assert(getinlinecache_idx >= 0);
|
// Store the instruction index for opt_getinlinecache on the IC for
|
||||||
// Store index to the matching opt_getinlinecache on the IC for YJIT
|
// YJIT to invalidate code when opt_setinlinecache runs.
|
||||||
is_entries[op].ic_cache.get_insn_idx = (unsigned)getinlinecache_idx;
|
is_entries[op].ic_cache.get_insn_idx = insn_index;
|
||||||
getinlinecache_idx = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
|
FL_SET(iseqv, ISEQ_MARKABLE_ISEQ);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user