Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index 29c473933d8d086dfeba67be46614f7850eae603..ea9f09856bcabcd357256deda1e42b0223937432 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -4635,7 +4635,7 @@ static uint32_t FinalizeHash(uint32_t hash) { |
} |
-intptr_t TypeArguments::Hash() const { |
+intptr_t TypeArguments::ComputeHash() const { |
if (IsNull()) return 0; |
const intptr_t num_types = Length(); |
if (IsRaw(0, num_types)) return 0; |
@@ -4647,7 +4647,9 @@ intptr_t TypeArguments::Hash() const { |
// purposes only) while a type argument is still temporarily null. |
result = CombineHashes(result, type.IsNull() ? 0 : type.Hash()); |
} |
- return FinalizeHash(result); |
+ result = FinalizeHash(result); |
+ SetHash(result); |
+ return result; |
} |
@@ -5098,6 +5100,7 @@ RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { |
result ^= raw; |
// Length must be set before we start storing into the array. |
result.SetLength(len); |
+ result.SetHash(0); |
} |
// The zero array should have been initialized. |
ASSERT(Object::zero_array().raw() != Array::null()); |
@@ -16885,6 +16888,8 @@ RawAbstractType* Type::Canonicalize(TrailPtr trail) const { |
Isolate* isolate = thread->isolate(); |
AbstractType& type = Type::Handle(zone); |
const Class& cls = Class::Handle(zone, type_class()); |
+ intptr_t hash = Hash(); |
+ USE(hash); // Will be used to store the type in a hash map. |
// Since void is a keyword, we never have to canonicalize the void type after |
// it is canonicalized once by the vm isolate. The parser does the mapping. |
ASSERT((cls.raw() != Object::void_class()) || |
@@ -17035,7 +17040,7 @@ RawString* Type::EnumerateURIs() const { |
} |
-intptr_t Type::Hash() const { |
+intptr_t Type::ComputeHash() const { |
ASSERT(IsFinalized()); |
uint32_t result = 1; |
if (IsMalformed()) return result; |
@@ -17059,7 +17064,9 @@ intptr_t Type::Hash() const { |
} |
} |
} |
- return FinalizeHash(result); |
+ result = FinalizeHash(result); |
+ SetHash(result); |
+ return result; |
} |
@@ -17090,6 +17097,7 @@ RawType* Type::New(const Object& clazz, |
const Type& result = Type::Handle(Type::New(space)); |
result.set_type_class(clazz); |
result.set_arguments(arguments); |
+ result.SetHash(0); |
result.set_token_pos(token_pos); |
result.StoreNonPointer(&result.raw_ptr()->type_state_, RawType::kAllocated); |
return result.raw(); |
@@ -17499,13 +17507,15 @@ RawString* TypeParameter::EnumerateURIs() const { |
} |
-intptr_t TypeParameter::Hash() const { |
+intptr_t TypeParameter::ComputeHash() const { |
ASSERT(IsFinalized()); |
uint32_t result = Class::Handle(parameterized_class()).id(); |
// No need to include the hash of the bound, since the type parameter is fully |
// identified by its class and index. |
result = CombineHashes(result, index()); |
- return FinalizeHash(result); |
+ result = FinalizeHash(result); |
+ SetHash(result); |
+ return result; |
} |
@@ -17527,6 +17537,7 @@ RawTypeParameter* TypeParameter::New(const Class& parameterized_class, |
result.set_index(index); |
result.set_name(name); |
result.set_bound(bound); |
+ result.SetHash(0); |
result.set_token_pos(token_pos); |
result.StoreNonPointer(&result.raw_ptr()->type_state_, |
RawTypeParameter::kAllocated); |
@@ -17763,13 +17774,15 @@ RawString* BoundedType::EnumerateURIs() const { |
} |
-intptr_t BoundedType::Hash() const { |
+intptr_t BoundedType::ComputeHash() const { |
uint32_t result = AbstractType::Handle(type()).Hash(); |
// No need to include the hash of the bound, since the bound is defined by the |
// type parameter (modulo instantiation state). |
result = CombineHashes(result, |
TypeParameter::Handle(type_parameter()).Hash()); |
- return FinalizeHash(result); |
+ result = FinalizeHash(result); |
+ SetHash(result); |
+ return result; |
} |
@@ -17787,6 +17800,7 @@ RawBoundedType* BoundedType::New(const AbstractType& type, |
const BoundedType& result = BoundedType::Handle(BoundedType::New()); |
result.set_type(type); |
result.set_bound(bound); |
+ result.SetHash(0); |
result.set_type_parameter(type_parameter); |
return result.raw(); |
} |