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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 9bfb6695089d1aca6709ebfaa64f3489ae1859e1..a6d736467d40e9e35e871ef894f485016f7d9485 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -92,7 +92,6 @@ LanguageError* Object::branch_offset_error_ = NULL;
RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL);
RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
-RawClass* Object::null_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
RawClass* Object::unresolved_class_class_ =
@@ -416,7 +415,7 @@ void Object::InitOnce() {
cls = Class::New<Instance>(kNullCid);
cls.set_is_finalized();
cls.set_is_type_finalized();
- null_class_ = cls.raw();
+ isolate->object_store()->set_null_class(cls);
// Allocate and initialize the free list element class.
cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement);
@@ -621,7 +620,6 @@ void Object::RegisterSingletonClassNames() {
// Set up names for all VM singleton classes.
SET_CLASS_NAME(class, Class);
- SET_CLASS_NAME(null, Null);
SET_CLASS_NAME(dynamic, Dynamic);
SET_CLASS_NAME(void, Void);
SET_CLASS_NAME(unresolved_class, UnresolvedClass);
@@ -842,6 +840,20 @@ RawError* Object::Init(Isolate* isolate) {
RegisterClass(cls, Symbols::Bool(), core_lib);
pending_classes.Add(cls, Heap::kOld);
+ cls = Class::New<Instance>(kNullCid);
+ cls.set_name(Symbols::Null());
+ // We immediately mark Null as finalized because it has no corresponding
+ // source.
+ cls.set_is_finalized();
+ cls.set_is_type_finalized();
+ object_store->set_null_class(cls);
+ cls.set_library(core_lib); // A sort of fiction for the mirrors.
+ // When/if we promote Null to an ordinary class, it should be added to the
+ // core library, given source and added to the list of classes pending
+ // finalization.
+ // RegisterClass(cls, Symbols::Null(), core_lib);
+ // pending_classes.Add(cls, Heap::kOld);
+
cls = object_store->array_class(); // Was allocated above.
RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib);
pending_classes.Add(cls, Heap::kOld);
@@ -1100,22 +1112,25 @@ RawError* Object::Init(Isolate* isolate) {
type = Type::NewNonParameterizedType(cls);
object_store->set_mint_type(type);
- // The classes 'Null' and 'void' are not registered in the class dictionary,
- // because their names are reserved keywords. Their names are not heap
- // allocated, because the classes reside in the VM isolate.
+ // The class 'Null' is not register in the class dictionary because it is not
siva 2013/08/10 00:43:34 registered, the comment also doesn't seem correct.
+ // The classes 'void' and 'dynamic' are phoney classes to make type checking
+ // more regular; they live in the VM isolate. The class 'void' is not
+ // registered in the class dictionary because its name is a reserved word.
+ // The class 'dynamic' is registered in the class dictionary because its name
+ // is a built-in identifier (this is wrong).
siva 2013/08/10 00:43:34 Maybe you should add an issue to track this and ad
// The corresponding types are stored in the object store.
- cls = null_class();
+ cls = object_store->null_class();
type = Type::NewNonParameterizedType(cls);
object_store->set_null_type(type);
+ // Consider removing when/if Null becomes an ordinary class.
siva 2013/08/10 00:43:34 I think this should also have an issue and a TODO
+ type = object_store->object_type();
+ cls.set_super_type(type);
+
cls = void_class();
type = Type::NewNonParameterizedType(cls);
object_store->set_void_type(type);
- // The class 'dynamic' is registered in the class dictionary because its name
- // is a built-in identifier, rather than a reserved keyword. Its name is not
- // heap allocated, because the class resides in the VM isolate.
- // The corresponding type, the "unknown type", is stored in the object store.
cls = dynamic_class();
type = Type::NewNonParameterizedType(cls);
object_store->set_dynamic_type(type);
@@ -1220,6 +1235,9 @@ void Object::InitFromSnapshot(Isolate* isolate) {
cls = Class::New<Bool>();
object_store->set_bool_class(cls);
+ cls = Class::New<Instance>(kNullCid);
+ object_store->set_null_class(cls);
+
cls = Class::New<Stacktrace>();
object_store->set_stacktrace_class(cls);
@@ -10443,6 +10461,12 @@ RawString* AbstractType::ClassName() const {
}
+bool AbstractType::IsNullType() const {
+ return HasResolvedTypeClass() &&
+ (type_class() == Type::Handle(Type::NullType()).type_class());
siva 2013/08/10 00:43:34 This has become an expensive operation now with th
+}
+
+
bool AbstractType::IsBoolType() const {
return HasResolvedTypeClass() &&
(type_class() == Type::Handle(Type::BoolType()).type_class());
« 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