Merge branch 'fix/emscripten-translate' of github.com:wasmerio/wasmer into fix/emscripten-translate

This commit is contained in:
Lachlan Sneff 2019-02-04 23:08:46 -08:00
commit f75006c062
3 changed files with 9 additions and 25 deletions

View File

@ -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

View File

@ -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();

View File

@ -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}