Commit 5468590a authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Fix hash value of ValueType

Since the equality operator uses the whole encoded bitfield, also the
hash value should use that. Otherwise get get unnecessary hash
collisions, resulting in bad hash table performance (e.g. in the
signature map).

R=manoskouk@chromium.org

Bug: v8:12593
Change-Id: I6f9b8ed1789ee937c90ece15d78b2bf5a3c357a6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3435189Reviewed-by: 's avatarManos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78921}
parent ef53e0a0
......@@ -534,6 +534,9 @@ class ValueType {
private:
STATIC_ASSERT(kV8MaxWasmTypes < (1u << kHeapTypeBits));
// {hash_value} directly reads {bit_field_}.
friend size_t hash_value(ValueType type);
using KindField = base::BitField<ValueKind, 0, kKindBits>;
using HeapTypeField = KindField::Next<uint32_t, kHeapTypeBits>;
......@@ -554,7 +557,8 @@ static_assert(ValueType::kLastUsedBit < 8 * sizeof(ValueType) - kSmiTagSize,
"ValueType has space to be encoded in a Smi");
inline size_t hash_value(ValueType type) {
return static_cast<size_t>(type.kind());
// Just use the whole encoded bit field, similar to {operator==}.
return static_cast<size_t>(type.bit_field_);
}
// Output operator, useful for DCHECKS and others.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment