ruby-changes:68916
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:13:15 +0900 (JST)
Subject: [ruby-changes:68916] e85e0e2fa9 (master): Commit WIP setlocal_WC_1 implementation
https://git.ruby-lang.org/ruby.git/commit/?id=e85e0e2fa9 From e85e0e2fa98d7835163e3470ca322b11a0f67c67 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Wed, 3 Feb 2021 16:09:03 -0500 Subject: Commit WIP setlocal_WC_1 implementation --- ujit_codegen.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/ujit_codegen.c b/ujit_codegen.c index 3b66e8fa40..ad5d1b18b0 100644 --- a/ujit_codegen.c +++ b/ujit_codegen.c @@ -339,7 +339,7 @@ gen_getlocal_wc0(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L339 // Compute the offset from BP to the local int32_t local_idx = (int32_t)jit_get_arg(jit, 0); - const int32_t offs = -sizeof(VALUE) * local_idx; + const int32_t offs = -(SIZEOF_VALUE * local_idx); // Load the local from the block mov(cb, REG0, mem_opnd(64, REG0, offs)); @@ -351,6 +351,33 @@ gen_getlocal_wc0(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L351 return true; } +static bool +gen_getlocal_wc1(jitstate_t* jit, ctx_t* ctx) +{ + //fprintf(stderr, "gen_getlocal_wc1\n"); + + // Load environment pointer EP from CFP + mov(cb, REG0, member_opnd(REG_CFP, rb_control_frame_t, ep)); + + // Get the previous EP from the current EP + // See GET_PREV_EP(ep) macro + // VALUE* prev_ep = ((VALUE *)((ep)[VM_ENV_DATA_INDEX_SPECVAL] & ~0x03)) + mov(cb, REG0, mem_opnd(64, REG0, SIZEOF_VALUE * VM_ENV_DATA_INDEX_SPECVAL)); + and(cb, REG0, imm_opnd(~0x03)); + + // Load the local from the block + // val = *(vm_get_ep(GET_EP(), level) - idx); + int32_t local_idx = (int32_t)jit_get_arg(jit, 0); + const int32_t offs = -(SIZEOF_VALUE * local_idx); + mov(cb, REG0, mem_opnd(64, REG0, offs)); + + // Write the local at SP + x86opnd_t stack_top = ctx_stack_push(ctx, T_NONE); + mov(cb, stack_top, REG0); + + return true; +} + static bool gen_setlocal_wc0(jitstate_t* jit, ctx_t* ctx) { @@ -1186,9 +1213,9 @@ gen_opt_swb_iseq(jitstate_t* jit, ctx_t* ctx, struct rb_call_data * cd, const rb https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L1213 // Setup the new frame // *cfp = (const struct rb_control_frame_struct) { - // .pc = 0, + // .pc = pc, // .sp = sp, - // .iseq = 0, + // .iseq = iseq, // .self = recv, // .ep = sp - 1, // .block_code = 0, @@ -1348,6 +1375,7 @@ ujit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L1375 ujit_reg_op(BIN(putobject_INT2FIX_1_), gen_putobject_int2fix, false); ujit_reg_op(BIN(putself), gen_putself, false); ujit_reg_op(BIN(getlocal_WC_0), gen_getlocal_wc0, false); + //ujit_reg_op(BIN(getlocal_WC_1), gen_getlocal_wc1, false); ujit_reg_op(BIN(setlocal_WC_0), gen_setlocal_wc0, false); ujit_reg_op(BIN(getinstancevariable), gen_getinstancevariable, false); ujit_reg_op(BIN(setinstancevariable), gen_setinstancevariable, false); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/