mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-24 22:21:32 +00:00
Add Pages and Bytes newtypes
This commit is contained in:
@ -13,8 +13,6 @@ use wasmer_runtime_core::{
|
||||
vm,
|
||||
};
|
||||
|
||||
const WASM_PAGE_SIZE: usize = 65_536;
|
||||
|
||||
pub struct FuncEnv<'env, 'module, 'isa> {
|
||||
env: &'env ModuleEnv<'module, 'isa>,
|
||||
}
|
||||
@ -219,7 +217,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
|
||||
func.create_heap(ir::HeapData {
|
||||
base: local_memory_base,
|
||||
min_size: ((description.minimum as u64) * (WASM_PAGE_SIZE as u64)).into(),
|
||||
min_size: (description.minimum.bytes().0 as u64).into(),
|
||||
offset_guard_size: mem_type.guard_size().into(),
|
||||
style: ir::HeapStyle::Dynamic {
|
||||
bound_gv: local_memory_bound,
|
||||
@ -230,7 +228,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
mem_type @ MemoryType::Static | mem_type @ MemoryType::SharedStatic => func
|
||||
.create_heap(ir::HeapData {
|
||||
base: local_memory_base,
|
||||
min_size: ((description.minimum as u64) * (WASM_PAGE_SIZE as u64)).into(),
|
||||
min_size: (description.minimum.bytes().0 as u64).into(),
|
||||
offset_guard_size: mem_type.guard_size().into(),
|
||||
style: ir::HeapStyle::Static {
|
||||
bound: mem_type.bounds().unwrap().into(),
|
||||
|
@ -14,6 +14,7 @@ use wasmer_runtime_core::{
|
||||
ElementType, FuncSig, GlobalDescriptor, GlobalIndex, GlobalInit, Initializer,
|
||||
LocalFuncIndex, LocalOrImport, MemoryDescriptor, SigIndex, TableDescriptor, Value,
|
||||
},
|
||||
units::Pages,
|
||||
};
|
||||
|
||||
pub struct ModuleEnv<'module, 'isa> {
|
||||
@ -251,8 +252,8 @@ impl<'module, 'isa, 'data> ModuleEnvironment<'data> for ModuleEnv<'module, 'isa>
|
||||
/// Declares a memory to the environment
|
||||
fn declare_memory(&mut self, memory: cranelift_wasm::Memory) {
|
||||
self.module.memories.push(MemoryDescriptor {
|
||||
minimum: memory.minimum,
|
||||
maximum: memory.maximum,
|
||||
minimum: Pages(memory.minimum),
|
||||
maximum: memory.maximum.map(|max| Pages(max)),
|
||||
shared: memory.shared,
|
||||
});
|
||||
}
|
||||
@ -270,8 +271,8 @@ impl<'module, 'isa, 'data> ModuleEnvironment<'data> for ModuleEnv<'module, 'isa>
|
||||
};
|
||||
|
||||
let memory = MemoryDescriptor {
|
||||
minimum: memory.minimum,
|
||||
maximum: memory.maximum,
|
||||
minimum: Pages(memory.minimum),
|
||||
maximum: memory.maximum.map(|max| Pages(max)),
|
||||
shared: memory.shared,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user