Third step towards loading core library scripts directly from the sources
- Read the patch source files using the source mapping array generated for patch files instead of relying on a generated buffer containing the sources. - Modify the gyp files to ensure that all patch libraries are read directly from the sources. Remove the source buffer generation step in the gypi files for all patch files. R=hausner@google.com, iposva@google.com Review URL: https://codereview.chromium.org//14784010 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22436 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
+13
-12
@@ -5,6 +5,19 @@
|
||||
|
||||
// VM implementation of DateTime.
|
||||
patch class DateTime {
|
||||
// Natives.
|
||||
// The natives have been moved up here to work around Issue 10401.
|
||||
static int _getCurrentMs() native "DateNatives_currentTimeMillis";
|
||||
|
||||
static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch)
|
||||
native "DateNatives_timeZoneName";
|
||||
|
||||
static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch)
|
||||
native "DateNatives_timeZoneOffsetInSeconds";
|
||||
|
||||
static int _localTimeZoneAdjustmentInSeconds()
|
||||
native "DateNatives_localTimeZoneAdjustmentInSeconds";
|
||||
|
||||
/* patch */ DateTime._internal(int year,
|
||||
int month,
|
||||
int day,
|
||||
@@ -310,16 +323,4 @@ patch class DateTime {
|
||||
int equivalentSeconds = _equivalentSeconds(millisecondsSinceEpoch);
|
||||
return _timeZoneNameForClampedSeconds(equivalentSeconds);
|
||||
}
|
||||
|
||||
// Natives
|
||||
static int _getCurrentMs() native "DateNatives_currentTimeMillis";
|
||||
|
||||
static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch)
|
||||
native "DateNatives_timeZoneName";
|
||||
|
||||
static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch)
|
||||
native "DateNatives_timeZoneOffsetInSeconds";
|
||||
|
||||
static int _localTimeZoneAdjustmentInSeconds()
|
||||
native "DateNatives_localTimeZoneAdjustmentInSeconds";
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ def makeFile(output_file, input_cc_file, include, var_name, lib_name, in_files):
|
||||
os.path.basename(string_file).replace('\\', '\\\\') + '", ')
|
||||
part_index.append('"' +
|
||||
os.path.abspath(string_file).replace('\\', '\\\\') + '", \n')
|
||||
bootstrap_cc_text = bootstrap_cc_text.replace("{{LIBRARY_SOURCE_MAP}}", '')
|
||||
bootstrap_cc_text = bootstrap_cc_text.replace("{{PART_SOURCE_MAP}}",
|
||||
''.join(part_index))
|
||||
open(output_file, 'w').write(bootstrap_cc_text)
|
||||
|
||||
+55
-31
@@ -27,7 +27,7 @@ typedef struct {
|
||||
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 @@ static bootstrap_lib_props bootstrap_libraries[] = {
|
||||
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 @@ static bootstrap_lib_props bootstrap_libraries[] = {
|
||||
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 @@ static RawString* GetLibrarySource(const Library& lib,
|
||||
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 Dart_Handle BootstrapLibraryTagHandler(Dart_LibraryTag tag,
|
||||
}
|
||||
|
||||
|
||||
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 @@ RawError* Bootstrap::LoadandCompileScripts() {
|
||||
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 @@ RawError* Bootstrap::LoadandCompileScripts() {
|
||||
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;
|
||||
}
|
||||
|
||||
+10
-10
@@ -31,16 +31,16 @@ class Bootstrap : public AllStatic {
|
||||
static const char* uri_source_paths_[];
|
||||
static const char* utf_source_paths_[];
|
||||
|
||||
// Patch sources for libaries (concatenated source).
|
||||
static const char async_patch_[];
|
||||
static const char corelib_patch_[];
|
||||
static const char collection_patch_[];
|
||||
static const char collection_dev_patch_[];
|
||||
static const char isolate_patch_[];
|
||||
static const char json_patch_[];
|
||||
static const char math_patch_[];
|
||||
static const char mirrors_patch_[];
|
||||
static const char typed_data_patch_[];
|
||||
// Source path mapping for patch URI and 'parts'.
|
||||
static const char* async_patch_paths_[];
|
||||
static const char* corelib_patch_paths_[];
|
||||
static const char* collection_patch_paths_[];
|
||||
static const char* collection_dev_patch_paths_[];
|
||||
static const char* isolate_patch_paths_[];
|
||||
static const char* json_patch_paths_[];
|
||||
static const char* math_patch_paths_[];
|
||||
static const char* mirrors_patch_paths_[];
|
||||
static const char* typed_data_patch_paths_[];
|
||||
};
|
||||
|
||||
} // namespace dart
|
||||
|
||||
+54
-45
@@ -274,8 +274,8 @@
|
||||
{
|
||||
'action_name': 'generate_corelib_patch_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'../tools/gen_library_src_paths.py',
|
||||
'<(libgen_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
@@ -283,11 +283,12 @@
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/create_string_literal.py',
|
||||
'tools/gen_library_src_paths.py',
|
||||
'--output', '<(corelib_patch_cc_file)',
|
||||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--input_cc', '<(libgen_in_cc_file)',
|
||||
'--include', 'vm/bootstrap.h',
|
||||
'--var_name', 'dart::Bootstrap::corelib_patch_',
|
||||
'--var_name', 'dart::Bootstrap::corelib_patch_paths_',
|
||||
'--library_name', 'dart:corelib',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'message': 'Generating ''<(corelib_patch_cc_file)'' file.'
|
||||
@@ -353,8 +354,8 @@
|
||||
{
|
||||
'action_name': 'generate_collection_dev_patch_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'../tools/gen_library_src_paths.py',
|
||||
'<(libgen_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
@@ -362,11 +363,12 @@
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/create_string_literal.py',
|
||||
'tools/gen_library_src_paths.py',
|
||||
'--output', '<(collection_dev_patch_cc_file)',
|
||||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--input_cc', '<(libgen_in_cc_file)',
|
||||
'--include', 'vm/bootstrap.h',
|
||||
'--var_name', 'dart::Bootstrap::collection_dev_patch_',
|
||||
'--var_name', 'dart::Bootstrap::collection_dev_patch_paths_',
|
||||
'--library_name', 'dart:_collection-dev',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'message': 'Generating ''<(collection_dev_patch_cc_file)'' file.'
|
||||
@@ -505,8 +507,8 @@
|
||||
{
|
||||
'action_name': 'generate_math_patch_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'../tools/gen_library_src_paths.py',
|
||||
'<(libgen_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
@@ -514,11 +516,12 @@
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/create_string_literal.py',
|
||||
'tools/gen_library_src_paths.py',
|
||||
'--output', '<(math_patch_cc_file)',
|
||||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--input_cc', '<(libgen_in_cc_file)',
|
||||
'--include', 'vm/bootstrap.h',
|
||||
'--var_name', 'dart::Bootstrap::math_patch_',
|
||||
'--var_name', 'dart::Bootstrap::math_patch_paths_',
|
||||
'--library_name', 'dart:math',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'message': 'Generating ''<(math_patch_cc_file)'' file.'
|
||||
@@ -584,8 +587,8 @@
|
||||
{
|
||||
'action_name': 'generate_mirrors_patch_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'../tools/gen_library_src_paths.py',
|
||||
'<(libgen_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
@@ -593,11 +596,12 @@
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/create_string_literal.py',
|
||||
'tools/gen_library_src_paths.py',
|
||||
'--output', '<(mirrors_patch_cc_file)',
|
||||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--input_cc', '<(libgen_in_cc_file)',
|
||||
'--include', 'vm/bootstrap.h',
|
||||
'--var_name', 'dart::Bootstrap::mirrors_patch_',
|
||||
'--var_name', 'dart::Bootstrap::mirrors_patch_paths_',
|
||||
'--library_name', 'dart:mirrors',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'message': 'Generating ''<(mirrors_patch_cc_file)'' file.'
|
||||
@@ -663,8 +667,8 @@
|
||||
{
|
||||
'action_name': 'generate_async_patch_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'../tools/gen_library_src_paths.py',
|
||||
'<(libgen_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
@@ -672,11 +676,12 @@
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/create_string_literal.py',
|
||||
'tools/gen_library_src_paths.py',
|
||||
'--output', '<(async_patch_cc_file)',
|
||||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--input_cc', '<(libgen_in_cc_file)',
|
||||
'--include', 'vm/bootstrap.h',
|
||||
'--var_name', 'dart::Bootstrap::async_patch_',
|
||||
'--var_name', 'dart::Bootstrap::async_patch_paths_',
|
||||
'--library_name', 'dart:async',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'message': 'Generating ''<(async_patch_cc_file)'' file.'
|
||||
@@ -702,8 +707,8 @@
|
||||
{
|
||||
'action_name': 'generate_collection_patch_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'../tools/gen_library_src_paths.py',
|
||||
'<(libgen_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
@@ -711,11 +716,12 @@
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/create_string_literal.py',
|
||||
'tools/gen_library_src_paths.py',
|
||||
'--output', '<(collection_patch_cc_file)',
|
||||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--input_cc', '<(libgen_in_cc_file)',
|
||||
'--include', 'vm/bootstrap.h',
|
||||
'--var_name', 'dart::Bootstrap::collection_patch_',
|
||||
'--var_name', 'dart::Bootstrap::collection_patch_paths_',
|
||||
'--library_name', 'dart:collection',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'message': 'Generating ''<(collection_patch_cc_file)'' file.'
|
||||
@@ -741,8 +747,8 @@
|
||||
{
|
||||
'action_name': 'generate_isolate_patch_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'../tools/gen_library_src_paths.py',
|
||||
'<(libgen_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
@@ -750,11 +756,12 @@
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/create_string_literal.py',
|
||||
'tools/gen_library_src_paths.py',
|
||||
'--output', '<(isolate_patch_cc_file)',
|
||||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--input_cc', '<(libgen_in_cc_file)',
|
||||
'--include', 'vm/bootstrap.h',
|
||||
'--var_name', 'dart::Bootstrap::isolate_patch_',
|
||||
'--var_name', 'dart::Bootstrap::isolate_patch_paths_',
|
||||
'--library_name', 'dart:isolate',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'message': 'Generating ''<(isolate_patch_cc_file)'' file.'
|
||||
@@ -813,8 +820,8 @@
|
||||
{
|
||||
'action_name': 'generate_json_patch_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'../tools/gen_library_src_paths.py',
|
||||
'<(libgen_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
@@ -822,11 +829,12 @@
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/create_string_literal.py',
|
||||
'tools/gen_library_src_paths.py',
|
||||
'--output', '<(json_patch_cc_file)',
|
||||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--input_cc', '<(libgen_in_cc_file)',
|
||||
'--include', 'vm/bootstrap.h',
|
||||
'--var_name', 'dart::Bootstrap::json_patch_',
|
||||
'--var_name', 'dart::Bootstrap::json_patch_paths_',
|
||||
'--library_name', 'dart:json',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'message': 'Generating ''<(json_patch_cc_file)'' file.'
|
||||
@@ -892,8 +900,8 @@
|
||||
{
|
||||
'action_name': 'generate_typed_data_patch_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'../tools/gen_library_src_paths.py',
|
||||
'<(libgen_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
@@ -901,11 +909,12 @@
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/create_string_literal.py',
|
||||
'tools/gen_library_src_paths.py',
|
||||
'--output', '<(typed_data_patch_cc_file)',
|
||||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--input_cc', '<(libgen_in_cc_file)',
|
||||
'--include', 'vm/bootstrap.h',
|
||||
'--var_name', 'dart::Bootstrap::typed_data_patch_',
|
||||
'--var_name', 'dart::Bootstrap::typed_data_patch_paths_',
|
||||
'--library_name', 'dart:typed_data',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'message': 'Generating ''<(typed_data_patch_cc_file)'' file.'
|
||||
|
||||
Reference in New Issue
Block a user