Skip to content

Commit b197db5

Browse files
committed
[NFC] Move HeapType::isBottom() to header
This makes Precompute about 5% faster on a WasmGC binary. Inspired by #6931.
1 parent 2705372 commit b197db5

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

src/wasm-type.h

+27
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,33 @@ std::ostream& operator<<(std::ostream&, Struct);
870870
std::ostream& operator<<(std::ostream&, Array);
871871
std::ostream& operator<<(std::ostream&, TypeBuilder::ErrorReason);
872872

873+
// Inline some nontrivial methods here for performance reasons.
874+
875+
inline bool HeapType::isBottom() const {
876+
if (isBasic()) {
877+
switch (getBasic(Unshared)) {
878+
case ext:
879+
case func:
880+
case cont:
881+
case any:
882+
case eq:
883+
case i31:
884+
case struct_:
885+
case array:
886+
case exn:
887+
case string:
888+
return false;
889+
case none:
890+
case noext:
891+
case nofunc:
892+
case nocont:
893+
case noexn:
894+
return true;
895+
}
896+
}
897+
return false;
898+
}
899+
873900
} // namespace wasm
874901

875902
namespace std {

src/wasm/wasm-type.cpp

-25
Original file line numberDiff line numberDiff line change
@@ -866,31 +866,6 @@ HeapTypeKind HeapType::getKind() const {
866866
return getHeapTypeInfo(*this)->kind;
867867
}
868868

869-
bool HeapType::isBottom() const {
870-
if (isBasic()) {
871-
switch (getBasic(Unshared)) {
872-
case ext:
873-
case func:
874-
case cont:
875-
case any:
876-
case eq:
877-
case i31:
878-
case struct_:
879-
case array:
880-
case exn:
881-
case string:
882-
return false;
883-
case none:
884-
case noext:
885-
case nofunc:
886-
case nocont:
887-
case noexn:
888-
return true;
889-
}
890-
}
891-
return false;
892-
}
893-
894869
bool HeapType::isOpen() const {
895870
if (isBasic()) {
896871
return false;

0 commit comments

Comments
 (0)