mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 21:49:06 +02:00
Port opt_getinlinecache to the new backend (https://github.com/Shopify/ruby/pull/399)
This commit is contained in:
parent
dca5e74aa1
commit
cb15886e61
1 changed files with 24 additions and 15 deletions
|
@ -5475,11 +5475,10 @@ fn gen_setclassvariable(
|
||||||
KeepCompiling
|
KeepCompiling
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
fn gen_opt_getinlinecache(
|
fn gen_opt_getinlinecache(
|
||||||
jit: &mut JITState,
|
jit: &mut JITState,
|
||||||
ctx: &mut Context,
|
ctx: &mut Context,
|
||||||
cb: &mut CodeBlock,
|
asm: &mut Assembler,
|
||||||
ocb: &mut OutlinedCb,
|
ocb: &mut OutlinedCb,
|
||||||
) -> CodegenStatus {
|
) -> CodegenStatus {
|
||||||
let jump_offset = jit_get_arg(jit, 0);
|
let jump_offset = jit_get_arg(jit, 0);
|
||||||
|
@ -5498,25 +5497,35 @@ fn gen_opt_getinlinecache(
|
||||||
// to invalidate this block from yjit_constant_ic_update().
|
// to invalidate this block from yjit_constant_ic_update().
|
||||||
jit_ensure_block_entry_exit(jit, ocb);
|
jit_ensure_block_entry_exit(jit, ocb);
|
||||||
|
|
||||||
|
let inline_cache = Opnd::const_ptr(ic as *const u8);
|
||||||
if !unsafe { (*ice).ic_cref }.is_null() {
|
if !unsafe { (*ice).ic_cref }.is_null() {
|
||||||
// Cache is keyed on a certain lexical scope. Use the interpreter's cache.
|
// Cache is keyed on a certain lexical scope. Use the interpreter's cache.
|
||||||
let side_exit = get_side_exit(jit, ocb, ctx);
|
let side_exit = get_side_exit(jit, ocb, ctx);
|
||||||
|
|
||||||
// Call function to verify the cache. It doesn't allocate or call methods.
|
// Call function to verify the cache. It doesn't allocate or call methods.
|
||||||
mov(cb, C_ARG_REGS[0], const_ptr_opnd(ic as *const u8));
|
let ret_val = asm.ccall(
|
||||||
mov(cb, C_ARG_REGS[1], mem_opnd(64, REG_CFP, RUBY_OFFSET_CFP_EP));
|
rb_vm_ic_hit_p as *const u8,
|
||||||
call_ptr(cb, REG0, rb_vm_ic_hit_p as *const u8);
|
vec![inline_cache, Opnd::mem(64, CFP, RUBY_OFFSET_CFP_EP)]
|
||||||
|
);
|
||||||
|
|
||||||
// Check the result. _Bool is one byte in SysV.
|
// Check the result. _Bool is one byte in SysV.
|
||||||
test(cb, AL, AL);
|
asm.test(ret_val, ret_val);
|
||||||
jz_ptr(cb, counted_exit!(ocb, side_exit, opt_getinlinecache_miss));
|
asm.jz(counted_exit!(ocb, side_exit, opt_getinlinecache_miss).into());
|
||||||
|
|
||||||
|
let inline_cache_entry = Opnd::mem(
|
||||||
|
64,
|
||||||
|
inline_cache,
|
||||||
|
RUBY_OFFSET_IC_ENTRY
|
||||||
|
);
|
||||||
|
let inline_cache_entry_val = Opnd::mem(
|
||||||
|
64,
|
||||||
|
inline_cache_entry,
|
||||||
|
RUBY_OFFSET_ICE_VALUE
|
||||||
|
);
|
||||||
|
|
||||||
// Push ic->entry->value
|
// Push ic->entry->value
|
||||||
mov(cb, REG0, const_ptr_opnd(ic as *mut u8));
|
|
||||||
mov(cb, REG0, mem_opnd(64, REG0, RUBY_OFFSET_IC_ENTRY));
|
|
||||||
let stack_top = ctx.stack_push(Type::Unknown);
|
let stack_top = ctx.stack_push(Type::Unknown);
|
||||||
mov(cb, REG0, mem_opnd(64, REG0, RUBY_OFFSET_ICE_VALUE));
|
asm.mov(stack_top, inline_cache_entry_val);
|
||||||
mov(cb, stack_top, REG0);
|
|
||||||
} else {
|
} else {
|
||||||
// Optimize for single ractor mode.
|
// Optimize for single ractor mode.
|
||||||
// FIXME: This leaks when st_insert raises NoMemoryError
|
// FIXME: This leaks when st_insert raises NoMemoryError
|
||||||
|
@ -5528,7 +5537,7 @@ fn gen_opt_getinlinecache(
|
||||||
// constants referenced within the current block.
|
// constants referenced within the current block.
|
||||||
assume_stable_constant_names(jit, ocb);
|
assume_stable_constant_names(jit, ocb);
|
||||||
|
|
||||||
jit_putobject(jit, ctx, cb, unsafe { (*ice).value });
|
jit_putobject(jit, ctx, asm, unsafe { (*ice).value });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jump over the code for filling the cache
|
// Jump over the code for filling the cache
|
||||||
|
@ -5540,11 +5549,11 @@ fn gen_opt_getinlinecache(
|
||||||
iseq: jit.iseq,
|
iseq: jit.iseq,
|
||||||
idx: jump_idx,
|
idx: jump_idx,
|
||||||
},
|
},
|
||||||
cb,
|
asm,
|
||||||
);
|
);
|
||||||
EndBlock
|
EndBlock
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Push the explicit block parameter onto the temporary stack. Part of the
|
// Push the explicit block parameter onto the temporary stack. Part of the
|
||||||
// interpreter's scheme for avoiding Proc allocations when delegating
|
// interpreter's scheme for avoiding Proc allocations when delegating
|
||||||
|
@ -5873,7 +5882,7 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> {
|
||||||
YARVINSN_opt_size => Some(gen_opt_size),
|
YARVINSN_opt_size => Some(gen_opt_size),
|
||||||
YARVINSN_opt_length => Some(gen_opt_length),
|
YARVINSN_opt_length => Some(gen_opt_length),
|
||||||
YARVINSN_opt_regexpmatch2 => Some(gen_opt_regexpmatch2),
|
YARVINSN_opt_regexpmatch2 => Some(gen_opt_regexpmatch2),
|
||||||
//YARVINSN_opt_getinlinecache => Some(gen_opt_getinlinecache),
|
YARVINSN_opt_getinlinecache => Some(gen_opt_getinlinecache),
|
||||||
YARVINSN_invokebuiltin => Some(gen_invokebuiltin),
|
YARVINSN_invokebuiltin => Some(gen_invokebuiltin),
|
||||||
YARVINSN_opt_invokebuiltin_delegate => Some(gen_opt_invokebuiltin_delegate),
|
YARVINSN_opt_invokebuiltin_delegate => Some(gen_opt_invokebuiltin_delegate),
|
||||||
YARVINSN_opt_invokebuiltin_delegate_leave => Some(gen_opt_invokebuiltin_delegate),
|
YARVINSN_opt_invokebuiltin_delegate_leave => Some(gen_opt_invokebuiltin_delegate),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue