Make alignment magic number constants
This commit is contained in:
@@ -17,6 +17,10 @@ use target_lexicon::PointerWidth;
|
||||
#[cfg(windows)]
|
||||
use winapi;
|
||||
|
||||
const EXECUTABLE_DATA_ALIGNMENT: u8 = 0x10;
|
||||
const WRITABLE_DATA_ALIGNMENT: u8 = 0x8;
|
||||
const READONLY_DATA_ALIGNMENT: u8 = 0x1;
|
||||
|
||||
/// A builder for `SimpleJITBackend`.
|
||||
pub struct SimpleJITBuilder {
|
||||
isa: Box<TargetIsa>,
|
||||
@@ -229,7 +233,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
|
||||
let size = code_size as usize;
|
||||
let ptr = self
|
||||
.code_memory
|
||||
.allocate(size, 0x10)
|
||||
.allocate(size, EXECUTABLE_DATA_ALIGNMENT)
|
||||
.expect("TODO: handle OOM etc.");
|
||||
|
||||
if cfg!(target_os = "linux") && ::std::env::var_os("PERF_BUILDID_DIR").is_some() {
|
||||
@@ -274,11 +278,11 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
|
||||
let size = init.size();
|
||||
let storage = if writable {
|
||||
self.writable_memory
|
||||
.allocate(size, align.unwrap_or(0x8))
|
||||
.allocate(size, align.unwrap_or(WRITABLE_DATA_ALIGNMENT))
|
||||
.expect("TODO: handle OOM etc.")
|
||||
} else {
|
||||
self.readonly_memory
|
||||
.allocate(size, align.unwrap_or(1))
|
||||
.allocate(size, align.unwrap_or(READONLY_DATA_ALIGNMENT))
|
||||
.expect("TODO: handle OOM etc.")
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user