diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-11-22 17:32:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 17:32:08 -0800 |
commit | 37999167bb333dd0b12d744af8e633897e65cff8 (patch) | |
tree | 4f70902c55b8fcd58c3793368c489111f519da30 /src/wasm/wasm.cpp | |
parent | 962ecc84cd12bce59d0b2f969aa71ecafbe38ca6 (diff) | |
download | binaryen-37999167bb333dd0b12d744af8e633897e65cff8.tar.gz binaryen-37999167bb333dd0b12d744af8e633897e65cff8.tar.bz2 binaryen-37999167bb333dd0b12d744af8e633897e65cff8.zip |
Change from storing Signature to HeapType on CallIndirect (#4352)
With nominal function types, this change makes it so that we preserve the
identity of the function type used with call_indirect instructions rather than
recreating a function heap type, which may or may not be the same as the
originally parsed heap type, from the function signature during module writing.
This will simplify the type system implementation by removing the need to store
a "canonical" nominal heap type for each unique signature. We previously
depended on those canonical types to avoid creating multiple duplicate function
types during module writing, but now we aren't creating any new function types
at all.
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r-- | src/wasm/wasm.cpp | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index fd3cec8d8..d220b7162 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -290,7 +290,7 @@ void Call::finalize() { } void CallIndirect::finalize() { - type = sig.results; + type = heapType.getSignature().results; handleUnreachableOperands(this); if (isReturn) { type = Type::unreachable; @@ -300,30 +300,6 @@ void CallIndirect::finalize() { } } -HeapType CallIndirect::getHeapType(Module* module) { - auto heapType = HeapType(sig); - // See comment in wasm.h - if (module) { - // The table may not yet exist if the wasm module is still being - // constructed. This should perhaps be an error, but as this is a hack for - // the time being, handle this the same as the case where module is null. - // Note: table_ (with underscore) is needed as |table| is a field on |this|. - if (auto* table_ = module->getTableOrNull(table)) { - // The wasm spec may allow more things eventually, and if so we'd need to - // add more checking here. - assert(table_->type.isRef()); - auto tableHeapType = table_->type.getHeapType(); - if (tableHeapType.isSignature()) { - auto tableSig = tableHeapType.getSignature(); - if (sig == tableSig) { - heapType = tableHeapType; - } - } - } - } - return heapType; -} - bool LocalSet::isTee() const { return type != Type::none; } // Changes to local.tee. The type of the local should be given. |