mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Implement putspecialobject
This commit is contained in:
parent
3edf29668e
commit
e18b0b6eba
2 changed files with 23 additions and 1 deletions
|
@ -59,6 +59,10 @@ class TestYJIT < Test::Unit::TestCase
|
||||||
assert_compiles('$foo = 123; $foo', insns: %i[setglobal], result: 123)
|
assert_compiles('$foo = 123; $foo', insns: %i[setglobal], result: 123)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_compile_putspecialobject
|
||||||
|
assert_compiles('-> {}', insns: %i[putspecialobject])
|
||||||
|
end
|
||||||
|
|
||||||
def test_compile_tostring
|
def test_compile_tostring
|
||||||
assert_no_exits('"i am a string #{true}"')
|
assert_no_exits('"i am a string #{true}"')
|
||||||
end
|
end
|
||||||
|
@ -201,7 +205,7 @@ class TestYJIT < Test::Unit::TestCase
|
||||||
|
|
||||||
iseq = RubyVM::InstructionSequence.of(_test_proc)
|
iseq = RubyVM::InstructionSequence.of(_test_proc)
|
||||||
IO.open(3).write Marshal.dump({
|
IO.open(3).write Marshal.dump({
|
||||||
result: result,
|
result: #{result == ANY ? "nil" : "result"},
|
||||||
stats: stats,
|
stats: stats,
|
||||||
iseqs: collect_iseqs(iseq),
|
iseqs: collect_iseqs(iseq),
|
||||||
disasm: iseq.disasm
|
disasm: iseq.disasm
|
||||||
|
|
|
@ -988,6 +988,23 @@ gen_putself(jitstate_t* jit, ctx_t* ctx)
|
||||||
return YJIT_KEEP_COMPILING;
|
return YJIT_KEEP_COMPILING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static codegen_status_t
|
||||||
|
gen_putspecialobject(jitstate_t* jit, ctx_t* ctx)
|
||||||
|
{
|
||||||
|
enum vm_special_object_type type = (enum vm_special_object_type)jit_get_arg(jit, 0);
|
||||||
|
|
||||||
|
if (type == VM_SPECIAL_OBJECT_VMCORE) {
|
||||||
|
x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_HEAP);
|
||||||
|
jit_mov_gc_ptr(jit, cb, REG0, rb_mRubyVMFrozenCore);
|
||||||
|
mov(cb, stack_top, REG0);
|
||||||
|
return YJIT_KEEP_COMPILING;
|
||||||
|
} else {
|
||||||
|
// TODO: implement for VM_SPECIAL_OBJECT_CBASE and
|
||||||
|
// VM_SPECIAL_OBJECT_CONST_BASE
|
||||||
|
return YJIT_CANT_COMPILE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Compute the index of a local variable from its slot index
|
// Compute the index of a local variable from its slot index
|
||||||
static uint32_t
|
static uint32_t
|
||||||
slot_to_local_idx(const rb_iseq_t *iseq, int32_t slot_idx)
|
slot_to_local_idx(const rb_iseq_t *iseq, int32_t slot_idx)
|
||||||
|
@ -3693,6 +3710,7 @@ yjit_init_codegen(void)
|
||||||
yjit_reg_op(BIN(putobject_INT2FIX_0_), gen_putobject_int2fix);
|
yjit_reg_op(BIN(putobject_INT2FIX_0_), gen_putobject_int2fix);
|
||||||
yjit_reg_op(BIN(putobject_INT2FIX_1_), gen_putobject_int2fix);
|
yjit_reg_op(BIN(putobject_INT2FIX_1_), gen_putobject_int2fix);
|
||||||
yjit_reg_op(BIN(putself), gen_putself);
|
yjit_reg_op(BIN(putself), gen_putself);
|
||||||
|
yjit_reg_op(BIN(putspecialobject), gen_putspecialobject);
|
||||||
yjit_reg_op(BIN(getlocal), gen_getlocal);
|
yjit_reg_op(BIN(getlocal), gen_getlocal);
|
||||||
yjit_reg_op(BIN(getlocal_WC_0), gen_getlocal_wc0);
|
yjit_reg_op(BIN(getlocal_WC_0), gen_getlocal_wc0);
|
||||||
yjit_reg_op(BIN(getlocal_WC_1), gen_getlocal_wc1);
|
yjit_reg_op(BIN(getlocal_WC_1), gen_getlocal_wc1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue