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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 // Directly set raw_ to break a circular dependency: SetRaw will attempt | 538 // Directly set raw_ to break a circular dependency: SetRaw will attempt |
539 // to lookup class class in the class table where it is not registered yet. | 539 // to lookup class class in the class table where it is not registered yet. |
540 cls.raw_ = class_class_; | 540 cls.raw_ = class_class_; |
541 cls.set_handle_vtable(fake.vtable()); | 541 cls.set_handle_vtable(fake.vtable()); |
542 cls.set_instance_size(Class::InstanceSize()); | 542 cls.set_instance_size(Class::InstanceSize()); |
543 cls.set_next_field_offset(Class::NextFieldOffset()); | 543 cls.set_next_field_offset(Class::NextFieldOffset()); |
544 cls.set_id(Class::kClassId); | 544 cls.set_id(Class::kClassId); |
545 cls.set_state_bits(0); | 545 cls.set_state_bits(0); |
546 cls.set_is_finalized(); | 546 cls.set_is_finalized(); |
547 cls.set_is_type_finalized(); | 547 cls.set_is_type_finalized(); |
| 548 cls.set_is_cycle_free(); |
548 cls.set_type_arguments_field_offset_in_words(Class::kNoTypeArguments); | 549 cls.set_type_arguments_field_offset_in_words(Class::kNoTypeArguments); |
549 cls.set_num_type_arguments(0); | 550 cls.set_num_type_arguments(0); |
550 cls.set_num_own_type_arguments(0); | 551 cls.set_num_own_type_arguments(0); |
551 cls.set_num_native_fields(0); | 552 cls.set_num_native_fields(0); |
552 cls.InitEmptyFields(); | 553 cls.InitEmptyFields(); |
553 isolate->RegisterClass(cls); | 554 isolate->RegisterClass(cls); |
554 } | 555 } |
555 | 556 |
556 // Allocate and initialize the null class. | 557 // Allocate and initialize the null class. |
557 cls = Class::New<Instance>(kNullCid); | 558 cls = Class::New<Instance>(kNullCid); |
558 cls.set_num_type_arguments(0); | 559 cls.set_num_type_arguments(0); |
559 cls.set_num_own_type_arguments(0); | 560 cls.set_num_own_type_arguments(0); |
560 isolate->object_store()->set_null_class(cls); | 561 isolate->object_store()->set_null_class(cls); |
561 | 562 |
562 // Allocate and initialize the free list element class. | 563 // Allocate and initialize the free list element class. |
563 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); | 564 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); |
564 cls.set_num_type_arguments(0); | 565 cls.set_num_type_arguments(0); |
565 cls.set_num_own_type_arguments(0); | 566 cls.set_num_own_type_arguments(0); |
566 cls.set_is_finalized(); | 567 cls.set_is_finalized(); |
567 cls.set_is_type_finalized(); | 568 cls.set_is_type_finalized(); |
| 569 cls.set_is_cycle_free(); |
568 | 570 |
569 // Allocate and initialize the forwarding corpse class. | 571 // Allocate and initialize the forwarding corpse class. |
570 cls = Class::New<ForwardingCorpse::FakeInstance>(kForwardingCorpse); | 572 cls = Class::New<ForwardingCorpse::FakeInstance>(kForwardingCorpse); |
571 cls.set_num_type_arguments(0); | 573 cls.set_num_type_arguments(0); |
572 cls.set_num_own_type_arguments(0); | 574 cls.set_num_own_type_arguments(0); |
573 cls.set_is_finalized(); | 575 cls.set_is_finalized(); |
574 cls.set_is_type_finalized(); | 576 cls.set_is_type_finalized(); |
| 577 cls.set_is_cycle_free(); |
575 | 578 |
576 // Allocate and initialize the sentinel values of Null class. | 579 // Allocate and initialize the sentinel values of Null class. |
577 { | 580 { |
578 *sentinel_ ^= | 581 *sentinel_ ^= |
579 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); | 582 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); |
580 | 583 |
581 *transition_sentinel_ ^= | 584 *transition_sentinel_ ^= |
582 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); | 585 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); |
583 } | 586 } |
584 | 587 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 } | 820 } |
818 | 821 |
819 // The VM isolate snapshot object table is initialized to an empty array | 822 // The VM isolate snapshot object table is initialized to an empty array |
820 // as we do not have any VM isolate snapshot at this time. | 823 // as we do not have any VM isolate snapshot at this time. |
821 *vm_isolate_snapshot_object_table_ = Object::empty_array().raw(); | 824 *vm_isolate_snapshot_object_table_ = Object::empty_array().raw(); |
822 | 825 |
823 cls = Class::New<Instance>(kDynamicCid); | 826 cls = Class::New<Instance>(kDynamicCid); |
824 cls.set_is_abstract(); | 827 cls.set_is_abstract(); |
825 cls.set_num_type_arguments(0); | 828 cls.set_num_type_arguments(0); |
826 cls.set_num_own_type_arguments(0); | 829 cls.set_num_own_type_arguments(0); |
| 830 cls.set_is_finalized(); |
827 cls.set_is_type_finalized(); | 831 cls.set_is_type_finalized(); |
828 cls.set_is_finalized(); | 832 cls.set_is_cycle_free(); |
829 dynamic_class_ = cls.raw(); | 833 dynamic_class_ = cls.raw(); |
830 | 834 |
831 cls = Class::New<Instance>(kVoidCid); | 835 cls = Class::New<Instance>(kVoidCid); |
832 cls.set_num_type_arguments(0); | 836 cls.set_num_type_arguments(0); |
833 cls.set_num_own_type_arguments(0); | 837 cls.set_num_own_type_arguments(0); |
| 838 cls.set_is_finalized(); |
834 cls.set_is_type_finalized(); | 839 cls.set_is_type_finalized(); |
835 cls.set_is_finalized(); | 840 cls.set_is_cycle_free(); |
836 void_class_ = cls.raw(); | 841 void_class_ = cls.raw(); |
837 | 842 |
838 cls = Class::New<Type>(); | 843 cls = Class::New<Type>(); |
| 844 cls.set_is_finalized(); |
839 cls.set_is_type_finalized(); | 845 cls.set_is_type_finalized(); |
840 cls.set_is_finalized(); | 846 cls.set_is_cycle_free(); |
841 | 847 |
842 cls = dynamic_class_; | 848 cls = dynamic_class_; |
843 *dynamic_type_ = Type::NewNonParameterizedType(cls); | 849 *dynamic_type_ = Type::NewNonParameterizedType(cls); |
844 | 850 |
845 cls = void_class_; | 851 cls = void_class_; |
846 *void_type_ = Type::NewNonParameterizedType(cls); | 852 *void_type_ = Type::NewNonParameterizedType(cls); |
847 | 853 |
848 // Allocate and initialize singleton true and false boolean objects. | 854 // Allocate and initialize singleton true and false boolean objects. |
849 cls = Class::New<Bool>(); | 855 cls = Class::New<Bool>(); |
850 isolate->object_store()->set_bool_class(cls); | 856 isolate->object_store()->set_bool_class(cls); |
(...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3180 cls.set_super_type(Type::Handle(Type::ObjectType())); | 3186 cls.set_super_type(Type::Handle(Type::ObjectType())); |
3181 // Compute instance size. First word contains a pointer to a properly | 3187 // Compute instance size. First word contains a pointer to a properly |
3182 // sized typed array once the first native field has been set. | 3188 // sized typed array once the first native field has been set. |
3183 intptr_t instance_size = sizeof(RawInstance) + kWordSize; | 3189 intptr_t instance_size = sizeof(RawInstance) + kWordSize; |
3184 cls.set_instance_size(RoundedAllocationSize(instance_size)); | 3190 cls.set_instance_size(RoundedAllocationSize(instance_size)); |
3185 cls.set_next_field_offset(instance_size); | 3191 cls.set_next_field_offset(instance_size); |
3186 cls.set_num_native_fields(field_count); | 3192 cls.set_num_native_fields(field_count); |
3187 cls.set_is_finalized(); | 3193 cls.set_is_finalized(); |
3188 cls.set_is_type_finalized(); | 3194 cls.set_is_type_finalized(); |
3189 cls.set_is_synthesized_class(); | 3195 cls.set_is_synthesized_class(); |
| 3196 cls.set_is_cycle_free(); |
3190 library.AddClass(cls); | 3197 library.AddClass(cls); |
3191 return cls.raw(); | 3198 return cls.raw(); |
3192 } else { | 3199 } else { |
3193 return Class::null(); | 3200 return Class::null(); |
3194 } | 3201 } |
3195 } | 3202 } |
3196 | 3203 |
3197 | 3204 |
3198 RawClass* Class::NewStringClass(intptr_t class_id) { | 3205 RawClass* Class::NewStringClass(intptr_t class_id) { |
3199 intptr_t instance_size; | 3206 intptr_t instance_size; |
(...skipping 19564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22764 return UserTag::null(); | 22771 return UserTag::null(); |
22765 } | 22772 } |
22766 | 22773 |
22767 | 22774 |
22768 const char* UserTag::ToCString() const { | 22775 const char* UserTag::ToCString() const { |
22769 const String& tag_label = String::Handle(label()); | 22776 const String& tag_label = String::Handle(label()); |
22770 return tag_label.ToCString(); | 22777 return tag_label.ToCString(); |
22771 } | 22778 } |
22772 | 22779 |
22773 } // namespace dart | 22780 } // namespace dart |
OLD | NEW |