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

Unified Diff: runtime/vm/object.cc

Issue 14520010: First step towards loading the core library scripts directly from the sources (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 22095)
+++ runtime/vm/object.cc (working copy)
@@ -678,30 +678,8 @@
#define LOAD_LIBRARY(name, raw_name) \
Ivan Posva 2013/04/29 04:42:32 This is now an empty macro.
siva 2013/04/29 17:35:58 Yes, removed it. On 2013/04/29 04:42:32, Ivan Pos
- url = Symbols::Dart##name().raw(); \
- lib = Library::LookupLibrary(url); \
- if (lib.IsNull()) { \
- lib = Library::NewLibraryHelper(url, true); \
- lib.Register(); \
- } \
- isolate->object_store()->set_##raw_name##_library(lib); \
-#define INIT_LIBRARY(name, raw_name, has_patch) \
- LOAD_LIBRARY(name, raw_name) \
- script = Bootstrap::Load##name##Script(false); \
- error = Bootstrap::Compile(lib, script); \
- if (!error.IsNull()) { \
- return error.raw(); \
- } \
- if (has_patch) { \
- script = Bootstrap::Load##name##Script(true); \
- error = lib.Patch(script); \
- if (!error.IsNull()) { \
- return error.raw(); \
- } \
- } \
-
RawError* Object::Init(Isolate* isolate) {
TIMERSCOPE(time_bootstrap);
ObjectStore* object_store = isolate->object_store();
@@ -709,10 +687,7 @@
Class& cls = Class::Handle();
Type& type = Type::Handle();
Array& array = Array::Handle();
- String& url = String::Handle();
Library& lib = Library::Handle();
- Script& script = Script::Handle();
- Error& error = Error::Handle();
// All RawArray fields will be initialized to an empty array, therefore
// initialize array class first.
@@ -843,13 +818,13 @@
pending_classes.Add(cls, Heap::kOld);
// Initialize the base interfaces used by the core VM classes.
- script = Bootstrap::LoadCoreScript(false);
+ const Script& core_script = Script::Handle(Bootstrap::LoadCoreScript());
// Allocate and initialize the pre-allocated classes in the core library.
cls = Class::New<Instance>(kInstanceCid);
object_store->set_object_class(cls);
cls.set_name(Symbols::Object());
- cls.set_script(script);
+ cls.set_script(core_script);
cls.set_is_prefinalized();
core_lib.AddClass(cls);
pending_classes.Add(cls, Heap::kOld);
@@ -900,7 +875,13 @@
// Pre-register the typed_data library so the native class implementations
// can be hooked up before compiling it.
- LOAD_LIBRARY(TypedData, typed_data);
+ lib = Library::LookupLibrary(Symbols::DartTypedData());
+ if (lib.IsNull()) {
+ lib = Library::NewLibraryHelper(Symbols::DartTypedData(), true);
+ lib.Register();
+ isolate->object_store()->set_bootstrap_library(ObjectStore::kTypedData,
+ lib);
+ }
ASSERT(!lib.IsNull());
ASSERT(lib.raw() == Library::TypedDataLibrary());
const intptr_t typed_data_class_array_length =
@@ -979,14 +960,16 @@
type = Type::NewNonParameterizedType(cls);
object_store->set_number_type(type);
- cls = Class::New<Instance>(Symbols::Int(), script, Scanner::kDummyTokenIndex);
+ cls = Class::New<Instance>(Symbols::Int(),
+ core_script,
+ Scanner::kDummyTokenIndex);
RegisterClass(cls, Symbols::Int(), core_lib);
pending_classes.Add(cls, Heap::kOld);
type = Type::NewNonParameterizedType(cls);
object_store->set_int_type(type);
cls = Class::New<Instance>(Symbols::Double(),
- script,
+ core_script,
Scanner::kDummyTokenIndex);
RegisterClass(cls, Symbols::Double(), core_lib);
pending_classes.Add(cls, Heap::kOld);
@@ -994,14 +977,14 @@
object_store->set_double_type(type);
name = Symbols::New("String");
- cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex);
+ cls = Class::New<Instance>(name, core_script, Scanner::kDummyTokenIndex);
RegisterClass(cls, name, core_lib);
pending_classes.Add(cls, Heap::kOld);
type = Type::NewNonParameterizedType(cls);
object_store->set_string_type(type);
cls = Class::New<Instance>(Symbols::List(),
- script,
+ core_script,
Scanner::kDummyTokenIndex);
RegisterClass(cls, Symbols::List(), core_lib);
pending_classes.Add(cls, Heap::kOld);
@@ -1041,22 +1024,12 @@
// Finish the initialization by compiling the bootstrap scripts containing the
// base interfaces and the implementation of the internal classes.
- INIT_LIBRARY(Core, core, true);
+ const Error& error =
+ Error::Handle(Bootstrap::LoadandCompileScripts(core_script));
+ if (!error.IsNull()) {
+ return error.raw();
+ }
- INIT_LIBRARY(Async, async, true);
- INIT_LIBRARY(Collection, collection, true);
- INIT_LIBRARY(CollectionDev, collection_dev, true);
- INIT_LIBRARY(Crypto, crypto, false);
- INIT_LIBRARY(Isolate, isolate, true);
- INIT_LIBRARY(Json, json, true);
- INIT_LIBRARY(Math, math, true);
- INIT_LIBRARY(Mirrors, mirrors, true);
- INIT_LIBRARY(TypedData, typed_data, true);
- INIT_LIBRARY(Utf, utf, false);
- INIT_LIBRARY(Uri, uri, false);
-
- Bootstrap::SetupNativeResolver();
-
// Remove the Object superclass cycle by setting the super type to null (not
// to the type of null).
cls = object_store->object_class();
@@ -6445,7 +6418,7 @@
const Library& core_lib =
Library::Handle(Library::NewLibraryHelper(core_lib_url, false));
core_lib.Register();
- isolate->object_store()->set_core_library(core_lib);
+ isolate->object_store()->set_bootstrap_library(ObjectStore::kCore, core_lib);
isolate->object_store()->set_root_library(Library::Handle());
// Hook up predefined classes without setting their library pointers. These
« runtime/vm/bootstrap.cc ('K') | « 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