diff --git a/include/proxy-wasm/wasm.h b/include/proxy-wasm/wasm.h index 9b85710b..00e11f50 100644 --- a/include/proxy-wasm/wasm.h +++ b/include/proxy-wasm/wasm.h @@ -226,6 +226,8 @@ class WasmBase : public std::enable_shared_from_this { WasmCallVoid<0> _start_; /* WASI command (Emscripten v1.39.0+, TinyGo) */ WasmCallWord<2> main_; + WasmCallWord<0> __main_void_; + WasmCallWord<1> malloc_; // Calls into the VM. diff --git a/include/proxy-wasm/wasm_vm.h b/include/proxy-wasm/wasm_vm.h index e2e2ea0b..9fc435d3 100644 --- a/include/proxy-wasm/wasm_vm.h +++ b/include/proxy-wasm/wasm_vm.h @@ -71,8 +71,8 @@ using WasmCallWord = std::function) _f(proxy_wasm::WasmCallVoid<1>) _f(proxy_wasm::WasmCallVoid<2>) \ _f(proxy_wasm::WasmCallVoid<3>) _f(proxy_wasm::WasmCallVoid<5>) \ - _f(proxy_wasm::WasmCallWord<1>) _f(proxy_wasm::WasmCallWord<2>) \ - _f(proxy_wasm::WasmCallWord<3>) + _f(proxy_wasm::WasmCallWord<0>) _f(proxy_wasm::WasmCallWord<1>) \ + _f(proxy_wasm::WasmCallWord<2>) _f(proxy_wasm::WasmCallWord<3>) // These are templates and its helper for constructing signatures of functions callbacks from Wasm // VMs. diff --git a/src/wasm.cc b/src/wasm.cc index a1b4c183..6502cd03 100644 --- a/src/wasm.cc +++ b/src/wasm.cc @@ -162,6 +162,7 @@ void WasmBase::getFunctions() { _GET(_initialize); if (_initialize_) { _GET(main); + _GET(__main_void); } else { _GET(_start); } @@ -410,6 +411,8 @@ void WasmBase::startVm(ContextBase *root_context) { // Re-using main() keeps this consistent when switching between // WASI command (that calls main()) and reactor (that doesn't). main_(root_context, Word(0), Word(0)); + } else if (__main_void_) { + __main_void_(root_context); } } else if (_start_) { // WASI command.