author | Jan de Mooij <jdemooij@mozilla.com> |
Tue, 08 Feb 2022 15:23:35 +0000 | |
changeset 607094 | b57b87a024c030978b8477b0b6989ea8698c62e3 |
parent 607093 | 3bb6f9ea44f794d8348af9773945fc4c17f0970e |
child 607095 | f64a89bf96817cd2796e6cc0bce11698e872c0fe |
push id | 39260 |
push user | mlaza@mozilla.com |
push date | Tue, 08 Feb 2022 21:51:08 +0000 |
treeherder | mozilla-central@bad861b89142 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | iain |
bugs | 1753633 |
milestone | 99.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/src/vm/PropertyKey.h +++ b/js/src/vm/PropertyKey.h @@ -13,28 +13,38 @@ #include "js/HashTable.h" // js::DefaultHasher #include "js/Id.h" // JS::PropertyKey #include "vm/StringType.h" // JSAtom::hash #include "vm/SymbolType.h" // JS::Symbol::hash namespace js { -static MOZ_ALWAYS_INLINE js::HashNumber HashPropertyKey(PropertyKey key) { +static MOZ_ALWAYS_INLINE HashNumber HashPropertyKey(PropertyKey key) { // HashGeneric alone would work, but bits of atom and symbol addresses // could then be recovered from the hash code. See bug 1330769. if (MOZ_LIKELY(key.isAtom())) { return key.toAtom()->hash(); } if (key.isSymbol()) { return key.toSymbol()->hash(); } return mozilla::HashGeneric(key.asBits); } +// Like HashPropertyKey but optimized for callers that only use atom or symbol +// keys. +static MOZ_ALWAYS_INLINE HashNumber +HashAtomOrSymbolPropertyKey(PropertyKey key) { + if (MOZ_LIKELY(key.isAtom())) { + return key.toAtom()->hash(); + } + return key.toSymbol()->hash(); +} + } // namespace js namespace mozilla { template <> struct DefaultHasher<JS::PropertyKey> { using Lookup = JS::PropertyKey; static HashNumber hash(JS::PropertyKey key) {