summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wasm-interpreter.h6
-rw-r--r--src/wasm-js.cpp9
-rw-r--r--src/wasm-validator.h12
3 files changed, 16 insertions, 11 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 2206bfcae..a8b4b5614 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -650,8 +650,10 @@ private:
Function *func = instance.wasm.getFunction(name);
if (func->type.is() && func->type != curr->fullType) trap("callIndirect: bad type");
if (func->params.size() != arguments.size()) trap("callIndirect: bad # of arguments");
- for (size_t i = 0; i < func->getNumLocals(); i++) {
- if (func->params[i] != arguments[i].type) trap("callIndirect: bad argument type");
+ for (size_t i = 0; i < func->params.size(); i++) {
+ if (func->params[i] != arguments[i].type) {
+ trap("callIndirect: bad argument type");
+ }
}
return instance.callFunctionInternal(name, arguments);
}
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp
index 87059f9be..33b0faa55 100644
--- a/src/wasm-js.cpp
+++ b/src/wasm-js.cpp
@@ -79,12 +79,9 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_asm2wasm(char *input) {
module->memory.max = pre.memoryGrowth ? Address(Memory::kMaxSize) : module->memory.initial;
if (wasmJSDebug) std::cerr << "wasming...\n";
- asm2wasm = new Asm2WasmBuilder(*module, pre.memoryGrowth, debug, false /* TODO: support imprecise? */);
+ asm2wasm = new Asm2WasmBuilder(*module, pre.memoryGrowth, debug, false /* TODO: support imprecise? */, false /* TODO: support optimizing? */);
asm2wasm->processAsm(asmjs);
- if (wasmJSDebug) std::cerr << "optimizing...\n";
- asm2wasm->optimize();
-
if (wasmJSDebug) std::cerr << "mapping globals...\n";
for (auto& pair : asm2wasm->mappedGlobals) {
auto name = pair.first;
@@ -200,7 +197,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() {
}
}
- Literal callImport(Import *import, ModuleInstance::LiteralList& arguments) override {
+ Literal callImport(Import *import, LiteralList& arguments) override {
if (wasmJSDebug) std::cout << "calling import " << import->name.str << '\n';
EM_ASM({
Module['tempArguments'] = [];
@@ -436,7 +433,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE call_from_js(const char *target) {
assert(function);
size_t seen = EM_ASM_INT_V({ return Module['tempArguments'].length });
size_t actual = function->params.size();
- ModuleInstance::LiteralList arguments;
+ LiteralList arguments;
for (size_t i = 0; i < actual; i++) {
WasmType type = function->params[i];
// add the parameter, with a zero value if JS did not provide it.
diff --git a/src/wasm-validator.h b/src/wasm-validator.h
index 76e142725..ac8cac410 100644
--- a/src/wasm-validator.h
+++ b/src/wasm-validator.h
@@ -98,7 +98,9 @@ public:
if (!shouldBeTrue(!!target, curr, "call target must exist")) return;
if (!shouldBeTrue(curr->operands.size() == target->params.size(), curr, "call param number must match")) return;
for (size_t i = 0; i < curr->operands.size(); i++) {
- shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, target->params[i], curr, "call param types must match");
+ if (!shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, target->params[i], curr, "call param types must match")) {
+ std::cerr << "(on argument " << i << ")\n";
+ }
}
}
void visitCallImport(CallImport *curr) {
@@ -107,7 +109,9 @@ public:
auto* type = import->type;
if (!shouldBeTrue(curr->operands.size() == type->params.size(), curr, "call param number must match")) return;
for (size_t i = 0; i < curr->operands.size(); i++) {
- shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, type->params[i], curr, "call param types must match");
+ if (!shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, type->params[i], curr, "call param types must match")) {
+ std::cerr << "(on argument " << i << ")\n";
+ }
}
}
void visitCallIndirect(CallIndirect *curr) {
@@ -116,7 +120,9 @@ public:
shouldBeEqualOrFirstIsUnreachable(curr->target->type, i32, curr, "indirect call target must be an i32");
if (!shouldBeTrue(curr->operands.size() == type->params.size(), curr, "call param number must match")) return;
for (size_t i = 0; i < curr->operands.size(); i++) {
- shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, type->params[i], curr, "call param types must match");
+ if (!shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, type->params[i], curr, "call param types must match")) {
+ std::cerr << "(on argument " << i << ")\n";
+ }
}
}
void visitSetLocal(SetLocal *curr) {