summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/shell-interface.h3
-rw-r--r--src/wasm-interpreter.h4
-rw-r--r--src/wasm-js.cpp5
3 files changed, 5 insertions, 7 deletions
diff --git a/src/shell-interface.h b/src/shell-interface.h
index 2b0c491b9..f9afe21fb 100644
--- a/src/shell-interface.h
+++ b/src/shell-interface.h
@@ -126,10 +126,9 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface {
abort();
}
- Literal callTable(Index index, Name type, LiteralList& arguments, ModuleInstance& instance) override {
+ Literal callTable(Index index, LiteralList& arguments, WasmType result, ModuleInstance& instance) override {
if (index >= table.size()) trap("callTable overflow");
auto* func = instance.wasm.getFunction(table[index]);
- if (func->type.is() && func->type != type) trap("callIndirect: bad type");
if (func->params.size() != arguments.size()) trap("callIndirect: bad # of arguments");
for (size_t i = 0; i < func->params.size(); i++) {
if (func->params[i] != arguments[i].type) {
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 247d34500..f237f63db 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -542,7 +542,7 @@ public:
struct ExternalInterface {
virtual void init(Module& wasm) {}
virtual Literal callImport(Import* import, LiteralList& arguments) = 0;
- virtual Literal callTable(Index index, Name type, LiteralList& arguments, ModuleInstance& instance) = 0;
+ virtual Literal callTable(Index index, LiteralList& arguments, WasmType result, ModuleInstance& instance) = 0;
virtual Literal load(Load* load, Address addr) = 0;
virtual void store(Store* store, Address addr, Literal value) = 0;
virtual void growMemory(Address oldSize, Address newSize) = 0;
@@ -681,7 +681,7 @@ public:
Flow target = visit(curr->target);
if (target.breaking()) return target;
Index index = target.value.geti32();
- return instance.externalInterface->callTable(index, curr->fullType, arguments, instance);
+ return instance.externalInterface->callTable(index, arguments, curr->type, instance);
}
Flow visitGetLocal(GetLocal *curr) {
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp
index 66dcb4864..3c3c4eec7 100644
--- a/src/wasm-js.cpp
+++ b/src/wasm-js.cpp
@@ -255,7 +255,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() {
return getResultFromJS(ret, import->type->result);
}
- Literal callTable(Index index, Name type, LiteralList& arguments, ModuleInstance& instance) override {
+ Literal callTable(Index index, LiteralList& arguments, WasmType result, ModuleInstance& instance) override {
void* ptr = (void*)EM_ASM_INT({
var value = Module['outside']['wasmTable'][$0];
return typeof value === "number" ? value : -1;
@@ -264,7 +264,6 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() {
if (ptr != (void*)-1) {
// a Function we can call
Function* func = (Function*)ptr;
- if (func->type.is() && func->type != type) trap("callIndirect: bad type");
if (func->params.size() != arguments.size()) trap("callIndirect: bad # of arguments");
for (size_t i = 0; i < func->params.size(); i++) {
if (func->params[i] != arguments[i].type) {
@@ -281,7 +280,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() {
Module['tempArguments'] = null;
return func.apply(null, tempArguments);
}, index);
- return getResultFromJS(ret, instance.wasm.getFunctionType(type)->result);
+ return getResultFromJS(ret, result);
}
}