Commit 407d6bf1 authored by littledan's avatar littledan Committed by Commit bot

[bootstrapper] Remove Intl experimental natives files

These experimental natives previously only installed functions to the
appropriate parent. In this patch, the exports container is retained
so that the bootstrapper may install the functions instead. This
change is intended to reduce startup time. SharedArrayBuffer retains
some experimental natives exported from JS; this may be addressed
in a follow-on patch. The patch includes some minor cleanup of the
bootstrap process by removing "experimental exports", which was unused.

R=yangguo@chromium.org
BUG=v8:5880
CQ_INCLUDE_TRYBOTS=master.tryserver.v8:v8_linux_noi18n_rel_ng

Review-Url: https://codereview.chromium.org/2683083003
Cr-Commit-Position: refs/heads/master@{#43221}
parent e7ebb930
......@@ -499,13 +499,6 @@ action("js2c_experimental") {
"$target_gen_dir/experimental-libraries.cc",
]
if (v8_enable_i18n_support) {
sources += [
"src/js/datetime-format-to-parts.js",
"src/js/icu-case-mapping.js",
]
}
args = [
rebase_path("$target_gen_dir/experimental-libraries.cc",
root_build_dir),
......
......@@ -3141,6 +3141,7 @@ void Genesis::ConfigureUtilsObject(GlobalContextType context_type) {
// The utils object can be removed for cases that reach this point.
native_context()->set_natives_utils_object(heap()->undefined_value());
native_context()->set_extras_utils_object(heap()->undefined_value());
native_context()->set_exports_container(heap()->undefined_value());
}
......@@ -3496,24 +3497,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Accessors::FunctionSetPrototype(callsite_fun, proto).Assert();
}
}
}
void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
Handle<JSObject> container) {
HandleScope scope(isolate);
#ifdef V8_I18N_SUPPORT
#define INITIALIZE_FLAG(FLAG) \
{ \
Handle<String> name = \
isolate->factory()->NewStringFromAsciiChecked(#FLAG); \
JSObject::AddProperty(container, name, \
isolate->factory()->ToBoolean(FLAG), NONE); \
}
#undef INITIALIZE_FLAG
#endif
isolate->native_context()->set_exports_container(*container);
}
......@@ -3526,10 +3510,6 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tailcalls)
#ifdef V8_I18N_SUPPORT
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(datetime_format_to_parts)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(icu_case_mapping)
#endif
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_generators)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_trailing_commas)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_class_fields)
......@@ -3628,6 +3608,75 @@ void Genesis::InitializeGlobal_harmony_async_iteration() {
factory()->async_iterator_symbol());
}
#ifdef V8_I18N_SUPPORT
void Genesis::InitializeGlobal_datetime_format_to_parts() {
if (!FLAG_datetime_format_to_parts) return;
Handle<JSReceiver> exports_container(
JSReceiver::cast(native_context()->exports_container()));
Handle<JSObject> date_time_format_prototype(JSObject::cast(
native_context()->intl_date_time_format_function()->prototype()));
Handle<JSFunction> format_date_to_parts = Handle<JSFunction>::cast(
JSReceiver::GetProperty(
exports_container,
factory()->InternalizeUtf8String("FormatDateToParts"))
.ToHandleChecked());
InstallFunction(date_time_format_prototype, format_date_to_parts,
factory()->InternalizeUtf8String("formatToParts"));
}
namespace {
void SetFunction(Handle<JSObject> target, Handle<JSFunction> function,
Handle<Name> name, PropertyAttributes attributes = DONT_ENUM) {
JSObject::SetOwnPropertyIgnoreAttributes(target, name, function, attributes)
.ToHandleChecked();
}
} // namespace
void Genesis::InitializeGlobal_icu_case_mapping() {
if (!FLAG_icu_case_mapping) return;
Handle<JSReceiver> exports_container(
JSReceiver::cast(native_context()->exports_container()));
Handle<JSObject> string_prototype(
JSObject::cast(native_context()->string_function()->prototype()));
Handle<JSFunction> to_lower_case = Handle<JSFunction>::cast(
JSReceiver::GetProperty(
exports_container,
factory()->InternalizeUtf8String("ToLowerCaseI18N"))
.ToHandleChecked());
SetFunction(string_prototype, to_lower_case,
factory()->InternalizeUtf8String("toLowerCase"));
Handle<JSFunction> to_upper_case = Handle<JSFunction>::cast(
JSReceiver::GetProperty(
exports_container,
factory()->InternalizeUtf8String("ToUpperCaseI18N"))
.ToHandleChecked());
SetFunction(string_prototype, to_upper_case,
factory()->InternalizeUtf8String("toUpperCase"));
Handle<JSFunction> to_locale_lower_case = Handle<JSFunction>::cast(
JSReceiver::GetProperty(
exports_container,
factory()->InternalizeUtf8String("ToLocaleLowerCaseI18N"))
.ToHandleChecked());
SetFunction(string_prototype, to_locale_lower_case,
factory()->InternalizeUtf8String("toLocaleLowerCase"));
Handle<JSFunction> to_locale_upper_case = Handle<JSFunction>::cast(
JSReceiver::GetProperty(
exports_container,
factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N"))
.ToHandleChecked());
SetFunction(string_prototype, to_locale_upper_case,
factory()->InternalizeUtf8String("toLocaleUpperCase"));
}
#endif
Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target,
const char* name,
Builtins::Name call,
......@@ -4083,10 +4132,8 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_function_sent_natives[] = {nullptr};
static const char* harmony_array_prototype_values_natives[] = {nullptr};
#ifdef V8_I18N_SUPPORT
static const char* icu_case_mapping_natives[] = {"native icu-case-mapping.js",
nullptr};
static const char* datetime_format_to_parts_natives[] = {
"native datetime-format-to-parts.js", nullptr};
static const char* icu_case_mapping_natives[] = {nullptr};
static const char* datetime_format_to_parts_natives[] = {nullptr};
#endif
static const char* harmony_restrictive_generators_natives[] = {nullptr};
static const char* harmony_trailing_commas_natives[] = {nullptr};
......@@ -4211,7 +4258,6 @@ void Genesis::InstallExperimentalBuiltinFunctionIds() {
}
}
#undef INSTALL_BUILTIN_ID
......
......@@ -121,8 +121,6 @@ class Bootstrapper final {
static bool CompileExperimentalExtraBuiltin(Isolate* isolate, int index);
static void ExportFromRuntime(Isolate* isolate, Handle<JSObject> container);
static void ExportExperimentalFromRuntime(Isolate* isolate,
Handle<JSObject> container);
private:
Isolate* isolate_;
......
......@@ -342,6 +342,7 @@ enum ContextLookupFlags {
V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun) \
V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun) \
V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun) \
V(EXPORTS_CONTAINER, Object, exports_container) \
NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \
NATIVE_CONTEXT_IMPORTED_FIELDS(V) \
NATIVE_CONTEXT_JS_ARRAY_ITERATOR_MAPS(V)
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function(global, utils) {
"use strict";
%CheckIsBootstrapping();
var GlobalIntl = global.Intl;
var FormatDateToParts = utils.ImportNow("FormatDateToParts");
utils.InstallFunctions(GlobalIntl.DateTimeFormat.prototype, DONT_ENUM, [
'formatToParts', FormatDateToParts
]);
})
......@@ -2053,6 +2053,7 @@ OverrideFunction(GlobalString.prototype, 'normalize', function() {
}
);
// TODO(littledan): Rewrite these two functions as C++ builtins
function ToLowerCaseI18N() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
return %StringToLowerCaseI18N(TO_STRING(this));
......@@ -2077,18 +2078,6 @@ function ToLocaleUpperCaseI18N(locales) {
%FunctionSetLength(ToLocaleUpperCaseI18N, 0);
%FunctionRemovePrototype(ToLowerCaseI18N);
%FunctionRemovePrototype(ToUpperCaseI18N);
%FunctionRemovePrototype(ToLocaleLowerCaseI18N);
%FunctionRemovePrototype(ToLocaleUpperCaseI18N);
utils.Export(function(to) {
to.ToLowerCaseI18N = ToLowerCaseI18N;
to.ToUpperCaseI18N = ToUpperCaseI18N;
to.ToLocaleLowerCaseI18N = ToLocaleLowerCaseI18N;
to.ToLocaleUpperCaseI18N = ToLocaleUpperCaseI18N;
});
/**
* Formats a Number object (this) using locale and options values.
......@@ -2169,9 +2158,23 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
);
%FunctionRemovePrototype(FormatDateToParts);
%FunctionRemovePrototype(ToLowerCaseI18N);
%FunctionRemovePrototype(ToUpperCaseI18N);
%FunctionRemovePrototype(ToLocaleLowerCaseI18N);
%FunctionRemovePrototype(ToLocaleUpperCaseI18N);
utils.SetFunctionName(FormatDateToParts, "formatToParts");
utils.SetFunctionName(ToLowerCaseI18N, "toLowerCase");
utils.SetFunctionName(ToUpperCaseI18N, "toUpperCase");
utils.SetFunctionName(ToLocaleLowerCaseI18N, "toLocaleLowerCase");
utils.SetFunctionName(ToLocaleUpperCaseI18N, "toLocaleUpperCase");
utils.Export(function(to) {
to.FormatDateToParts = FormatDateToParts;
to.ToLowerCaseI18N = ToLowerCaseI18N;
to.ToUpperCaseI18N = ToUpperCaseI18N;
to.ToLocaleLowerCaseI18N = ToLocaleLowerCaseI18N;
to.ToLocaleUpperCaseI18N = ToLocaleUpperCaseI18N;
});
})
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function(global, utils) {
"use strict";
%CheckIsBootstrapping();
var GlobalString = global.String;
var OverrideFunction = utils.OverrideFunction;
var ToLowerCaseI18N = utils.ImportNow("ToLowerCaseI18N");
var ToUpperCaseI18N = utils.ImportNow("ToUpperCaseI18N");
var ToLocaleLowerCaseI18N = utils.ImportNow("ToLocaleLowerCaseI18N");
var ToLocaleUpperCaseI18N = utils.ImportNow("ToLocaleUpperCaseI18N");
OverrideFunction(GlobalString.prototype, 'toLowerCase', ToLowerCaseI18N, true);
OverrideFunction(GlobalString.prototype, 'toUpperCase', ToUpperCaseI18N, true);
OverrideFunction(GlobalString.prototype, 'toLocaleLowerCase',
ToLocaleLowerCaseI18N, true);
OverrideFunction(GlobalString.prototype, 'toLocaleUpperCase',
ToLocaleUpperCaseI18N, true);
})
......@@ -203,7 +203,6 @@ function PostNatives(utils) {
function PostExperimentals(utils) {
%CheckIsBootstrapping();
%ExportExperimentalFromRuntime(exports_container);
for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
imports(exports_container);
}
......
......@@ -106,6 +106,7 @@ function StringSlice(start, end) {
return %_SubString(s, start_i, end_i);
}
// TODO(littledan): Rewrite these four functions as C++ builtins
// ECMA-262, 15.5.4.16
function StringToLowerCaseJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
......
......@@ -43,19 +43,6 @@ RUNTIME_FUNCTION(Runtime_ExportFromRuntime) {
}
RUNTIME_FUNCTION(Runtime_ExportExperimentalFromRuntime) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
CHECK(isolate->bootstrapper()->IsActive());
JSObject::NormalizeProperties(container, KEEP_INOBJECT_PROPERTIES, 10,
"ExportExperimentalFromRuntime");
Bootstrapper::ExportExperimentalFromRuntime(isolate, container);
JSObject::MigrateSlowToFast(container, 0, "ExportExperimentalFromRuntime");
return *container;
}
RUNTIME_FUNCTION(Runtime_InstallToContext) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
......
......@@ -291,7 +291,6 @@ namespace internal {
F(CheckIsBootstrapping, 0, 1) \
F(CreateListFromArrayLike, 1, 1) \
F(GetAndResetRuntimeCallStats, -1 /* <= 2 */, 1) \
F(ExportExperimentalFromRuntime, 1, 1) \
F(ExportFromRuntime, 1, 1) \
F(IncrementUseCounter, 1, 1) \
F(InstallToContext, 1, 1) \
......
......@@ -2291,10 +2291,6 @@
'conditions': [
['v8_enable_i18n_support==1', {
'library_files': ['js/i18n.js'],
'experimental_library_files': [
'js/datetime-format-to-parts.js',
'js/icu-case-mapping.js',
],
}],
],
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment