ruby-changes:68583
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:09:57 +0900 (JST)
Subject: [ruby-changes:68583] 132f7e11fd (master): Compile putnil
https://git.ruby-lang.org/ruby.git/commit/?id=132f7e11fd From 132f7e11fd6715a9e2e09b06441de8d399728049 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Wed, 16 Sep 2020 15:30:23 -0400 Subject: Compile putnil --- ujit_compile.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ujit_compile.c b/ujit_compile.c index 60dc6a0927..5e958dd751 100644 --- a/ujit_compile.c +++ b/ujit_compile.c @@ -195,8 +195,20 @@ void gen_putobject_int2fix(codeblock_t* cb, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_compile.c#L195 mov(cb, mem_opnd(64, RDI, 8), RCX); } -// TODO: putnil -// could we reuse code from putobject_int2fix here? +void gen_putnil(codeblock_t* cb, ctx_t* ctx) +{ + // Load current SP into RAX + mov(cb, RAX, mem_opnd(64, RDI, 8)); + + // Write constant at SP + mov(cb, mem_opnd(64, RAX, 0), imm_opnd(Qnil)); + + // Load incremented SP into RCX + lea(cb, RCX, mem_opnd(64, RAX, 8)); + + // Write back incremented SP + mov(cb, mem_opnd(64, RDI, 8), RCX); +} // TODO: implement putself @@ -239,6 +251,7 @@ static void ujit_init() https://github.com/ruby/ruby/blob/trunk/ujit_compile.c#L251 // Map YARV opcodes to the corresponding codegen functions st_insert(gen_fns, (st_data_t)BIN(nop), (st_data_t)&gen_nop); st_insert(gen_fns, (st_data_t)BIN(pop), (st_data_t)&gen_pop); + st_insert(gen_fns, (st_data_t)BIN(putnil), (st_data_t)&gen_putnil); st_insert(gen_fns, (st_data_t)BIN(putobject_INT2FIX_0_), (st_data_t)&gen_putobject_int2fix); st_insert(gen_fns, (st_data_t)BIN(putobject_INT2FIX_1_), (st_data_t)&gen_putobject_int2fix); st_insert(gen_fns, (st_data_t)BIN(getlocal_WC_0), (st_data_t)&gen_getlocal_wc0); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/