Skip to content

Commit e90729a

Browse files
authored
ZJIT: Rust code refactors (ruby#14687)
1 parent a0a4068 commit e90729a

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

zjit/src/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ fn gen_setlocal(asm: &mut Assembler, val: Opnd, val_type: Type, local_ep_offset:
573573
} else {
574574
// We're potentially writing a reference to an IMEMO/env object,
575575
// so take care of the write barrier with a function.
576-
let local_index = local_ep_offset * -1;
576+
let local_index = -local_ep_offset;
577577
asm_ccall!(asm, rb_vm_env_write, ep, local_index.into(), val);
578578
}
579579
}

zjit/src/hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,7 +3263,7 @@ struct BytecodeInfo {
32633263
has_blockiseq: bool,
32643264
}
32653265

3266-
fn compute_bytecode_info(iseq: *const rb_iseq_t, opt_table: &Vec<u32>) -> BytecodeInfo {
3266+
fn compute_bytecode_info(iseq: *const rb_iseq_t, opt_table: &[u32]) -> BytecodeInfo {
32673267
let iseq_size = unsafe { get_iseq_encoded_size(iseq) };
32683268
let mut insn_idx = 0;
32693269
let mut jump_targets: HashSet<u32> = opt_table.iter().copied().collect();
@@ -4251,7 +4251,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
42514251
}
42524252

42534253
/// Compile an entry_block for the interpreter
4254-
fn compile_entry_block(fun: &mut Function, jit_entry_insns: &Vec<u32>) {
4254+
fn compile_entry_block(fun: &mut Function, jit_entry_insns: &[u32]) {
42554255
let entry_block = fun.entry_block;
42564256
fun.push_insn(entry_block, Insn::EntryPoint { jit_entry_idx: None });
42574257

zjit/src/hir_type/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ impl Type {
355355
fn is_builtin(class: VALUE) -> bool {
356356
types::ExactBitsAndClass
357357
.iter()
358-
.find(|&(_, class_object)| unsafe { **class_object } == class)
359-
.is_some()
358+
.any(|&(_, class_object)| unsafe { *class_object } == class)
360359
}
361360

362361
/// Union both types together, preserving specialization if possible.

zjit/src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ fn update_profile_threshold() {
314314
/// Update --zjit-call-threshold for testing
315315
#[cfg(test)]
316316
pub fn set_call_threshold(call_threshold: u64) {
317-
unsafe { rb_zjit_call_threshold = call_threshold as u64; }
317+
unsafe { rb_zjit_call_threshold = call_threshold; }
318318
rb_zjit_prepare_options();
319319
update_profile_threshold();
320320
}

0 commit comments

Comments
 (0)