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

Unified Diff: runtime/vm/object.cc

Issue 8403005: Add support for 'Dynamic' type in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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 | « no previous file | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 861)
+++ runtime/vm/object.cc (working copy)
@@ -258,14 +258,20 @@
transition_sentinel_ = transition_sentinel.raw();
}
+ // The interface "Dynamic" is not a VM internal class. It is the type class of
+ // the "unknown type". For efficiency, we allocate it in the VM isolate.
+ // Therefore, it cannot have a heap allocated name (the name is hard coded,
+ // see GetSingletonClassIndex) and its array fields cannot be set to the empty
+ // array, but remain null.
+ cls = Class::New<Instance>();
+ cls.set_is_interface();
+ dynamic_class_ = cls.raw();
+
// Allocate the remaining VM internal classes.
cls = Class::New<UnresolvedClass>();
unresolved_class_class_ = cls.raw();
cls = Class::New<Instance>();
- dynamic_class_ = cls.raw();
-
- cls = Class::New<Instance>();
void_class_ = cls.raw();
cls = Class::New<ParameterizedType>();
@@ -557,21 +563,27 @@
type = Type::NewNonParameterizedType(cls);
object_store->set_bool_interface(type);
- // The classes 'Null', 'Dynamic', and 'void' are not registered in the class
- // dictionary and are not named, but corresponding types are stored in the
- // object store.
+ // 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 corresponding types are stored in the object store.
cls = null_class_;
type = Type::NewNonParameterizedType(cls);
object_store->set_null_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);
+ core_lib.AddClass(cls);
- cls = void_class_;
- type = Type::NewNonParameterizedType(cls);
- object_store->set_void_type(type);
-
// Finish the initialization by compiling the bootstrap script containing the
// implementation of the internal classes.
Bootstrap::Compile(Library::Handle(Library::CoreLibrary()), script);
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698