mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 22:25:40 +00:00
Merge branch 'fix/emscripten-translate' of github.com:wasmerio/wasmer into fix/emscripten-translate
This commit is contained in:
commit
f75006c062
@ -12,7 +12,7 @@ use wasmer_runtime_core::{
|
||||
global::Global,
|
||||
import::{ImportObject, Namespace},
|
||||
imports,
|
||||
memory::Memory,
|
||||
memory::{Memory, MemoryVariant},
|
||||
table::Table,
|
||||
types::{
|
||||
ElementType, FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor,
|
||||
@ -322,7 +322,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
|
||||
let import_object = imports! {
|
||||
"env" => {
|
||||
"memory" => Export::Memory(globals.memory.clone()),
|
||||
"memory" => Export::Memory(MemoryVariant::Unshared(globals.memory.clone())),
|
||||
"table" => Export::Table(globals.table.clone()),
|
||||
|
||||
// Globals
|
||||
|
@ -18,7 +18,7 @@ macro_rules! assert_emscripten_output {
|
||||
let mut emscripten_globals = EmscriptenGlobals::new(&module);
|
||||
let import_object = generate_emscripten_env(&mut emscripten_globals);
|
||||
|
||||
let mut instance = module.instantiate(import_object)
|
||||
let mut instance = module.instantiate(&import_object)
|
||||
.map_err(|err| format!("Can't instantiate the WebAssembly module: {:?}", err)).unwrap(); // NOTE: Need to figure what the unwrap is for ??
|
||||
|
||||
let capturer = StdioCapturer::new();
|
||||
|
@ -82,6 +82,7 @@ use wasmer_runtime_core::import::ImportObject;
|
||||
use wasmer_runtime_core::types::Value;
|
||||
use wasmer_runtime_core::{{Instance, module::Module}};
|
||||
use wasmer_runtime_core::error::Result;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
static IMPORT_MODULE: &str = r#"
|
||||
(module
|
||||
@ -99,7 +100,7 @@ pub fn generate_imports() -> ImportObject {
|
||||
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new())
|
||||
.expect("WASM can't be compiled");
|
||||
let instance = module
|
||||
.instantiate(ImportObject::new())
|
||||
.instantiate(&ImportObject::new())
|
||||
.expect("WASM can't be instantiated");
|
||||
let mut imports = ImportObject::new();
|
||||
imports.register("spectest", instance);
|
||||
@ -358,7 +359,7 @@ fn test_module_{}() {{
|
||||
println!(\"{{}}\", module_str);
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect(\"WAST not valid or malformed\");
|
||||
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new()).expect(\"WASM can't be compiled\");
|
||||
module.instantiate(generate_imports()).expect(\"WASM can't be instantiated\")
|
||||
module.instantiate(&generate_imports()).expect(\"WASM can't be instantiated\")
|
||||
}}\n",
|
||||
self.last_module,
|
||||
// We do this to ident four spaces, so it looks aligned to the function body
|
||||
@ -369,23 +370,6 @@ fn test_module_{}() {{
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
|
||||
// We set the start call to the module
|
||||
let start_module_call = format!("start_module_{}", self.last_module);
|
||||
self.buffer.push_str(
|
||||
format!(
|
||||
"\nfn {}(vmctx: &mut Ctx) {{
|
||||
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
|
||||
//instance.start();
|
||||
}}\n",
|
||||
start_module_call
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
self.module_calls
|
||||
.entry(self.last_module)
|
||||
.or_insert(Vec::new())
|
||||
.push(start_module_call);
|
||||
}
|
||||
|
||||
fn visit_assert_invalid(&mut self, module: &ModuleBinary) {
|
||||
@ -437,7 +421,7 @@ fn {}_assert_invalid() {{
|
||||
let func_name = format!("{}_assert_return_arithmetic_nan", self.command_name());
|
||||
self.buffer.push_str(
|
||||
format!(
|
||||
"fn {func_name}(vmctx: &mut Ctx) {{
|
||||
"fn {func_name}(instance: &mut Instance) {{
|
||||
println!(\"Executing function {{}}\", \"{func_name}\");
|
||||
let result = instance.call(\"{field}\", &[{args_values}]).unwrap().first().expect(\"Missing result in {func_name}\").clone();
|
||||
{assertion}
|
||||
@ -496,7 +480,7 @@ fn {}_assert_invalid() {{
|
||||
let func_name = format!("{}_assert_return_canonical_nan", self.command_name());
|
||||
self.buffer.push_str(
|
||||
format!(
|
||||
"fn {func_name}(vmctx: &mut Ctx) {{
|
||||
"fn {func_name}(instance: &mut Instance) {{
|
||||
println!(\"Executing function {{}}\", \"{func_name}\");
|
||||
let result = instance.call(\"{field}\", &[{args_values}]).unwrap().first().expect(\"Missing result in {func_name}\").clone();
|
||||
{assertion}
|
||||
@ -611,7 +595,7 @@ fn {}_assert_malformed() {{
|
||||
let func_name = format!("{}_action_invoke", self.command_name());
|
||||
self.buffer.push_str(
|
||||
format!(
|
||||
"fn {func_name}(vmctx: &mut Ctx) -> Result<()> {{
|
||||
"fn {func_name}(instance: &mut Instance) -> Result<()> {{
|
||||
println!(\"Executing function {{}}\", \"{func_name}\");
|
||||
let result = instance.call(\"{field}\", &[{args_values}]);
|
||||
{assertion}
|
||||
|
Loading…
Reference in New Issue
Block a user