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

Unified Diff: runtime/vm/bootstrap.cc

Issue 14784010: Third step towards loading 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
« no previous file with comments | « runtime/vm/bootstrap.h ('k') | runtime/vm/vm.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/bootstrap.cc
===================================================================
--- runtime/vm/bootstrap.cc (revision 22398)
+++ runtime/vm/bootstrap.cc (working copy)
@@ -27,7 +27,7 @@
const char* uri_;
const char** source_paths_;
const char* patch_uri_;
- const char* patch_source_;
+ const char** patch_paths_;
} bootstrap_lib_props;
@@ -35,19 +35,19 @@
INIT_LIBRARY(ObjectStore::kCore,
core,
Bootstrap::corelib_source_paths_,
- Bootstrap::corelib_patch_),
+ Bootstrap::corelib_patch_paths_),
INIT_LIBRARY(ObjectStore::kAsync,
async,
Bootstrap::async_source_paths_,
- Bootstrap::async_patch_),
+ Bootstrap::async_patch_paths_),
INIT_LIBRARY(ObjectStore::kCollection,
collection,
Bootstrap::collection_source_paths_,
- Bootstrap::collection_patch_),
+ Bootstrap::collection_patch_paths_),
INIT_LIBRARY(ObjectStore::kCollectionDev,
_collection-dev,
Bootstrap::collection_dev_source_paths_,
- Bootstrap::collection_dev_patch_),
+ Bootstrap::collection_dev_patch_paths_),
INIT_LIBRARY(ObjectStore::kCrypto,
crypto,
Bootstrap::crypto_source_paths_,
@@ -55,23 +55,23 @@
INIT_LIBRARY(ObjectStore::kIsolate,
isolate,
Bootstrap::isolate_source_paths_,
- Bootstrap::isolate_patch_),
+ Bootstrap::isolate_patch_paths_),
INIT_LIBRARY(ObjectStore::kJson,
json,
Bootstrap::json_source_paths_,
- Bootstrap::json_patch_),
+ Bootstrap::json_patch_paths_),
INIT_LIBRARY(ObjectStore::kMath,
math,
Bootstrap::math_source_paths_,
- Bootstrap::math_patch_),
+ Bootstrap::math_patch_paths_),
INIT_LIBRARY(ObjectStore::kMirrors,
mirrors,
Bootstrap::mirrors_source_paths_,
- Bootstrap::mirrors_patch_),
+ Bootstrap::mirrors_patch_paths_),
INIT_LIBRARY(ObjectStore::kTypedData,
typed_data,
Bootstrap::typed_data_source_paths_,
- Bootstrap::typed_data_patch_),
+ Bootstrap::typed_data_patch_paths_),
INIT_LIBRARY(ObjectStore::kUtf,
utf,
Bootstrap::utf_source_paths_,
@@ -102,15 +102,10 @@
return String::null(); // Library is not a boot strap library.
}
- if (patch) {
- // TODO(asiva): Replace with actual read of the source file.
- const char* source = bootstrap_libraries[index].patch_source_;
- ASSERT(source != NULL);
- return String::New(source, Heap::kOld);
- }
-
// Try to read the source using the path specified for the uri.
- const char** source_paths = bootstrap_libraries[index].source_paths_;
+ const char** source_paths = patch ?
+ bootstrap_libraries[index].patch_paths_ :
+ bootstrap_libraries[index].source_paths_;
if (source_paths == NULL) {
return String::null(); // No path mapping information exists for library.
}
@@ -234,6 +229,41 @@
}
+static RawError* LoadPatchFiles(Isolate* isolate,
+ const Library& lib,
+ const String& patch_uri,
+ const char** patch_files) {
+ String& patch_file_uri = String::Handle(isolate);
+ String& source = String::Handle(isolate);
+ Script& script = Script::Handle(isolate);
+ Error& error = Error::Handle(isolate);
+ const Array& strings = Array::Handle(isolate, Array::New(3));
+ strings.SetAt(0, patch_uri);
+ strings.SetAt(1, Symbols::Slash());
+ intptr_t j = 0;
+ while (patch_files[j] != NULL) {
+ patch_file_uri = String::New(patch_files[j]);
+ source = GetLibrarySource(lib, patch_file_uri, true);
+ if (source.IsNull()) {
+ return Api::UnwrapErrorHandle(
+ isolate,
+ Api::NewError("Unable to find dart patch source for %s",
+ patch_file_uri.ToCString())).raw();
+ }
+ // Prepend the patch library URI to form a unique script URI for the patch.
+ strings.SetAt(2, patch_file_uri);
+ patch_file_uri = String::ConcatAll(strings);
+ script = Script::New(patch_file_uri, source, RawScript::kPatchTag);
+ error = lib.Patch(script);
+ if (!error.IsNull()) {
+ return error.raw();
+ }
+ j += 2;
+ }
+ return Error::null();
+}
+
+
RawError* Bootstrap::LoadandCompileScripts() {
Isolate* isolate = Isolate::Current();
String& uri = String::Handle();
@@ -266,7 +296,7 @@
i = i + 1;
}
- // Load and compile bootstrap libraries.
+ // Load, compile and patch bootstrap libraries.
i = 0;
while (bootstrap_libraries[i].index_ != ObjectStore::kNone) {
uri = Symbols::New(bootstrap_libraries[i].uri_);
@@ -285,18 +315,12 @@
break;
}
// If a patch exists, load and patch the script.
- if (bootstrap_libraries[i].patch_source_ != NULL) {
- patch_uri = String::New(bootstrap_libraries[i].patch_uri_,
- Heap::kOld);
- source = GetLibrarySource(lib, uri, true);
- if (source.IsNull()) {
- error ^= Api::UnwrapErrorHandle(
- isolate, Api::NewError("Unable to find dart patch source for %s",
- uri.ToCString())).raw();
- break;
- }
- script = Script::New(patch_uri, source, RawScript::kPatchTag);
- error = lib.Patch(script);
+ if (bootstrap_libraries[i].patch_paths_ != NULL) {
+ patch_uri = Symbols::New(bootstrap_libraries[i].patch_uri_);
+ error = LoadPatchFiles(isolate,
+ lib,
+ patch_uri,
+ bootstrap_libraries[i].patch_paths_);
if (!error.IsNull()) {
break;
}
« no previous file with comments | « runtime/vm/bootstrap.h ('k') | runtime/vm/vm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698