diff options
author | Alon Zakai <azakai@google.com> | 2022-01-14 08:46:21 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-14 08:46:21 -0800 |
commit | 993ea84f82c2baf6cd4f7d397b5270715d8e0d6c (patch) | |
tree | c158ee91e44c181bd76d8c6e0d6e1218bff213d5 | |
parent | a971566d37ae44ff50eeec8ba4a2384d80684571 (diff) | |
download | binaryen-993ea84f82c2baf6cd4f7d397b5270715d8e0d6c.tar.gz binaryen-993ea84f82c2baf6cd4f7d397b5270715d8e0d6c.tar.bz2 binaryen-993ea84f82c2baf6cd4f7d397b5270715d8e0d6c.zip |
Add a fast path to isSubType (#4453)
We call this very frequently in the interpreter.
This is a 25% speedup on the benchmark in #4452
-rw-r--r-- | src/wasm/wasm-type.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 1b6313ad7..a63c66770 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -1049,6 +1049,10 @@ Type Type::get(unsigned byteSize, bool float_) { } bool Type::isSubType(Type left, Type right) { + // As an optimization, in the common case do not even construct a SubTyper. + if (left == right) { + return true; + } return SubTyper().isSubType(left, right); } @@ -1220,6 +1224,10 @@ bool HeapType::isNominal() const { } bool HeapType::isSubType(HeapType left, HeapType right) { + // As an optimization, in the common case do not even construct a SubTyper. + if (left == right) { + return true; + } return SubTyper().isSubType(left, right); } |