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/cpu.h" | 11 #include "vm/cpu.h" |
11 #include "vm/bit_vector.h" | 12 #include "vm/bit_vector.h" |
12 #include "vm/bootstrap.h" | 13 #include "vm/bootstrap.h" |
13 #include "vm/class_finalizer.h" | 14 #include "vm/class_finalizer.h" |
14 #include "vm/code_observers.h" | 15 #include "vm/code_observers.h" |
15 #include "vm/compiler.h" | 16 #include "vm/compiler.h" |
16 #include "vm/compiler_stats.h" | 17 #include "vm/compiler_stats.h" |
17 #include "vm/dart.h" | 18 #include "vm/dart.h" |
18 #include "vm/dart_api_state.h" | 19 #include "vm/dart_api_state.h" |
19 #include "vm/dart_entry.h" | 20 #include "vm/dart_entry.h" |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 cls.set_num_own_type_arguments(0); | 556 cls.set_num_own_type_arguments(0); |
556 isolate->object_store()->set_null_class(cls); | 557 isolate->object_store()->set_null_class(cls); |
557 | 558 |
558 // Allocate and initialize the free list element class. | 559 // Allocate and initialize the free list element class. |
559 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); | 560 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); |
560 cls.set_num_type_arguments(0); | 561 cls.set_num_type_arguments(0); |
561 cls.set_num_own_type_arguments(0); | 562 cls.set_num_own_type_arguments(0); |
562 cls.set_is_finalized(); | 563 cls.set_is_finalized(); |
563 cls.set_is_type_finalized(); | 564 cls.set_is_type_finalized(); |
564 | 565 |
| 566 // Allocate and initialize the forwarding corpse class. |
| 567 cls = Class::New<ForwardingCorpse::FakeInstance>(kForwardingCorpse); |
| 568 cls.set_num_type_arguments(0); |
| 569 cls.set_num_own_type_arguments(0); |
| 570 cls.set_is_finalized(); |
| 571 cls.set_is_type_finalized(); |
| 572 |
565 // Allocate and initialize the sentinel values of Null class. | 573 // Allocate and initialize the sentinel values of Null class. |
566 { | 574 { |
567 *sentinel_ ^= | 575 *sentinel_ ^= |
568 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); | 576 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); |
569 | 577 |
570 *transition_sentinel_ ^= | 578 *transition_sentinel_ ^= |
571 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); | 579 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); |
572 } | 580 } |
573 | 581 |
574 // Allocate and initialize optimizing compiler constants. | 582 // Allocate and initialize optimizing compiler constants. |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 | 930 |
923 // An object visitor which will mark all visited objects. This is used to | 931 // An object visitor which will mark all visited objects. This is used to |
924 // premark all objects in the vm_isolate_ heap. | 932 // premark all objects in the vm_isolate_ heap. |
925 class PremarkingVisitor : public ObjectVisitor { | 933 class PremarkingVisitor : public ObjectVisitor { |
926 public: | 934 public: |
927 PremarkingVisitor() { } | 935 PremarkingVisitor() { } |
928 | 936 |
929 void VisitObject(RawObject* obj) { | 937 void VisitObject(RawObject* obj) { |
930 // Free list elements should never be marked. | 938 // Free list elements should never be marked. |
931 ASSERT(!obj->IsMarked()); | 939 ASSERT(!obj->IsMarked()); |
| 940 // No forwarding corpses in the VM isolate. |
| 941 ASSERT(!obj->IsForwardingCorpse()); |
932 if (!obj->IsFreeListElement()) { | 942 if (!obj->IsFreeListElement()) { |
933 ASSERT(obj->IsVMHeapObject()); | 943 ASSERT(obj->IsVMHeapObject()); |
934 obj->SetMarkBitUnsynchronized(); | 944 obj->SetMarkBitUnsynchronized(); |
935 } | 945 } |
936 } | 946 } |
937 }; | 947 }; |
938 | 948 |
939 | 949 |
940 #define SET_CLASS_NAME(class_name, name) \ | 950 #define SET_CLASS_NAME(class_name, name) \ |
941 cls = class_name##_class(); \ | 951 cls = class_name##_class(); \ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 SET_CLASS_NAME(unhandled_exception, UnhandledException); | 1003 SET_CLASS_NAME(unhandled_exception, UnhandledException); |
994 SET_CLASS_NAME(unwind_error, UnwindError); | 1004 SET_CLASS_NAME(unwind_error, UnwindError); |
995 | 1005 |
996 // Set up names for object array and one byte string class which are | 1006 // Set up names for object array and one byte string class which are |
997 // pre-allocated in the vm isolate also. | 1007 // pre-allocated in the vm isolate also. |
998 cls = isolate->object_store()->array_class(); | 1008 cls = isolate->object_store()->array_class(); |
999 cls.set_name(Symbols::_List()); | 1009 cls.set_name(Symbols::_List()); |
1000 cls = isolate->object_store()->one_byte_string_class(); | 1010 cls = isolate->object_store()->one_byte_string_class(); |
1001 cls.set_name(Symbols::OneByteString()); | 1011 cls.set_name(Symbols::OneByteString()); |
1002 | 1012 |
| 1013 // Set up names for the pseudo-classes for free list elements and forwarding |
| 1014 // corpses. Mainly this makes VM debugging easier. |
| 1015 cls = isolate->class_table()->At(kFreeListElement); |
| 1016 cls.set_name(Symbols::FreeListElement()); |
| 1017 cls = isolate->class_table()->At(kForwardingCorpse); |
| 1018 cls.set_name(Symbols::ForwardingCorpse()); |
| 1019 |
1003 { | 1020 { |
1004 ASSERT(isolate == Dart::vm_isolate()); | 1021 ASSERT(isolate == Dart::vm_isolate()); |
1005 WritableVMIsolateScope scope(Thread::Current()); | 1022 WritableVMIsolateScope scope(Thread::Current()); |
1006 PremarkingVisitor premarker; | 1023 PremarkingVisitor premarker; |
1007 ASSERT(isolate->heap()->UsedInWords(Heap::kNew) == 0); | 1024 ASSERT(isolate->heap()->UsedInWords(Heap::kNew) == 0); |
1008 isolate->heap()->IterateOldObjectsNoEmbedderPages(&premarker); | 1025 isolate->heap()->IterateOldObjectsNoEmbedderPages(&premarker); |
1009 // Make the VM isolate read-only again after setting all objects as marked. | 1026 // Make the VM isolate read-only again after setting all objects as marked. |
1010 } | 1027 } |
1011 } | 1028 } |
1012 | 1029 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 Thread* thread = Thread::Current(); | 1090 Thread* thread = Thread::Current(); |
1074 Isolate* isolate = thread->isolate(); | 1091 Isolate* isolate = thread->isolate(); |
1075 Class& cls = Class::Handle(thread->zone(), Class::null()); | 1092 Class& cls = Class::Handle(thread->zone(), Class::null()); |
1076 for (intptr_t cid = (kIllegalCid + 1); cid < kNumPredefinedCids; cid++) { | 1093 for (intptr_t cid = (kIllegalCid + 1); cid < kNumPredefinedCids; cid++) { |
1077 if (isolate->class_table()->HasValidClassAt(cid)) { | 1094 if (isolate->class_table()->HasValidClassAt(cid)) { |
1078 cls ^= isolate->class_table()->At(cid); | 1095 cls ^= isolate->class_table()->At(cid); |
1079 ASSERT(builtin_vtables_[cid] == cls.raw_ptr()->handle_vtable_); | 1096 ASSERT(builtin_vtables_[cid] == cls.raw_ptr()->handle_vtable_); |
1080 } | 1097 } |
1081 } | 1098 } |
1082 ASSERT(builtin_vtables_[kFreeListElement] == 0); | 1099 ASSERT(builtin_vtables_[kFreeListElement] == 0); |
| 1100 ASSERT(builtin_vtables_[kForwardingCorpse] == 0); |
1083 #endif | 1101 #endif |
1084 } | 1102 } |
1085 | 1103 |
1086 | 1104 |
1087 void Object::RegisterClass(const Class& cls, | 1105 void Object::RegisterClass(const Class& cls, |
1088 const String& name, | 1106 const String& name, |
1089 const Library& lib) { | 1107 const Library& lib) { |
1090 ASSERT(name.Length() > 0); | 1108 ASSERT(name.Length() > 0); |
1091 ASSERT(name.CharAt(0) != '_'); | 1109 ASSERT(name.CharAt(0) != '_'); |
1092 cls.set_name(name); | 1110 cls.set_name(name); |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 // Old original doesn't need to be remembered, so neither does the clone. | 1927 // Old original doesn't need to be remembered, so neither does the clone. |
1910 return raw_clone; | 1928 return raw_clone; |
1911 } | 1929 } |
1912 StoreBufferUpdateVisitor visitor(Thread::Current(), raw_clone); | 1930 StoreBufferUpdateVisitor visitor(Thread::Current(), raw_clone); |
1913 raw_clone->VisitPointers(&visitor); | 1931 raw_clone->VisitPointers(&visitor); |
1914 return raw_clone; | 1932 return raw_clone; |
1915 } | 1933 } |
1916 | 1934 |
1917 | 1935 |
1918 RawString* Class::Name() const { | 1936 RawString* Class::Name() const { |
1919 // TODO(turnidge): This assert fails for the fake kFreeListElement class. | |
1920 // Fix this. | |
1921 ASSERT(raw_ptr()->name_ != String::null()); | 1937 ASSERT(raw_ptr()->name_ != String::null()); |
1922 return raw_ptr()->name_; | 1938 return raw_ptr()->name_; |
1923 } | 1939 } |
1924 | 1940 |
1925 | 1941 |
1926 RawString* Class::ScrubbedName() const { | 1942 RawString* Class::ScrubbedName() const { |
1927 return String::ScrubName(String::Handle(Name())); | 1943 return String::ScrubName(String::Handle(Name())); |
1928 } | 1944 } |
1929 | 1945 |
1930 | 1946 |
(...skipping 20680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22611 return UserTag::null(); | 22627 return UserTag::null(); |
22612 } | 22628 } |
22613 | 22629 |
22614 | 22630 |
22615 const char* UserTag::ToCString() const { | 22631 const char* UserTag::ToCString() const { |
22616 const String& tag_label = String::Handle(label()); | 22632 const String& tag_label = String::Handle(label()); |
22617 return tag_label.ToCString(); | 22633 return tag_label.ToCString(); |
22618 } | 22634 } |
22619 | 22635 |
22620 } // namespace dart | 22636 } // namespace dart |
OLD | NEW |