Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: runtime/vm/object.cc

Issue 22638011: Move Null class out of the VM isolate. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 Instance* Object::transition_sentinel_ = NULL; 84 Instance* Object::transition_sentinel_ = NULL;
85 Instance* Object::unknown_constant_ = NULL; 85 Instance* Object::unknown_constant_ = NULL;
86 Instance* Object::non_constant_ = NULL; 86 Instance* Object::non_constant_ = NULL;
87 Bool* Object::bool_true_ = NULL; 87 Bool* Object::bool_true_ = NULL;
88 Bool* Object::bool_false_ = NULL; 88 Bool* Object::bool_false_ = NULL;
89 Smi* Object::smi_illegal_cid_ = NULL; 89 Smi* Object::smi_illegal_cid_ = NULL;
90 LanguageError* Object::snapshot_writer_error_ = NULL; 90 LanguageError* Object::snapshot_writer_error_ = NULL;
91 91
92 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL); 92 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL);
93 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 93 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
94 RawClass* Object::null_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
95 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 94 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
96 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 95 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
97 RawClass* Object::unresolved_class_class_ = 96 RawClass* Object::unresolved_class_class_ =
98 reinterpret_cast<RawClass*>(RAW_NULL); 97 reinterpret_cast<RawClass*>(RAW_NULL);
99 RawClass* Object::type_arguments_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 98 RawClass* Object::type_arguments_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
100 RawClass* Object::instantiated_type_arguments_class_ = 99 RawClass* Object::instantiated_type_arguments_class_ =
101 reinterpret_cast<RawClass*>(RAW_NULL); 100 reinterpret_cast<RawClass*>(RAW_NULL);
102 RawClass* Object::patch_class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 101 RawClass* Object::patch_class_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
103 RawClass* Object::function_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 102 RawClass* Object::function_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
104 RawClass* Object::closure_data_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 103 RawClass* Object::closure_data_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 Class::kNoTypeArguments; 405 Class::kNoTypeArguments;
407 cls.raw_ptr()->num_native_fields_ = 0; 406 cls.raw_ptr()->num_native_fields_ = 0;
408 cls.InitEmptyFields(); 407 cls.InitEmptyFields();
409 isolate->RegisterClass(cls); 408 isolate->RegisterClass(cls);
410 } 409 }
411 410
412 // Allocate and initialize the null class. 411 // Allocate and initialize the null class.
413 cls = Class::New<Instance>(kNullCid); 412 cls = Class::New<Instance>(kNullCid);
414 cls.set_is_finalized(); 413 cls.set_is_finalized();
415 cls.set_is_type_finalized(); 414 cls.set_is_type_finalized();
416 null_class_ = cls.raw(); 415 isolate->object_store()->set_null_class(cls);
417 416
418 // Allocate and initialize the free list element class. 417 // Allocate and initialize the free list element class.
419 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); 418 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement);
420 cls.set_is_finalized(); 419 cls.set_is_finalized();
421 cls.set_is_type_finalized(); 420 cls.set_is_type_finalized();
422 421
423 // Allocate and initialize the sentinel values of Null class. 422 // Allocate and initialize the sentinel values of Null class.
rmacnak 2013/08/09 17:45:44 There are actually five instances of Null >:/
424 { 423 {
425 *sentinel_ ^= 424 *sentinel_ ^=
426 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); 425 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
427 426
428 *transition_sentinel_ ^= 427 *transition_sentinel_ ^=
429 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); 428 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
430 } 429 }
431 430
432 // Allocate and initialize optimizing compiler constants. 431 // Allocate and initialize optimizing compiler constants.
433 { 432 {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 604
606 #define SET_CLASS_NAME(class_name, name) \ 605 #define SET_CLASS_NAME(class_name, name) \
607 cls = class_name##_class(); \ 606 cls = class_name##_class(); \
608 cls.set_name(Symbols::name()); \ 607 cls.set_name(Symbols::name()); \
609 608
610 void Object::RegisterSingletonClassNames() { 609 void Object::RegisterSingletonClassNames() {
611 Class& cls = Class::Handle(); 610 Class& cls = Class::Handle();
612 611
613 // Set up names for all VM singleton classes. 612 // Set up names for all VM singleton classes.
614 SET_CLASS_NAME(class, Class); 613 SET_CLASS_NAME(class, Class);
615 SET_CLASS_NAME(null, Null);
616 SET_CLASS_NAME(dynamic, Dynamic); 614 SET_CLASS_NAME(dynamic, Dynamic);
617 SET_CLASS_NAME(void, Void); 615 SET_CLASS_NAME(void, Void);
618 SET_CLASS_NAME(unresolved_class, UnresolvedClass); 616 SET_CLASS_NAME(unresolved_class, UnresolvedClass);
619 SET_CLASS_NAME(type_arguments, TypeArguments); 617 SET_CLASS_NAME(type_arguments, TypeArguments);
620 SET_CLASS_NAME(instantiated_type_arguments, InstantiatedTypeArguments); 618 SET_CLASS_NAME(instantiated_type_arguments, InstantiatedTypeArguments);
621 SET_CLASS_NAME(patch_class, PatchClass); 619 SET_CLASS_NAME(patch_class, PatchClass);
622 SET_CLASS_NAME(function, Function); 620 SET_CLASS_NAME(function, Function);
623 SET_CLASS_NAME(closure_data, ClosureData); 621 SET_CLASS_NAME(closure_data, ClosureData);
624 SET_CLASS_NAME(redirection_data, RedirectionData); 622 SET_CLASS_NAME(redirection_data, RedirectionData);
625 SET_CLASS_NAME(field, Field); 623 SET_CLASS_NAME(field, Field);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 824
827 // Now that the symbol table is initialized and that the core dictionary as 825 // Now that the symbol table is initialized and that the core dictionary as
828 // well as the core implementation dictionary have been setup, preallocate 826 // well as the core implementation dictionary have been setup, preallocate
829 // remaining classes and register them by name in the dictionaries. 827 // remaining classes and register them by name in the dictionaries.
830 String& name = String::Handle(); 828 String& name = String::Handle();
831 cls = Class::New<Bool>(); 829 cls = Class::New<Bool>();
832 object_store->set_bool_class(cls); 830 object_store->set_bool_class(cls);
833 RegisterClass(cls, Symbols::Bool(), core_lib); 831 RegisterClass(cls, Symbols::Bool(), core_lib);
834 pending_classes.Add(cls, Heap::kOld); 832 pending_classes.Add(cls, Heap::kOld);
835 833
834 cls = Class::New<Instance>(kNullCid);
835 cls.set_name(Symbols::Null());
836 // We immediately mark Null as finalized because it has no corresponding
837 // source.
838 cls.set_is_finalized();
839 cls.set_is_type_finalized();
840 object_store->set_null_class(cls);
841 cls.set_library(core_lib); // A sort of fiction for the mirrors.
842 // When/if we promote Null to an ordinary class, it should be added to the
843 // core library, given source and added to the list of classes pending
844 // finalization.
845 // RegisterClass(cls, Symbols::Null(), core_lib);
846 // pending_classes.Add(cls, Heap::kOld);
847
836 cls = object_store->array_class(); // Was allocated above. 848 cls = object_store->array_class(); // Was allocated above.
837 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib); 849 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib);
838 pending_classes.Add(cls, Heap::kOld); 850 pending_classes.Add(cls, Heap::kOld);
839 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. 851 // We cannot use NewNonParameterizedType(cls), because Array is parameterized.
840 type ^= Type::New(Object::Handle(cls.raw()), 852 type ^= Type::New(Object::Handle(cls.raw()),
841 TypeArguments::Handle(), 853 TypeArguments::Handle(),
842 Scanner::kDummyTokenIndex); 854 Scanner::kDummyTokenIndex);
843 type.SetIsFinalized(); 855 type.SetIsFinalized();
844 type ^= type.Canonicalize(); 856 type ^= type.Canonicalize();
845 object_store->set_array_type(type); 857 object_store->set_array_type(type);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 object_store->set_bool_type(type); 1096 object_store->set_bool_type(type);
1085 1097
1086 cls = object_store->smi_class(); 1098 cls = object_store->smi_class();
1087 type = Type::NewNonParameterizedType(cls); 1099 type = Type::NewNonParameterizedType(cls);
1088 object_store->set_smi_type(type); 1100 object_store->set_smi_type(type);
1089 1101
1090 cls = object_store->mint_class(); 1102 cls = object_store->mint_class();
1091 type = Type::NewNonParameterizedType(cls); 1103 type = Type::NewNonParameterizedType(cls);
1092 object_store->set_mint_type(type); 1104 object_store->set_mint_type(type);
1093 1105
1094 // The classes 'Null' and 'void' are not registered in the class dictionary, 1106 // The classes 'Null' and 'void' are not registered in the class dictionary,
rmacnak 2013/08/09 17:45:44 Null is not a reserved word; it just isn't exporte
1095 // because their names are reserved keywords. Their names are not heap 1107 // because their names are reserved keywords. Their names are not heap
1096 // allocated, because the classes reside in the VM isolate. 1108 // allocated, because the classes reside in the VM isolate.
rmacnak 2013/08/09 17:45:44 Not sure why this would prevent heap allocation. I
Ivan Posva 2013/08/09 21:15:12 It looks like this comment is out-of-date. The nam
1097 // The corresponding types are stored in the object store. 1109 // The corresponding types are stored in the object store.
1098 cls = null_class(); 1110 cls = object_store->null_class();
1099 type = Type::NewNonParameterizedType(cls); 1111 type = Type::NewNonParameterizedType(cls);
1100 object_store->set_null_type(type); 1112 object_store->set_null_type(type);
1101 1113
1114 // Consider removing when/if Null becomes an ordinary class.
1115 type = object_store->object_type();
1116 cls.set_super_type(type);
1117
1102 cls = void_class(); 1118 cls = void_class();
1103 type = Type::NewNonParameterizedType(cls); 1119 type = Type::NewNonParameterizedType(cls);
1104 object_store->set_void_type(type); 1120 object_store->set_void_type(type);
1105 1121
1106 // The class 'dynamic' is registered in the class dictionary because its name 1122 // The class 'dynamic' is registered in the class dictionary because its name
1107 // is a built-in identifier, rather than a reserved keyword. Its name is not 1123 // is a built-in identifier, rather than a reserved keyword. Its name is not
1108 // heap allocated, because the class resides in the VM isolate. 1124 // heap allocated, because the class resides in the VM isolate.
1109 // The corresponding type, the "unknown type", is stored in the object store. 1125 // The corresponding type, the "unknown type", is stored in the object store.
1110 cls = dynamic_class(); 1126 cls = dynamic_class();
1111 type = Type::NewNonParameterizedType(cls); 1127 type = Type::NewNonParameterizedType(cls);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 1220
1205 cls = Class::NewStringClass(kExternalOneByteStringCid); 1221 cls = Class::NewStringClass(kExternalOneByteStringCid);
1206 object_store->set_external_one_byte_string_class(cls); 1222 object_store->set_external_one_byte_string_class(cls);
1207 1223
1208 cls = Class::NewStringClass(kExternalTwoByteStringCid); 1224 cls = Class::NewStringClass(kExternalTwoByteStringCid);
1209 object_store->set_external_two_byte_string_class(cls); 1225 object_store->set_external_two_byte_string_class(cls);
1210 1226
1211 cls = Class::New<Bool>(); 1227 cls = Class::New<Bool>();
1212 object_store->set_bool_class(cls); 1228 object_store->set_bool_class(cls);
1213 1229
1230 cls = Class::New<Instance>(kNullCid);
1231 object_store->set_null_class(cls);
1232
1214 cls = Class::New<Stacktrace>(); 1233 cls = Class::New<Stacktrace>();
1215 object_store->set_stacktrace_class(cls); 1234 object_store->set_stacktrace_class(cls);
1216 1235
1217 cls = Class::New<JSRegExp>(); 1236 cls = Class::New<JSRegExp>();
1218 object_store->set_jsregexp_class(cls); 1237 object_store->set_jsregexp_class(cls);
1219 1238
1220 // Some classes are not stored in the object store. Yet we still need to 1239 // Some classes are not stored in the object store. Yet we still need to
1221 // create their Class object so that they get put into the class_table 1240 // create their Class object so that they get put into the class_table
1222 // (as a side effect of Class::New()). 1241 // (as a side effect of Class::New()).
1223 cls = Class::New<DartFunction>(); 1242 cls = Class::New<DartFunction>();
(...skipping 9203 matching lines...) Expand 10 before | Expand all | Expand 10 after
10427 10446
10428 RawString* AbstractType::ClassName() const { 10447 RawString* AbstractType::ClassName() const {
10429 if (HasResolvedTypeClass()) { 10448 if (HasResolvedTypeClass()) {
10430 return Class::Handle(type_class()).Name(); 10449 return Class::Handle(type_class()).Name();
10431 } else { 10450 } else {
10432 return UnresolvedClass::Handle(unresolved_class()).Name(); 10451 return UnresolvedClass::Handle(unresolved_class()).Name();
10433 } 10452 }
10434 } 10453 }
10435 10454
10436 10455
10456 bool AbstractType::IsNullType() const {
10457 return HasResolvedTypeClass() &&
rmacnak 2013/08/09 17:45:44 This mimics Bool, but perhaps type_class().IsNullC
10458 (type_class() == Type::Handle(Type::NullType()).type_class());
10459 }
10460
10461
10437 bool AbstractType::IsBoolType() const { 10462 bool AbstractType::IsBoolType() const {
10438 return HasResolvedTypeClass() && 10463 return HasResolvedTypeClass() &&
10439 (type_class() == Type::Handle(Type::BoolType()).type_class()); 10464 (type_class() == Type::Handle(Type::BoolType()).type_class());
10440 } 10465 }
10441 10466
10442 10467
10443 bool AbstractType::IsIntType() const { 10468 bool AbstractType::IsIntType() const {
10444 return HasResolvedTypeClass() && 10469 return HasResolvedTypeClass() &&
10445 (type_class() == Type::Handle(Type::IntType()).type_class()); 10470 (type_class() == Type::Handle(Type::IntType()).type_class());
10446 } 10471 }
(...skipping 4130 matching lines...) Expand 10 before | Expand all | Expand 10 after
14577 } 14602 }
14578 14603
14579 14604
14580 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 14605 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
14581 stream->OpenObject(); 14606 stream->OpenObject();
14582 stream->CloseObject(); 14607 stream->CloseObject();
14583 } 14608 }
14584 14609
14585 14610
14586 } // namespace dart 14611 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698