Skip to content

Commit 9e8a21b

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm] Improve the hash for function type parameters.
AOT compiling the isolate stress test spends the majority of its time canonicalizing function types. In release mode, 2:45 -> 1:43 (-38%) TEST=ci Change-Id: I58ef0157612930d582784c7bea7de177c1219a0d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408941 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 4cf27cc commit 9e8a21b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

runtime/vm/object.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23610,10 +23610,18 @@ void TypeParameter::PrintName(NameVisibility name_visibility,
2361023610

2361123611
uword TypeParameter::ComputeHash() const {
2361223612
ASSERT(IsFinalized());
23613-
uint32_t result = parameterized_class_id();
23614-
result = CombineHashes(result, base());
23613+
uint32_t result = base();
2361523614
result = CombineHashes(result, index());
2361623615
result = CombineHashes(result, static_cast<uint32_t>(nullability()));
23616+
if (IsFunctionTypeParameter()) {
23617+
const FunctionType& func =
23618+
FunctionType::Handle(parameterized_function_type());
23619+
result = CombineHashes(result, func.packed_parameter_counts());
23620+
result = CombineHashes(result, func.packed_type_parameter_counts());
23621+
} else {
23622+
ASSERT(IsClassTypeParameter());
23623+
result = CombineHashes(result, parameterized_class_id());
23624+
}
2361723625
result = FinalizeHash(result, kHashBits);
2361823626
SetHash(result);
2361923627
return result;

0 commit comments

Comments
 (0)