From 0ff42aac19ca67c0855d81e68478c964287d30bc Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 27 May 2026 07:21:32 -0700 Subject: [PATCH] [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 Commit-Queue: Ryan Macnak --- runtime/vm/compiler/aot/precompiler.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc index e72e79e4190..4f7fabedab5 100644 --- a/runtime/vm/compiler/aot/precompiler.cc +++ b/runtime/vm/compiler/aot/precompiler.cc @@ -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();