mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 22:25:40 +00:00
Update emscripten memory macro
This commit is contained in:
parent
8a8290b155
commit
cee248ae89
@ -12,7 +12,7 @@ use wasmer_runtime_core::{
|
|||||||
global::Global,
|
global::Global,
|
||||||
import::{ImportObject, Namespace},
|
import::{ImportObject, Namespace},
|
||||||
imports,
|
imports,
|
||||||
memory::{Memory, MemoryVariant},
|
memory::Memory,
|
||||||
table::Table,
|
table::Table,
|
||||||
types::{
|
types::{
|
||||||
ElementType, FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor,
|
ElementType, FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor,
|
||||||
@ -303,18 +303,18 @@ impl EmscriptenGlobals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject {
|
pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject {
|
||||||
use crate::varargs::VarArgs;
|
// use crate::varargs::VarArgs;
|
||||||
let mut imports = ImportObject::new();
|
// let mut imports = ImportObject::new();
|
||||||
let mut env_namespace = Namespace::new();
|
// let mut env_namespace = Namespace::new();
|
||||||
let mut asm_namespace = Namespace::new();
|
// let mut asm_namespace = Namespace::new();
|
||||||
let mut global_namespace = Namespace::new();
|
// let mut global_namespace = Namespace::new();
|
||||||
let mut global_math_namespace = Namespace::new();
|
// let mut global_math_namespace = Namespace::new();
|
||||||
|
|
||||||
// Add globals.
|
// // Add globals.
|
||||||
// NOTE: There is really no need for checks, these globals should always be available.
|
// // NOTE: There is really no need for checks, these globals should always be available.
|
||||||
|
|
||||||
// We generate a fake Context that traps on access
|
// // We generate a fake Context that traps on access
|
||||||
let null_ctx = Context::External(ptr::null_mut());
|
// let null_ctx = Context::External(ptr::null_mut());
|
||||||
|
|
||||||
// env_namespace.insert("memory".to_string(), Export::Memory(globals.memory.clone()));
|
// env_namespace.insert("memory".to_string(), Export::Memory(globals.memory.clone()));
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
|
|
||||||
let import_object = imports! {
|
let import_object = imports! {
|
||||||
"env" => {
|
"env" => {
|
||||||
"memory" => Export::Memory(MemoryVariant::Unshared(globals.memory.clone())),
|
"memory" => Export::Memory(globals.memory.clone()),
|
||||||
"table" => Export::Table(globals.table.clone()),
|
"table" => Export::Table(globals.table.clone()),
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
@ -514,12 +514,12 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
// mock_external!(env_namespace, _getgrent);
|
// mock_external!(env_namespace, _getgrent);
|
||||||
// mock_external!(env_namespace, _dlerror);
|
// mock_external!(env_namespace, _dlerror);
|
||||||
|
|
||||||
imports.register("env", env_namespace);
|
// imports.register("env", env_namespace);
|
||||||
imports.register("asm2wasm", asm_namespace);
|
// imports.register("asm2wasm", asm_namespace);
|
||||||
imports.register("global", global_namespace);
|
// imports.register("global", global_namespace);
|
||||||
imports.register("global.Math", global_math_namespace);
|
// imports.register("global.Math", global_math_namespace);
|
||||||
|
|
||||||
imports
|
import_object
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The current version of this crate
|
/// The current version of this crate
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
macro_rules! emscripten_memory_pointer {
|
macro_rules! emscripten_memory_pointer {
|
||||||
($memory:expr, $pointer:expr) => {
|
($memory:expr, $pointer:expr) => {{
|
||||||
0 as usize
|
use std::cell::Cell;
|
||||||
// unsafe { $memory.as_ptr().add($pointer as usize) }
|
(&$memory.view::<u8>()[($pointer as usize)..]).as_ptr() as *mut Cell<u8> as *mut u8
|
||||||
};
|
}};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user