From 993ea84f82c2baf6cd4f7d397b5270715d8e0d6c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 14 Jan 2022 08:46:21 -0800 Subject: 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 --- src/wasm/wasm-type.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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); } -- cgit v1.2.3