ruby-changes:68960
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:27 +0900 (JST)
Subject: [ruby-changes:68960] 62c1297e24 (master): Implement setn bytecode (#15)
https://git.ruby-lang.org/ruby.git/commit/?id=62c1297e24 From 62c1297e246966bd3b309d3a3ce3cd0dc78c389d Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maximechevalierb@g...> Date: Wed, 28 Apr 2021 16:55:56 -0400 Subject: Implement setn bytecode (#15) --- yjit_codegen.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/yjit_codegen.c b/yjit_codegen.c index f02c519612..ace2df622d 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -456,6 +456,13 @@ yjit_gen_block(block_t *block, rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L456 } } +static codegen_status_t +gen_nop(jitstate_t* jit, ctx_t* ctx) +{ + // Do nothing + return YJIT_KEEP_COMPILING; +} + static codegen_status_t gen_dup(jitstate_t* jit, ctx_t* ctx) { @@ -471,10 +478,22 @@ gen_dup(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L478 return YJIT_KEEP_COMPILING; } +// set Nth stack entry to stack top static codegen_status_t -gen_nop(jitstate_t* jit, ctx_t* ctx) +gen_setn(jitstate_t* jit, ctx_t* ctx) { - // Do nothing + rb_num_t n = (rb_num_t)jit_get_arg(jit, 0); + + // Get the top value and its type + val_type_t top_type = ctx_get_opnd_type(ctx, OPND_STACK(0)); + x86opnd_t top_val = ctx_stack_pop(ctx, 0); + + // Set the destination and its type + ctx_set_opnd_type(ctx, OPND_STACK(n), top_type); + x86opnd_t dst_opnd = ctx_stack_opnd(ctx, (int32_t)n); + mov(cb, REG0, top_val); + mov(cb, dst_opnd, REG0); + return YJIT_KEEP_COMPILING; } @@ -2220,8 +2239,9 @@ yjit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2239 leave_exit_code = yjit_gen_leave_exit(cb); // Map YARV opcodes to the corresponding codegen functions - yjit_reg_op(BIN(dup), gen_dup); yjit_reg_op(BIN(nop), gen_nop); + yjit_reg_op(BIN(dup), gen_dup); + yjit_reg_op(BIN(setn), gen_setn); yjit_reg_op(BIN(pop), gen_pop); yjit_reg_op(BIN(putnil), gen_putnil); yjit_reg_op(BIN(putobject), gen_putobject); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/