Index: src/bootstrapper.cc |
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc |
index 915b2e6a694107351fc160cb8d88cd3eb5e9eaaa..1b122ec48be978c85d6cc0c9d7e85649da53c67e 100644 |
--- a/src/bootstrapper.cc |
+++ b/src/bootstrapper.cc |
@@ -235,6 +235,7 @@ class Genesis BASE_EMBEDDED { |
bool InstallDebuggerNatives(); |
void InstallBuiltinFunctionIds(); |
void InstallExperimentalBuiltinFunctionIds(); |
+ void InstallExperimentalExports(); |
void InitializeNormalizedMapCaches(); |
enum ExtensionTraversalState { |
@@ -533,6 +534,12 @@ void InstallSpeciesGetter(Handle<JSFunction> constructor) { |
true); |
} |
+void SetFunction(Handle<JSObject> target, Handle<JSFunction> function, |
+ Handle<Name> name, PropertyAttributes attributes = DONT_ENUM) { |
+ JSObject::SetOwnPropertyIgnoreAttributes(target, name, function, attributes) |
+ .ToHandleChecked(); |
+} |
+ |
} // namespace |
Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { |
@@ -3501,19 +3508,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate, |
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_experimental_container(*container); |
} |
@@ -4116,10 +4111,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}; |
@@ -4151,6 +4144,7 @@ bool Genesis::InstallExperimentalNatives() { |
if (!CallUtilsFunction(isolate(), "PostExperimentals")) return false; |
InstallExperimentalBuiltinFunctionIds(); |
+ InstallExperimentalExports(); |
return true; |
} |
@@ -4244,6 +4238,63 @@ void Genesis::InstallExperimentalBuiltinFunctionIds() { |
} |
} |
+void Genesis::InstallExperimentalExports() { |
+ HandleScope scope(isolate()); |
+ |
+ Handle<JSObject> experimental_container( |
+ native_context()->experimental_container()); |
+ |
+#if V8_I18N_SUPPORT |
+ if (FLAG_icu_case_mapping) { |
+ Handle<JSObject> string_prototype( |
+ JSObject::cast(native_context()->string_function()->prototype())); |
+ |
+ Handle<JSFunction> to_lower_case = Handle<JSFunction>::cast( |
+ JSReceiver::GetProperty( |
+ experimental_container, |
+ factory()->InternalizeUtf8String("ToLowerCaseI18N")) |
+ .ToHandleChecked()); |
+ SetFunction(string_prototype, to_lower_case, |
+ factory()->InternalizeUtf8String("toLowerCase")); |
+ |
+ Handle<JSFunction> to_upper_case = Handle<JSFunction>::cast( |
+ JSReceiver::GetProperty( |
+ experimental_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( |
+ experimental_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( |
+ experimental_container, |
+ factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) |
+ .ToHandleChecked()); |
+ SetFunction(string_prototype, to_locale_upper_case, |
+ factory()->InternalizeUtf8String("toLocaleUpperCase")); |
+ } |
+ |
+ if (FLAG_datetime_format_to_parts) { |
+ 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( |
+ experimental_container, |
+ factory()->InternalizeUtf8String("FormatDateToParts")) |
+ .ToHandleChecked()); |
+ InstallFunction(date_time_format_prototype, format_date_to_parts, |
+ factory()->InternalizeUtf8String("formatToParts")); |
+ } |
+#endif // V8_I18N_SUPPORT |
+} |
#undef INSTALL_BUILTIN_ID |