| 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/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 15588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15599 // Fast canonical lookup/registry for simple types. | 15599 // Fast canonical lookup/registry for simple types. |
| 15600 if ((cls.NumTypeArguments() == 0) && !cls.IsSignatureClass()) { | 15600 if ((cls.NumTypeArguments() == 0) && !cls.IsSignatureClass()) { |
| 15601 type = cls.CanonicalType(); | 15601 type = cls.CanonicalType(); |
| 15602 if (type.IsNull()) { | 15602 if (type.IsNull()) { |
| 15603 ASSERT(!cls.raw()->IsVMHeapObject() || (isolate == Dart::vm_isolate())); | 15603 ASSERT(!cls.raw()->IsVMHeapObject() || (isolate == Dart::vm_isolate())); |
| 15604 cls.set_canonical_types(*this); | 15604 cls.set_canonical_types(*this); |
| 15605 SetCanonical(); | 15605 SetCanonical(); |
| 15606 return this->raw(); | 15606 return this->raw(); |
| 15607 } | 15607 } |
| 15608 ASSERT(this->Equals(type)); | 15608 ASSERT(this->Equals(type)); |
| 15609 ASSERT(type.IsCanonical()); |
| 15609 return type.raw(); | 15610 return type.raw(); |
| 15610 } | 15611 } |
| 15611 | 15612 |
| 15612 Array& canonical_types = Array::Handle(isolate); | 15613 Array& canonical_types = Array::Handle(isolate); |
| 15613 canonical_types ^= cls.canonical_types(); | 15614 canonical_types ^= cls.canonical_types(); |
| 15614 if (canonical_types.IsNull()) { | 15615 if (canonical_types.IsNull()) { |
| 15615 canonical_types = empty_array().raw(); | 15616 canonical_types = empty_array().raw(); |
| 15616 } | 15617 } |
| 15617 intptr_t length = canonical_types.Length(); | 15618 intptr_t length = canonical_types.Length(); |
| 15618 // Linear search to see whether this type is already present in the | 15619 // Linear search to see whether this type is already present in the |
| 15619 // list of canonicalized types. | 15620 // list of canonicalized types. |
| 15620 // TODO(asiva): Try to re-factor this lookup code to make sharing | 15621 // TODO(asiva): Try to re-factor this lookup code to make sharing |
| 15621 // easy between the 4 versions of this loop. | 15622 // easy between the 4 versions of this loop. |
| 15622 intptr_t index = 0; | 15623 intptr_t index = 0; |
| 15623 while (index < length) { | 15624 while (index < length) { |
| 15624 type ^= canonical_types.At(index); | 15625 type ^= canonical_types.At(index); |
| 15625 if (type.IsNull()) { | 15626 if (type.IsNull()) { |
| 15626 break; | 15627 break; |
| 15627 } | 15628 } |
| 15628 ASSERT(type.IsFinalized()); | 15629 ASSERT(type.IsFinalized()); |
| 15629 if (this->Equals(type)) { | 15630 if (this->Equals(type)) { |
| 15631 ASSERT(type.IsCanonical()); |
| 15630 return type.raw(); | 15632 return type.raw(); |
| 15631 } | 15633 } |
| 15632 index++; | 15634 index++; |
| 15633 } | 15635 } |
| 15634 // The type was not found in the table. It is not canonical yet. | 15636 // The type was not found in the table. It is not canonical yet. |
| 15635 | 15637 |
| 15636 // Canonicalize the type arguments. | 15638 // Canonicalize the type arguments. |
| 15637 TypeArguments& type_args = TypeArguments::Handle(isolate, arguments()); | 15639 TypeArguments& type_args = TypeArguments::Handle(isolate, arguments()); |
| 15638 // In case the type is first canonicalized at runtime, its type argument | 15640 // In case the type is first canonicalized at runtime, its type argument |
| 15639 // vector may be longer than necessary. This is not an issue. | 15641 // vector may be longer than necessary. This is not an issue. |
| 15640 ASSERT(type_args.IsNull() || (type_args.Length() >= cls.NumTypeArguments())); | 15642 ASSERT(type_args.IsNull() || (type_args.Length() >= cls.NumTypeArguments())); |
| 15641 type_args = type_args.Canonicalize(trail); | 15643 type_args = type_args.Canonicalize(trail); |
| 15642 set_arguments(type_args); | 15644 set_arguments(type_args); |
| 15643 | 15645 |
| 15644 // Canonicalizing the type arguments may have changed the index, may have | 15646 // Canonicalizing the type arguments may have changed the index, may have |
| 15645 // grown the table, or may even have canonicalized this type. | 15647 // grown the table, or may even have canonicalized this type. |
| 15646 canonical_types ^= cls.canonical_types(); | 15648 canonical_types ^= cls.canonical_types(); |
| 15647 if (canonical_types.IsNull()) { | 15649 if (canonical_types.IsNull()) { |
| 15648 canonical_types = empty_array().raw(); | 15650 canonical_types = empty_array().raw(); |
| 15649 } | 15651 } |
| 15650 length = canonical_types.Length(); | 15652 length = canonical_types.Length(); |
| 15651 while (index < length) { | 15653 while (index < length) { |
| 15652 type ^= canonical_types.At(index); | 15654 type ^= canonical_types.At(index); |
| 15653 if (type.IsNull()) { | 15655 if (type.IsNull()) { |
| 15654 break; | 15656 break; |
| 15655 } | 15657 } |
| 15656 ASSERT(type.IsFinalized()); | 15658 ASSERT(type.IsFinalized()); |
| 15657 if (this->Equals(type)) { | 15659 if (this->Equals(type)) { |
| 15660 ASSERT(type.IsCanonical()); |
| 15658 return type.raw(); | 15661 return type.raw(); |
| 15659 } | 15662 } |
| 15660 index++; | 15663 index++; |
| 15661 } | 15664 } |
| 15662 | 15665 |
| 15663 // The type needs to be added to the list. Grow the list if it is full. | 15666 // The type needs to be added to the list. Grow the list if it is full. |
| 15664 if (index == length) { | 15667 if (index == length) { |
| 15665 const intptr_t new_length = (length > 64) ? | 15668 const intptr_t new_length = (length > 64) ? |
| 15666 (length + 64) : | 15669 (length + 64) : |
| 15667 ((length == 0) ? 1 : (length * 2)); | 15670 ((length == 0) ? 1 : (length * 2)); |
| (...skipping 5695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21363 return tag_label.ToCString(); | 21366 return tag_label.ToCString(); |
| 21364 } | 21367 } |
| 21365 | 21368 |
| 21366 | 21369 |
| 21367 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21370 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 21368 Instance::PrintJSONImpl(stream, ref); | 21371 Instance::PrintJSONImpl(stream, ref); |
| 21369 } | 21372 } |
| 21370 | 21373 |
| 21371 | 21374 |
| 21372 } // namespace dart | 21375 } // namespace dart |
| OLD | NEW |