1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

YJIT: Skip setlocal WB check for immediate values (#6122)

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.
This commit is contained in:
John Hawthorn 2022-07-20 09:31:40 -07:00 committed by GitHub
parent 6140edb5df
commit 660b1e973c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-07-21 01:32:15 +09:00
Merged-By: maximecb <maximecb@ruby-lang.org>

View file

@ -1565,10 +1565,15 @@ fn gen_setlocal_wc0(
let slot_idx = jit_get_arg(jit, 0).as_i32(); let slot_idx = jit_get_arg(jit, 0).as_i32();
let local_idx = slot_to_local_idx(jit.get_iseq(), slot_idx).as_usize(); let local_idx = slot_to_local_idx(jit.get_iseq(), slot_idx).as_usize();
let value_type = ctx.get_opnd_type(StackOpnd(0));
// Load environment pointer EP (level 0) from CFP // Load environment pointer EP (level 0) from CFP
gen_get_ep(cb, REG0, 0); gen_get_ep(cb, REG0, 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 // flags & VM_ENV_FLAG_WB_REQUIRED
let flags_opnd = mem_opnd( let flags_opnd = mem_opnd(
64, 64,
@ -1582,10 +1587,10 @@ fn gen_setlocal_wc0(
// if (flags & VM_ENV_FLAG_WB_REQUIRED) != 0 // if (flags & VM_ENV_FLAG_WB_REQUIRED) != 0
jnz_ptr(cb, side_exit); jnz_ptr(cb, side_exit);
}
// Set the type of the local variable in the context // Set the type of the local variable in the context
let temp_type = ctx.get_opnd_type(StackOpnd(0)); ctx.set_local_type(local_idx, value_type);
ctx.set_local_type(local_idx, temp_type);
// Pop the value to write from the stack // Pop the value to write from the stack
let stack_top = ctx.stack_pop(1); let stack_top = ctx.stack_pop(1);
@ -1606,9 +1611,15 @@ fn gen_setlocal_generic(
local_idx: i32, local_idx: i32,
level: u32, level: u32,
) -> CodegenStatus { ) -> CodegenStatus {
let value_type = ctx.get_opnd_type(StackOpnd(0));
// Load environment pointer EP at level // Load environment pointer EP at level
gen_get_ep(cb, REG0, level); gen_get_ep(cb, REG0, level);
// 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 // flags & VM_ENV_FLAG_WB_REQUIRED
let flags_opnd = mem_opnd( let flags_opnd = mem_opnd(
64, 64,
@ -1622,6 +1633,7 @@ fn gen_setlocal_generic(
// if (flags & VM_ENV_FLAG_WB_REQUIRED) != 0 // if (flags & VM_ENV_FLAG_WB_REQUIRED) != 0
jnz_ptr(cb, side_exit); jnz_ptr(cb, side_exit);
}
// Pop the value to write from the stack // Pop the value to write from the stack
let stack_top = ctx.stack_pop(1); let stack_top = ctx.stack_pop(1);