From 7b3093ff7fa0db60d90950ae1bde313d1e2a06d0 Mon Sep 17 00:00:00 2001 From: Syrus Date: Thu, 14 Nov 2019 12:07:53 -0800 Subject: [PATCH 1/4] Added invoke option to the command --- src/bin/wasmer.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 6195e60a612..7af5df3e258 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -132,6 +132,10 @@ struct Run { )] backend: Backend, + /// Invoke a specified function + #[structopt(long = "invoke", short = "i")] + invoke: Option, + /// Emscripten symbol map #[structopt(long = "em-symbol-map", parse(from_os_str), group = "emscripten")] em_symbol_map: Option, @@ -683,8 +687,12 @@ fn execute_wasm(options: &Run) -> Result<(), String> { args.push(Value::I32(x)); } + let invoke_fn = match options.invoke.as_ref() { + Some(fun) => fun, + _ => "main", + }; instance - .dyn_func("main") + .dyn_func(&invoke_fn) .map_err(|e| format!("{:?}", e))? .call(&args) .map_err(|e| format!("{:?}", e))?; From d0960dc390f4c1e951d4d6c00ae7273c14d50bc5 Mon Sep 17 00:00:00 2001 From: Syrus Date: Thu, 14 Nov 2019 12:10:44 -0800 Subject: [PATCH 2/4] Added changes to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3bcfcd9518..3f3f4a4d991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#968](https://github.com/wasmerio/wasmer/pull/968) Added `--invoke` option to the command - [#925](https://github.com/wasmerio/wasmer/pull/925) Host functions can be closures with a captured environment. - [#917](https://github.com/wasmerio/wasmer/pull/917) Host functions (aka imported functions) may not have `&mut vm::Ctx` as first argument, i.e. the presence of the `&mut vm::Ctx` argument is optional. - [#915](https://github.com/wasmerio/wasmer/pull/915) All backends share the same definition of `Trampoline` (defined in `wasmer-runtime-core`). From f3b7c6b321b06dad25d9892b0c3c4b302843a6b0 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 15 Nov 2019 10:41:18 -0800 Subject: [PATCH 3/4] Improved wasmer invoke based on feedback --- src/bin/wasmer.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 7af5df3e258..48f43c917a1 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -687,10 +687,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { args.push(Value::I32(x)); } - let invoke_fn = match options.invoke.as_ref() { - Some(fun) => fun, - _ => "main", - }; + let invoke_fn = options.invoke.clone().unwrap_or("main".to_owned()); instance .dyn_func(&invoke_fn) .map_err(|e| format!("{:?}", e))? From 3d3636059a7dbb06b20fa915d6f5fbf3e92774bb Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 15 Nov 2019 14:04:48 -0800 Subject: [PATCH 4/4] Revert "Improved wasmer invoke based on feedback" This reverts commit f3b7c6b321b06dad25d9892b0c3c4b302843a6b0. --- src/bin/wasmer.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 48f43c917a1..7af5df3e258 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -687,7 +687,10 @@ fn execute_wasm(options: &Run) -> Result<(), String> { args.push(Value::I32(x)); } - let invoke_fn = options.invoke.clone().unwrap_or("main".to_owned()); + let invoke_fn = match options.invoke.as_ref() { + Some(fun) => fun, + _ => "main", + }; instance .dyn_func(&invoke_fn) .map_err(|e| format!("{:?}", e))?