Skip to content

Commit bd6bab4

Browse files
authored
Merge pull request #164 from jhawthorn/putspecialobject
Implement putspecialobject
2 parents d2a1a8b + c79f99b commit bd6bab4

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

test/ruby/test_yjit.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def test_compile_set_and_get_global
5959
assert_compiles('$foo = 123; $foo', insns: %i[setglobal], result: 123)
6060
end
6161

62+
def test_compile_putspecialobject
63+
assert_compiles('-> {}', insns: %i[putspecialobject])
64+
end
65+
6266
def test_compile_tostring
6367
assert_no_exits('"i am a string #{true}"')
6468
end
@@ -191,7 +195,7 @@ def collect_iseqs(iseq)
191195
192196
iseq = RubyVM::InstructionSequence.of(_test_proc)
193197
IO.open(3).write Marshal.dump({
194-
result: result,
198+
result: #{result == ANY ? "nil" : "result"},
195199
stats: stats,
196200
iseqs: collect_iseqs(iseq),
197201
disasm: iseq.disasm

yjit_codegen.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,23 @@ gen_putself(jitstate_t* jit, ctx_t* ctx)
986986
return YJIT_KEEP_COMPILING;
987987
}
988988

989+
static codegen_status_t
990+
gen_putspecialobject(jitstate_t* jit, ctx_t* ctx)
991+
{
992+
enum vm_special_object_type type = (enum vm_special_object_type)jit_get_arg(jit, 0);
993+
994+
if (type == VM_SPECIAL_OBJECT_VMCORE) {
995+
x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_HEAP);
996+
jit_mov_gc_ptr(jit, cb, REG0, rb_mRubyVMFrozenCore);
997+
mov(cb, stack_top, REG0);
998+
return YJIT_KEEP_COMPILING;
999+
} else {
1000+
// TODO: implement for VM_SPECIAL_OBJECT_CBASE and
1001+
// VM_SPECIAL_OBJECT_CONST_BASE
1002+
return YJIT_CANT_COMPILE;
1003+
}
1004+
}
1005+
9891006
// Compute the index of a local variable from its slot index
9901007
static uint32_t
9911008
slot_to_local_idx(const rb_iseq_t *iseq, int32_t slot_idx)
@@ -3685,6 +3702,7 @@ yjit_init_codegen(void)
36853702
yjit_reg_op(BIN(putobject_INT2FIX_0_), gen_putobject_int2fix);
36863703
yjit_reg_op(BIN(putobject_INT2FIX_1_), gen_putobject_int2fix);
36873704
yjit_reg_op(BIN(putself), gen_putself);
3705+
yjit_reg_op(BIN(putspecialobject), gen_putspecialobject);
36883706
yjit_reg_op(BIN(getlocal), gen_getlocal);
36893707
yjit_reg_op(BIN(getlocal_WC_0), gen_getlocal_wc0);
36903708
yjit_reg_op(BIN(getlocal_WC_1), gen_getlocal_wc1);

0 commit comments

Comments
 (0)