ruby-changes:69120
From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:53 +0900 (JST)
Subject: [ruby-changes:69120] e18b0b6eba (master): Implement putspecialobject
https://git.ruby-lang.org/ruby.git/commit/?id=e18b0b6eba From e18b0b6ebab74e16774bc6121ffba785564b9fd6 Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Sat, 19 Jun 2021 14:03:06 -0700 Subject: Implement putspecialobject --- test/ruby/test_yjit.rb | 6 +++++- yjit_codegen.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 95e768ee0c..8160042cb9 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -59,6 +59,10 @@ class TestYJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_yjit.rb#L59 assert_compiles('$foo = 123; $foo', insns: %i[setglobal], result: 123) end + def test_compile_putspecialobject + assert_compiles('-> {}', insns: %i[putspecialobject]) + end + def test_compile_tostring assert_no_exits('"i am a string #{true}"') end @@ -201,7 +205,7 @@ class TestYJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_yjit.rb#L205 iseq = RubyVM::InstructionSequence.of(_test_proc) IO.open(3).write Marshal.dump({ - result: result, + result: #{result == ANY ? "nil" : "result"}, stats: stats, iseqs: collect_iseqs(iseq), disasm: iseq.disasm diff --git a/yjit_codegen.c b/yjit_codegen.c index 40feda345f..ca4718380e 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -988,6 +988,23 @@ gen_putself(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L988 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 static uint32_t slot_to_local_idx(const rb_iseq_t *iseq, int32_t slot_idx) @@ -3693,6 +3710,7 @@ yjit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3710 yjit_reg_op(BIN(putobject_INT2FIX_0_), gen_putobject_int2fix); yjit_reg_op(BIN(putobject_INT2FIX_1_), gen_putobject_int2fix); 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_WC_0), gen_getlocal_wc0); yjit_reg_op(BIN(getlocal_WC_1), gen_getlocal_wc1); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/