YJIT: Move ocb
parameters into JITState
Many functions take an outlined code block but do nothing more than passing it along; only a couple of functions actually make use of it. So, in most cases the `ocb` parameter is just boilerplate. Most functions that take `ocb` already also take a `JITState` and this commit moves `ocb` into `JITState` to remove the visual noise of the `ocb` parameter.
This commit is contained in:
parent
01f0dcd336
commit
bc91e8ff1d
File diff suppressed because it is too large
Load Diff
@ -2227,7 +2227,7 @@ fn remove_block_version(blockref: &BlockRef) {
|
||||
version_list.retain(|other| blockref != other);
|
||||
}
|
||||
|
||||
impl JITState {
|
||||
impl<'a> JITState<'a> {
|
||||
// Finish compiling and turn a jit state into a block
|
||||
// note that the block is still not in shape.
|
||||
pub fn into_block(self, end_insn_idx: IseqIdx, start_addr: CodePtr, end_addr: CodePtr, gc_obj_offsets: Vec<u32>) -> BlockRef {
|
||||
@ -3729,7 +3729,6 @@ impl Assembler
|
||||
pub fn gen_branch(
|
||||
jit: &mut JITState,
|
||||
asm: &mut Assembler,
|
||||
ocb: &mut OutlinedCb,
|
||||
target0: BlockId,
|
||||
ctx0: &Context,
|
||||
target1: Option<BlockId>,
|
||||
@ -3737,6 +3736,7 @@ pub fn gen_branch(
|
||||
gen_fn: BranchGenFn,
|
||||
) {
|
||||
let branch = new_pending_branch(jit, gen_fn);
|
||||
let ocb = jit.get_ocb();
|
||||
|
||||
// Get the branch targets or stubs
|
||||
let target0_addr = branch.set_target(0, target0, ctx0, ocb);
|
||||
@ -3799,7 +3799,6 @@ pub fn gen_direct_jump(jit: &mut JITState, ctx: &Context, target0: BlockId, asm:
|
||||
pub fn defer_compilation(
|
||||
jit: &mut JITState,
|
||||
asm: &mut Assembler,
|
||||
ocb: &mut OutlinedCb,
|
||||
) {
|
||||
if asm.ctx.is_deferred() {
|
||||
panic!("Double defer!");
|
||||
@ -3817,7 +3816,7 @@ pub fn defer_compilation(
|
||||
};
|
||||
|
||||
// Likely a stub since the context is marked as deferred().
|
||||
let target0_address = branch.set_target(0, blockid, &next_ctx, ocb);
|
||||
let target0_address = branch.set_target(0, blockid, &next_ctx, jit.get_ocb());
|
||||
|
||||
// Pad the block if it has the potential to be invalidated. This must be
|
||||
// done before gen_fn() in case the jump is overwritten by a fallthrough.
|
||||
@ -4348,8 +4347,9 @@ mod tests {
|
||||
idx: 0,
|
||||
};
|
||||
let cb = CodeBlock::new_dummy(1024);
|
||||
let mut ocb = OutlinedCb::wrap(CodeBlock::new_dummy(1024));
|
||||
let dumm_addr = cb.get_write_ptr();
|
||||
let block = JITState::new(blockid, Context::default(), dumm_addr, ptr::null())
|
||||
let block = JITState::new(blockid, Context::default(), dumm_addr, ptr::null(), &mut ocb)
|
||||
.into_block(0, dumm_addr, dumm_addr, vec![]);
|
||||
let _dropper = BlockDropper(block);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
//! Code to track assumptions made during code generation and invalidate
|
||||
//! generated code if and when these assumptions are invalidated.
|
||||
|
||||
use crate::asm::OutlinedCb;
|
||||
use crate::backend::ir::Assembler;
|
||||
use crate::codegen::*;
|
||||
use crate::core::*;
|
||||
@ -98,12 +97,11 @@ impl Invariants {
|
||||
pub fn assume_bop_not_redefined(
|
||||
jit: &mut JITState,
|
||||
asm: &mut Assembler,
|
||||
ocb: &mut OutlinedCb,
|
||||
klass: RedefinitionFlag,
|
||||
bop: ruby_basic_operators,
|
||||
) -> bool {
|
||||
if unsafe { BASIC_OP_UNREDEFINED_P(bop, klass) } {
|
||||
if jit_ensure_block_entry_exit(jit, asm, ocb).is_none() {
|
||||
if jit_ensure_block_entry_exit(jit, asm).is_none() {
|
||||
return false;
|
||||
}
|
||||
jit.bop_assumptions.push((klass, bop));
|
||||
@ -192,13 +190,12 @@ pub fn iseq_free_invariants(iseq: IseqPtr) {
|
||||
pub fn assume_method_basic_definition(
|
||||
jit: &mut JITState,
|
||||
asm: &mut Assembler,
|
||||
ocb: &mut OutlinedCb,
|
||||
klass: VALUE,
|
||||
mid: ID
|
||||
) -> bool {
|
||||
if unsafe { rb_method_basic_definition_p(klass, mid) } != 0 {
|
||||
let cme = unsafe { rb_callable_method_entry(klass, mid) };
|
||||
jit.assume_method_lookup_stable(asm, ocb, cme);
|
||||
jit.assume_method_lookup_stable(asm, cme);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
@ -207,11 +204,11 @@ pub fn assume_method_basic_definition(
|
||||
|
||||
/// Tracks that a block is assuming it is operating in single-ractor mode.
|
||||
#[must_use]
|
||||
pub fn assume_single_ractor_mode(jit: &mut JITState, asm: &mut Assembler, ocb: &mut OutlinedCb) -> bool {
|
||||
pub fn assume_single_ractor_mode(jit: &mut JITState, asm: &mut Assembler) -> bool {
|
||||
if unsafe { rb_yjit_multi_ractor_p() } {
|
||||
false
|
||||
} else {
|
||||
if jit_ensure_block_entry_exit(jit, asm, ocb).is_none() {
|
||||
if jit_ensure_block_entry_exit(jit, asm).is_none() {
|
||||
return false;
|
||||
}
|
||||
jit.block_assumes_single_ractor = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user