Skip to content

Commit b2ba71d

Browse files
authored
Code clean around unused code for some architectures or features (ruby#6581)
1 parent e7166c9 commit b2ba71d

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

yjit/src/asm/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
use std::cell::RefCell;
2-
use std::cmp;
32
use std::fmt;
43
use std::mem;
54
use std::rc::Rc;
65
#[cfg(target_arch = "x86_64")]
76
use crate::backend::x86_64::JMP_PTR_BYTES;
87
#[cfg(target_arch = "aarch64")]
98
use crate::backend::arm64::JMP_PTR_BYTES;
10-
use crate::backend::ir::Assembler;
11-
use crate::backend::ir::Target;
129
use crate::virtualmem::WriteError;
1310

1411
#[cfg(feature = "asm_comments")]
@@ -154,7 +151,7 @@ impl CodeBlock {
154151
// We could remember the last write_pos in page2 and let set_page use that position,
155152
// but you need to waste some space for keeping write_pos for every single page.
156153
// It doesn't seem necessary for performance either. So we're currently not doing it.
157-
let mut dst_pos = self.page_size * page_idx + self.page_start();
154+
let dst_pos = self.page_size * page_idx + self.page_start();
158155
if self.page_size * page_idx < self.mem_size && self.write_pos < dst_pos {
159156
// Reset dropped_bytes
160157
self.dropped_bytes = false;
@@ -216,6 +213,8 @@ impl CodeBlock {
216213
self.page_end_reserve = old_page_end_reserve;
217214
}
218215

216+
#[cfg(target_arch = "aarch64")]
217+
#[cfg(not(test))]
219218
/// Return the address ranges of a given address range that this CodeBlock can write.
220219
pub fn writable_addrs(&self, start_ptr: CodePtr, end_ptr: CodePtr) -> Vec<(usize, usize)> {
221220
let mut addrs = vec![];

yjit/src/codegen.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ use crate::core::*;
88
use crate::cruby::*;
99
use crate::invariants::*;
1010
use crate::options::*;
11+
#[cfg(feature = "stats")]
1112
use crate::stats::*;
1213
use crate::utils::*;
1314
use CodegenStatus::*;
1415
use InsnOpnd::*;
1516

16-
use std::cell::RefCell;
17-
use std::cell::RefMut;
1817
use std::cmp;
1918
use std::collections::HashMap;
2019
use std::ffi::CStr;
2120
use std::mem::{self, size_of};
2221
use std::os::raw::c_uint;
2322
use std::ptr;
24-
use std::rc::Rc;
2523
use std::slice;
2624

2725
pub use crate::virtualmem::CodePtr;
@@ -650,7 +648,7 @@ pub fn gen_entry_prologue(cb: &mut CodeBlock, iseq: IseqPtr, insn_idx: u32) -> O
650648

651649
asm.compile(cb);
652650

653-
if (cb.has_dropped_bytes()) {
651+
if cb.has_dropped_bytes() {
654652
None
655653
} else {
656654
Some(code_ptr)
@@ -6537,10 +6535,15 @@ impl CodegenGlobals {
65376535
pub fn init() {
65386536
// Executable memory and code page size in bytes
65396537
let mem_size = get_option!(exec_mem_size);
6540-
let code_page_size = get_option!(code_page_size);
6538+
65416539

65426540
#[cfg(not(test))]
65436541
let (mut cb, mut ocb) = {
6542+
use std::cell::RefCell;
6543+
use std::rc::Rc;
6544+
6545+
let code_page_size = get_option!(code_page_size);
6546+
65446547
let virt_block: *mut u8 = unsafe { rb_yjit_reserve_addr_space(mem_size as u32) };
65456548

65466549
// Memory protection syscalls need page-aligned addresses, so check it here. Assuming

yjit/src/disasm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
use crate::core::*;
22
use crate::cruby::*;
33
use crate::yjit::yjit_enabled_p;
4+
#[cfg(feature = "disasm")]
45
use crate::asm::CodeBlock;
6+
#[cfg(feature = "disasm")]
57
use crate::options::DumpDisasm;
68

9+
#[cfg(feature = "disasm")]
710
use std::fmt::Write;
811

912
/// Primitive called in yjit.rb

yjit/src/invariants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ pub extern "C" fn rb_yjit_tracing_invalidate_all() {
533533
with_vm_lock(src_loc!(), || {
534534
// Make it so all live block versions are no longer valid branch targets
535535
for_each_iseq(|iseq| {
536-
if let Some(payload) = unsafe { get_iseq_payload(iseq) } {
536+
if let Some(payload) = get_iseq_payload(iseq) {
537537
// C comment:
538538
// Leaking the blocks for now since we might have situations where
539539
// a different ractor is waiting for the VM lock in branch_stub_hit().

yjit/src/virtualmem.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ impl CodePtr {
198198
ptr as i64
199199
}
200200

201+
#[cfg(target_arch = "aarch64")]
201202
pub fn into_u64(self) -> u64 {
202203
let CodePtr(ptr) = self;
203204
ptr as u64

0 commit comments

Comments
 (0)