diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-22 12:05:20 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 09:55:04 -0700 |
commit | db5ee8d83eb32fc7fd007f9e3d9b46d748161ae7 (patch) | |
tree | d2a38a4e49d84a1721420cf3b1f2973f368604dc /src | |
parent | 266e922cddf0a5c78ed22f046eeebc053a9305c0 (diff) | |
download | binaryen-db5ee8d83eb32fc7fd007f9e3d9b46d748161ae7.tar.gz binaryen-db5ee8d83eb32fc7fd007f9e3d9b46d748161ae7.tar.bz2 binaryen-db5ee8d83eb32fc7fd007f9e3d9b46d748161ae7.zip |
set type of calls to their target, instead of the previous behavior where the asm.js context informed us. this lets us add drops where necessary
Diffstat (limited to 'src')
-rw-r--r-- | src/asm2wasm.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index a85fd4676..5167ad70f 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -401,9 +401,9 @@ private: } void fixCallType(Expression* call, WasmType type) { - if (call->is<Call>()) call->type = type; - if (call->is<CallImport>()) call->type = type; - else if (call->is<CallIndirect>()) call->type = type; + if (call->is<Call>()) call->cast<Call>()->type = type; + if (call->is<CallImport>()) call->cast<CallImport>()->type = type; + else if (call->is<CallIndirect>()) call->cast<CallIndirect>()->type = type; } FunctionType* getBuiltinFunctionType(Name module, Name base, ExpressionList* operands = nullptr) { @@ -736,7 +736,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { wasm.removeImport(curr); } - // Finalize indirect calls and import calls + // Finalize calls now that everything is known and generated struct FinalizeCalls : public WalkerPass<PostWalker<FinalizeCalls, Visitor<FinalizeCalls>>> { bool isFunctionParallel() override { return true; } @@ -747,6 +747,10 @@ void Asm2WasmBuilder::processAsm(Ref ast) { FinalizeCalls(Asm2WasmBuilder* parent) : parent(parent) {} + void visitCall(Call* curr) { + curr->type = getModule()->getFunction(curr->target)->result; + } + void visitCallImport(CallImport* curr) { // fill out call_import - add extra params as needed, etc. asm tolerates ffi overloading, wasm does not auto iter = parent->importedFunctionTypes.find(curr->target); @@ -768,6 +772,8 @@ void Asm2WasmBuilder::processAsm(Ref ast) { } } } + + curr->type = getModule()->getImport(curr->target)->functionType->result; } void visitCallIndirect(CallIndirect* curr) { // we already call into target = something + offset, where offset is a callImport with the name of the table. replace that with the table offset |