aboutsummaryrefslogtreecommitdiffstats
path: root/yjit/src/asm
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-04-11 08:02:52 -0700
committerGitHub <noreply@github.com>2023-04-11 11:02:52 -0400
commit7297374c5e3dc2b66ee55d918b3f933e78dd23fd (patch)
tree44b4f37c1bd8617aa948af79b9c0c8101e29efc0 /yjit/src/asm
parent8c360ce713f57d4177de833297364f6f6d950420 (diff)
downloadruby-7297374c5e3dc2b66ee55d918b3f933e78dd23fd.tar.gz
YJIT: Reduce paddings if --yjit-exec-mem-size <= 128 on arm64 (#7671)
* YJIT: Reduce paddings if --yjit-exec-mem-size <= 128 on arm64 * YJIT: Define jmp_ptr_bytes on CodeBlock
Diffstat (limited to 'yjit/src/asm')
-rw-r--r--yjit/src/asm/mod.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/yjit/src/asm/mod.rs b/yjit/src/asm/mod.rs
index 9df246dcbb..68c09eb114 100644
--- a/yjit/src/asm/mod.rs
+++ b/yjit/src/asm/mod.rs
@@ -2,10 +2,6 @@ use std::cell::RefCell;
use std::fmt;
use std::mem;
use std::rc::Rc;
-#[cfg(target_arch = "x86_64")]
-use crate::backend::x86_64::JMP_PTR_BYTES;
-#[cfg(target_arch = "aarch64")]
-use crate::backend::arm64::JMP_PTR_BYTES;
use crate::core::IseqPayload;
use crate::core::for_each_off_stack_iseq_payload;
use crate::core::for_each_on_stack_iseq_payload;
@@ -123,7 +119,7 @@ impl CodeBlock {
page_size,
write_pos: 0,
past_page_bytes: 0,
- page_end_reserve: JMP_PTR_BYTES,
+ page_end_reserve: 0,
label_addrs: Vec::new(),
label_names: Vec::new(),
label_refs: Vec::new(),
@@ -133,6 +129,7 @@ impl CodeBlock {
dropped_bytes: false,
freed_pages,
};
+ cb.page_end_reserve = cb.jmp_ptr_bytes();
cb.write_pos = cb.page_start();
cb
}
@@ -196,7 +193,7 @@ impl CodeBlock {
self.write_pos = dst_pos;
let dst_ptr = self.get_write_ptr();
self.write_pos = src_pos;
- self.without_page_end_reserve(|cb| assert!(cb.has_capacity(JMP_PTR_BYTES)));
+ self.without_page_end_reserve(|cb| assert!(cb.has_capacity(cb.jmp_ptr_bytes())));
// Generate jmp_ptr from src_pos to dst_pos
self.without_page_end_reserve(|cb| {
@@ -242,6 +239,11 @@ impl CodeBlock {
self.mem_block.borrow().mapped_region_size()
}
+ /// Size of the region in bytes where writes could be attempted.
+ pub fn virtual_region_size(&self) -> usize {
+ self.mem_block.borrow().virtual_region_size()
+ }
+
/// Return the number of code pages that have been mapped by the VirtualMemory.
pub fn num_mapped_pages(&self) -> usize {
// CodeBlock's page size != VirtualMem's page size on Linux,
@@ -287,7 +289,7 @@ impl CodeBlock {
if cfg!(debug_assertions) && !cfg!(test) {
// Leave illegal instructions at the beginning of each page to assert
// we're not accidentally crossing page boundaries.
- start += JMP_PTR_BYTES;
+ start += self.jmp_ptr_bytes();
}
start
}