Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Port over setlocal_wc0
  • Loading branch information
maximecb authored and k0kubun committed Aug 29, 2022
1 parent b45b29f commit 86606e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
8 changes: 7 additions & 1 deletion yjit/src/backend/ir.rs
Expand Up @@ -253,7 +253,7 @@ impl From<u64> for Opnd {

impl From<i64> for Opnd {
fn from(value: i64) -> Self {
Opnd::Imm(value.try_into().unwrap())
Opnd::Imm(value)
}
}

Expand All @@ -263,6 +263,12 @@ impl From<i32> for Opnd {
}
}

impl From<u32> for Opnd {
fn from(value: u32) -> Self {
Opnd::UImm(value as u64)
}
}

impl From<VALUE> for Opnd {
fn from(value: VALUE) -> Self {
let VALUE(uimm) = value;
Expand Down
23 changes: 11 additions & 12 deletions yjit/src/codegen.rs
Expand Up @@ -1584,11 +1584,10 @@ fn gen_getlocal_wc1(
gen_getlocal_generic(ctx, asm, idx.as_u32(), 1)
}

/*
fn gen_setlocal_wc0(
jit: &mut JITState,
ctx: &mut Context,
cb: &mut CodeBlock,
asm: &mut Assembler,
ocb: &mut OutlinedCb,
) -> CodegenStatus {
/*
Expand All @@ -1609,41 +1608,41 @@ fn gen_setlocal_wc0(
let value_type = ctx.get_opnd_type(StackOpnd(0));

// Load environment pointer EP (level 0) from CFP
gen_get_ep(cb, REG0, 0);
let ep_opnd = gen_get_ep(asm, 0);

// Write barriers may be required when VM_ENV_FLAG_WB_REQUIRED is set, however write barriers
// only affect heap objects being written. If we know an immediate value is being written we
// can skip this check.
if !value_type.is_imm() {
// flags & VM_ENV_FLAG_WB_REQUIRED
let flags_opnd = mem_opnd(
let flags_opnd = Opnd::mem(
64,
REG0,
ep_opnd,
SIZEOF_VALUE as i32 * VM_ENV_DATA_INDEX_FLAGS as i32,
);
test(cb, flags_opnd, imm_opnd(VM_ENV_FLAG_WB_REQUIRED as i64));
asm.test(flags_opnd, VM_ENV_FLAG_WB_REQUIRED.into());

// Create a side-exit to fall back to the interpreter
let side_exit = get_side_exit(jit, ocb, ctx);

// if (flags & VM_ENV_FLAG_WB_REQUIRED) != 0
jnz_ptr(cb, side_exit);
asm.jnz(side_exit.into());
}

// Set the type of the local variable in the context
ctx.set_local_type(local_idx, value_type);

// Pop the value to write from the stack
let stack_top = ctx.stack_pop(1);
mov(cb, REG1, stack_top);

// Write the value at the environment pointer
let offs: i32 = -8 * slot_idx;
mov(cb, mem_opnd(64, REG0, offs), REG1);
asm.mov(Opnd::mem(64, ep_opnd, offs), stack_top);

KeepCompiling
}

/*
fn gen_setlocal_generic(
jit: &mut JITState,
ctx: &mut Context,
Expand Down Expand Up @@ -5992,11 +5991,11 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> {
YARVINSN_topn => Some(gen_topn),
YARVINSN_adjuststack => Some(gen_adjuststack),

//YARVINSN_getlocal => Some(gen_getlocal),
YARVINSN_getlocal => Some(gen_getlocal),
YARVINSN_getlocal_WC_0 => Some(gen_getlocal_wc0),
//YARVINSN_getlocal_WC_1 => Some(gen_getlocal_wc1),
YARVINSN_getlocal_WC_1 => Some(gen_getlocal_wc1),
//YARVINSN_setlocal => Some(gen_setlocal),
//YARVINSN_setlocal_WC_0 => Some(gen_setlocal_wc0),
YARVINSN_setlocal_WC_0 => Some(gen_setlocal_wc0),
//YARVINSN_setlocal_WC_1 => Some(gen_setlocal_wc1),
YARVINSN_opt_plus => Some(gen_opt_plus),
/*
Expand Down

0 comments on commit 86606e0

Please sign in to comment.