Make it possible to define data alignment

This commit is contained in:
bjorn3
2019-03-30 16:45:58 +01:00
committed by Benjamin Bouvier
parent 443e48aee1
commit cb6268118c
5 changed files with 33 additions and 14 deletions

View File

@@ -209,7 +209,13 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
// Nothing to do.
}
fn declare_data(&mut self, _name: &str, _linkage: Linkage, _writable: bool) {
fn declare_data(
&mut self,
_name: &str,
_linkage: Linkage,
_writable: bool,
_align: Option<u8>,
) {
// Nothing to do.
}
@@ -223,7 +229,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
let size = code_size as usize;
let ptr = self
.code_memory
.allocate(size)
.allocate(size, 0x10)
.expect("TODO: handle OOM etc.");
if cfg!(target_os = "linux") && ::std::env::var_os("PERF_BUILDID_DIR").is_some() {
@@ -253,6 +259,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
&mut self,
_name: &str,
writable: bool,
align: Option<u8>,
data: &DataContext,
_namespace: &ModuleNamespace<Self>,
) -> ModuleResult<Self::CompiledData> {
@@ -267,11 +274,11 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
let size = init.size();
let storage = if writable {
self.writable_memory
.allocate(size)
.allocate(size, align.unwrap_or(0x8))
.expect("TODO: handle OOM etc.")
} else {
self.readonly_memory
.allocate(size)
.allocate(size, align.unwrap_or(1))
.expect("TODO: handle OOM etc.")
};