diff options
author | Thomas Lively <tlively@google.com> | 2024-12-13 13:24:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-13 13:24:07 -0800 |
commit | 484adec87c8b988cbb24d0a2fc4718ac69625173 (patch) | |
tree | 5a7f4d39482ce6e9ac417063d6bb9123a9729ee3 | |
parent | 8a88ba280b2847d4d25d0859a87529e2132ebab8 (diff) | |
download | binaryen-484adec87c8b988cbb24d0a2fc4718ac69625173.tar.gz binaryen-484adec87c8b988cbb24d0a2fc4718ac69625173.tar.bz2 binaryen-484adec87c8b988cbb24d0a2fc4718ac69625173.zip |
[NFC] Move HeapType::isBottom() to header (#7150)
This makes Precompute about 5% faster on a WasmGC binary.
Inspired by #6931.
-rw-r--r-- | src/wasm-type.h | 27 | ||||
-rw-r--r-- | src/wasm/wasm-type.cpp | 25 |
2 files changed, 27 insertions, 25 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h index b48a10713..1e7c0a0ba 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -870,6 +870,33 @@ std::ostream& operator<<(std::ostream&, Struct); std::ostream& operator<<(std::ostream&, Array); std::ostream& operator<<(std::ostream&, TypeBuilder::ErrorReason); +// Inline some nontrivial methods here for performance reasons. + +inline bool HeapType::isBottom() const { + if (isBasic()) { + switch (getBasic(Unshared)) { + case ext: + case func: + case cont: + case any: + case eq: + case i31: + case struct_: + case array: + case exn: + case string: + return false; + case none: + case noext: + case nofunc: + case nocont: + case noexn: + return true; + } + } + return false; +} + } // namespace wasm namespace std { diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index a6ed68770..4f341588b 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -866,31 +866,6 @@ HeapTypeKind HeapType::getKind() const { return getHeapTypeInfo(*this)->kind; } -bool HeapType::isBottom() const { - if (isBasic()) { - switch (getBasic(Unshared)) { - case ext: - case func: - case cont: - case any: - case eq: - case i31: - case struct_: - case array: - case exn: - case string: - return false; - case none: - case noext: - case nofunc: - case nocont: - case noexn: - return true; - } - } - return false; -} - bool HeapType::isOpen() const { if (isBasic()) { return false; |