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

[codegen] (Slightly) speed up hashing of signatures

The hash of signatures currently has redundancy: We hash both the
parameter count and the return count, plus all contained values.
The total count of contained values is already implicitly captured by
{hash_combine}ing the individual values, thus it's enough to only
include one of parameter count and return count.

R=manoskouk@chromium.org

Bug: v8:12593
Change-Id: I6d3e8b15f4251964e3a74ae5411d06a7d41183a8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3460415Reviewed-by: 's avatarManos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79095}
parent ca68fc73
......@@ -127,9 +127,12 @@ using MachineSignature = Signature<MachineType>;
template <typename T>
size_t hash_value(const Signature<T>& sig) {
size_t hash = base::hash_combine(sig.parameter_count(), sig.return_count());
for (const T& t : sig.all()) hash = base::hash_combine(hash, t);
return hash;
// Hash over all contained representations, plus the parameter count to
// differentiate signatures with the same representation array but different
// parameter/return count.
size_t seed = base::hash_value(sig.parameter_count());
for (T rep : sig.all()) seed = base::hash_combine(seed, base::hash<T>{}(rep));
return seed;
}
template <typename T, size_t kNumReturns = 0, size_t kNumParams = 0>
......
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