mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Rename to ctx_upgrade_opnd_type
This commit is contained in:
parent
53079ca585
commit
4ea69e5c0b
3 changed files with 25 additions and 17 deletions
|
@ -1237,7 +1237,7 @@ gen_set_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt
|
|||
ADD_COMMENT(cb, "guard value is immediate");
|
||||
test(cb, REG1, imm_opnd(RUBY_IMMEDIATE_MASK));
|
||||
jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_val_heapobject));
|
||||
ctx_set_opnd_type(ctx, OPND_STACK(0), TYPE_IMM);
|
||||
ctx_upgrade_opnd_type(ctx, OPND_STACK(0), TYPE_IMM);
|
||||
}
|
||||
|
||||
// Pop the value to write
|
||||
|
@ -1704,8 +1704,8 @@ guard_two_fixnums(ctx_t* ctx, uint8_t* side_exit)
|
|||
}
|
||||
|
||||
// Set stack types in context
|
||||
ctx_set_opnd_type(ctx, OPND_STACK(0), TYPE_FIXNUM);
|
||||
ctx_set_opnd_type(ctx, OPND_STACK(1), TYPE_FIXNUM);
|
||||
ctx_upgrade_opnd_type(ctx, OPND_STACK(0), TYPE_FIXNUM);
|
||||
ctx_upgrade_opnd_type(ctx, OPND_STACK(1), TYPE_FIXNUM);
|
||||
}
|
||||
|
||||
// Conditional move operation used by comparison operators
|
||||
|
@ -2441,7 +2441,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_
|
|||
cmp(cb, REG0, imm_opnd(Qnil));
|
||||
jit_chain_guard(JCC_JNE, jit, ctx, max_chain_depth, side_exit);
|
||||
|
||||
ctx_set_opnd_type(ctx, insn_opnd, TYPE_NIL);
|
||||
ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_NIL);
|
||||
}
|
||||
}
|
||||
else if (known_klass == rb_cTrueClass) {
|
||||
|
@ -2453,7 +2453,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_
|
|||
cmp(cb, REG0, imm_opnd(Qtrue));
|
||||
jit_chain_guard(JCC_JNE, jit, ctx, max_chain_depth, side_exit);
|
||||
|
||||
ctx_set_opnd_type(ctx, insn_opnd, TYPE_TRUE);
|
||||
ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_TRUE);
|
||||
}
|
||||
}
|
||||
else if (known_klass == rb_cFalseClass) {
|
||||
|
@ -2466,7 +2466,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_
|
|||
test(cb, REG0, REG0);
|
||||
jit_chain_guard(JCC_JNZ, jit, ctx, max_chain_depth, side_exit);
|
||||
|
||||
ctx_set_opnd_type(ctx, insn_opnd, TYPE_FALSE);
|
||||
ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_FALSE);
|
||||
}
|
||||
}
|
||||
else if (known_klass == rb_cInteger && FIXNUM_P(sample_instance)) {
|
||||
|
@ -2479,7 +2479,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_
|
|||
ADD_COMMENT(cb, "guard object is fixnum");
|
||||
test(cb, REG0, imm_opnd(RUBY_FIXNUM_FLAG));
|
||||
jit_chain_guard(JCC_JZ, jit, ctx, max_chain_depth, side_exit);
|
||||
ctx_set_opnd_type(ctx, insn_opnd, TYPE_FIXNUM);
|
||||
ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_FIXNUM);
|
||||
}
|
||||
}
|
||||
else if (known_klass == rb_cSymbol && STATIC_SYM_P(sample_instance)) {
|
||||
|
@ -2493,7 +2493,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_
|
|||
STATIC_ASSERT(special_shift_is_8, RUBY_SPECIAL_SHIFT == 8);
|
||||
cmp(cb, REG0_8, imm_opnd(RUBY_SYMBOL_FLAG));
|
||||
jit_chain_guard(JCC_JNE, jit, ctx, max_chain_depth, side_exit);
|
||||
ctx_set_opnd_type(ctx, insn_opnd, TYPE_STATIC_SYMBOL);
|
||||
ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_STATIC_SYMBOL);
|
||||
}
|
||||
}
|
||||
else if (known_klass == rb_cFloat && FLONUM_P(sample_instance)) {
|
||||
|
@ -2507,7 +2507,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_
|
|||
and(cb, REG1, imm_opnd(RUBY_FLONUM_MASK));
|
||||
cmp(cb, REG1, imm_opnd(RUBY_FLONUM_FLAG));
|
||||
jit_chain_guard(JCC_JNE, jit, ctx, max_chain_depth, side_exit);
|
||||
ctx_set_opnd_type(ctx, insn_opnd, TYPE_FLONUM);
|
||||
ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_FLONUM);
|
||||
}
|
||||
}
|
||||
else if (FL_TEST(known_klass, FL_SINGLETON) && sample_instance == rb_attr_get(known_klass, id__attached__)) {
|
||||
|
@ -2540,7 +2540,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_
|
|||
cmp(cb, REG0, imm_opnd(Qnil));
|
||||
jit_chain_guard(JCC_JBE, jit, ctx, max_chain_depth, side_exit);
|
||||
|
||||
ctx_set_opnd_type(ctx, insn_opnd, TYPE_HEAP);
|
||||
ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_HEAP);
|
||||
}
|
||||
|
||||
x86opnd_t klass_opnd = mem_opnd(64, REG0, offsetof(struct RBasic, klass));
|
||||
|
@ -3085,7 +3085,7 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r
|
|||
ctx_set_local_type(&callee_ctx, arg_idx, arg_type);
|
||||
}
|
||||
val_type_t recv_type = ctx_get_opnd_type(ctx, OPND_STACK(argc));
|
||||
ctx_set_opnd_type(&callee_ctx, OPND_SELF, recv_type);
|
||||
ctx_upgrade_opnd_type(&callee_ctx, OPND_SELF, recv_type);
|
||||
|
||||
// The callee might change locals through Kernel#binding and other means.
|
||||
ctx_clear_local_types(ctx);
|
||||
|
|
18
yjit_core.c
18
yjit_core.c
|
@ -153,13 +153,20 @@ ctx_get_opnd_type(const ctx_t* ctx, insn_opnd_t opnd)
|
|||
rb_bug("unreachable");
|
||||
}
|
||||
|
||||
int type_diff(val_type_t src, val_type_t dst);
|
||||
#define UPGRADE_TYPE(dest, src) do { \
|
||||
RUBY_ASSERT(type_diff((src), (dest)) != INT_MAX); \
|
||||
(dest) = (src); \
|
||||
} while (false)
|
||||
|
||||
|
||||
/**
|
||||
Set the type of an instruction operand
|
||||
*/
|
||||
void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type)
|
||||
void ctx_upgrade_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type)
|
||||
{
|
||||
if (opnd.is_self) {
|
||||
ctx->self_type = type;
|
||||
UPGRADE_TYPE(ctx->self_type, type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -172,16 +179,17 @@ void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type)
|
|||
switch (mapping.kind)
|
||||
{
|
||||
case TEMP_SELF:
|
||||
ctx->self_type = type;
|
||||
UPGRADE_TYPE(ctx->self_type, type);
|
||||
break;
|
||||
|
||||
case TEMP_STACK:
|
||||
ctx->temp_types[ctx->stack_size - 1 - opnd.idx] = type;
|
||||
int stack_index = ctx->stack_size - 1 - opnd.idx;
|
||||
UPGRADE_TYPE(ctx->temp_types[stack_index], type);
|
||||
break;
|
||||
|
||||
case TEMP_LOCAL:
|
||||
RUBY_ASSERT(mapping.idx < MAX_LOCAL_TYPES);
|
||||
ctx->local_types[mapping.idx] = type;
|
||||
UPGRADE_TYPE(ctx->local_types[mapping.idx], type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ x86opnd_t ctx_stack_push_local(ctx_t* ctx, size_t local_idx);
|
|||
x86opnd_t ctx_stack_pop(ctx_t* ctx, size_t n);
|
||||
x86opnd_t ctx_stack_opnd(ctx_t* ctx, int32_t idx);
|
||||
val_type_t ctx_get_opnd_type(const ctx_t* ctx, insn_opnd_t opnd);
|
||||
void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type);
|
||||
void ctx_upgrade_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type);
|
||||
void ctx_set_local_type(ctx_t* ctx, size_t idx, val_type_t type);
|
||||
void ctx_clear_local_types(ctx_t* ctx);
|
||||
int ctx_diff(const ctx_t* src, const ctx_t* dst);
|
||||
|
|
Loading…
Reference in a new issue