[vm] Fix poor hash performance of CodeSet.

Observed this taking ~2% of debug gen_snapshot time.

TEST=ci
Change-Id: I657148904fe2b5a8f3dfbd006c3d1327aa3866ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506261
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak
2026-05-27 07:21:32 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent b0a82e98d5
commit 0ff42aac19
+4 -1
View File
@@ -3278,7 +3278,10 @@ void Precompiler::PruneDictionaries() {
// Traits for the HashTable template.
struct CodeKeyTraits {
static uint32_t Hash(const Object& key) { return Code::Cast(key).Size(); }
static uint32_t Hash(const Object& key) {
// Instructions never move.
return FinalizeHash(Code::Cast(key).PayloadStart());
}
static const char* Name() { return "CodeKeyTraits"; }
static bool IsMatch(const Object& x, const Object& y) {
return x.ptr() == y.ptr();