| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/become.h" | 10 #include "vm/become.h" |
| (...skipping 4526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4537 hash += hash << 10; | 4537 hash += hash << 10; |
| 4538 hash ^= hash >> 6; // Logical shift, unsigned hash. | 4538 hash ^= hash >> 6; // Logical shift, unsigned hash. |
| 4539 return hash; | 4539 return hash; |
| 4540 } | 4540 } |
| 4541 | 4541 |
| 4542 | 4542 |
| 4543 static uint32_t FinalizeHash(uint32_t hash, intptr_t hashbits) { | 4543 static uint32_t FinalizeHash(uint32_t hash, intptr_t hashbits) { |
| 4544 hash += hash << 3; | 4544 hash += hash << 3; |
| 4545 hash ^= hash >> 11; // Logical shift, unsigned hash. | 4545 hash ^= hash >> 11; // Logical shift, unsigned hash. |
| 4546 hash += hash << 15; | 4546 hash += hash << 15; |
| 4547 hash &= ((static_cast<uintptr_t>(1) << hashbits) - 1); | 4547 hash &= (static_cast<uint32_t>(1) << hashbits) - 1; |
| 4548 return (hash == 0) ? 1 : hash; | 4548 return (hash == 0) ? 1 : hash; |
| 4549 } | 4549 } |
| 4550 | 4550 |
| 4551 | 4551 |
| 4552 intptr_t TypeArguments::ComputeHash() const { | 4552 intptr_t TypeArguments::ComputeHash() const { |
| 4553 if (IsNull()) return 0; | 4553 if (IsNull()) return 0; |
| 4554 const intptr_t num_types = Length(); | 4554 const intptr_t num_types = Length(); |
| 4555 if (IsRaw(0, num_types)) return 0; | 4555 if (IsRaw(0, num_types)) return 0; |
| 4556 uint32_t result = 0; | 4556 uint32_t result = 0; |
| 4557 AbstractType& type = AbstractType::Handle(); | 4557 AbstractType& type = AbstractType::Handle(); |
| (...skipping 12897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17455 ASSERT(this->Equals(type)); | 17455 ASSERT(this->Equals(type)); |
| 17456 ASSERT(type.IsCanonical()); | 17456 ASSERT(type.IsCanonical()); |
| 17457 return type.raw(); | 17457 return type.raw(); |
| 17458 } | 17458 } |
| 17459 | 17459 |
| 17460 ObjectStore* object_store = isolate->object_store(); | 17460 ObjectStore* object_store = isolate->object_store(); |
| 17461 { | 17461 { |
| 17462 SafepointMutexLocker ml(isolate->type_canonicalization_mutex()); | 17462 SafepointMutexLocker ml(isolate->type_canonicalization_mutex()); |
| 17463 CanonicalTypeSet table(zone, object_store->canonical_types()); | 17463 CanonicalTypeSet table(zone, object_store->canonical_types()); |
| 17464 type ^= table.GetOrNull(CanonicalTypeKey(*this)); | 17464 type ^= table.GetOrNull(CanonicalTypeKey(*this)); |
| 17465 object_store->set_canonical_types(table.Release()); | 17465 ASSERT(object_store->canonical_types() == table.Release().raw()); |
| 17466 } | 17466 } |
| 17467 if (type.IsNull()) { | 17467 if (type.IsNull()) { |
| 17468 // The type was not found in the table. It is not canonical yet. | 17468 // The type was not found in the table. It is not canonical yet. |
| 17469 | 17469 |
| 17470 // Canonicalize the type arguments. | 17470 // Canonicalize the type arguments. |
| 17471 TypeArguments& type_args = TypeArguments::Handle(zone, arguments()); | 17471 TypeArguments& type_args = TypeArguments::Handle(zone, arguments()); |
| 17472 // In case the type is first canonicalized at runtime, its type argument | 17472 // In case the type is first canonicalized at runtime, its type argument |
| 17473 // vector may be longer than necessary. This is not an issue. | 17473 // vector may be longer than necessary. This is not an issue. |
| 17474 ASSERT(type_args.IsNull() || | 17474 ASSERT(type_args.IsNull() || |
| 17475 (type_args.Length() >= cls.NumTypeArguments())); | 17475 (type_args.Length() >= cls.NumTypeArguments())); |
| (...skipping 5609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23085 return UserTag::null(); | 23085 return UserTag::null(); |
| 23086 } | 23086 } |
| 23087 | 23087 |
| 23088 | 23088 |
| 23089 const char* UserTag::ToCString() const { | 23089 const char* UserTag::ToCString() const { |
| 23090 const String& tag_label = String::Handle(label()); | 23090 const String& tag_label = String::Handle(label()); |
| 23091 return tag_label.ToCString(); | 23091 return tag_label.ToCString(); |
| 23092 } | 23092 } |
| 23093 | 23093 |
| 23094 } // namespace dart | 23094 } // namespace dart |
| OLD | NEW |