Commit 9f50f935 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Remove usage of NewStringFromStaticChars

Bug: v8:5751
Change-Id: I17e2a5b489e84edb87805dd49dc144d6503d2c27
Reviewed-on: https://chromium-review.googlesource.com/c/1275146
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56582}
parent 71898faf
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
#define INTERNALIZED_STRING_LIST_GENERATOR_INTL(V, _) \ #define INTERNALIZED_STRING_LIST_GENERATOR_INTL(V, _) \
V(_, calendar_string, "calendar") \
V(_, caseFirst_string, "caseFirst") \ V(_, caseFirst_string, "caseFirst") \
V(_, day_string, "day") \ V(_, day_string, "day") \
V(_, dayPeriod_string, "dayPeriod") \ V(_, dayPeriod_string, "dayPeriod") \
...@@ -19,13 +20,17 @@ ...@@ -19,13 +20,17 @@
V(_, h23_string, "h23") \ V(_, h23_string, "h23") \
V(_, h24_string, "h24") \ V(_, h24_string, "h24") \
V(_, hour_string, "hour") \ V(_, hour_string, "hour") \
V(_, hour12_string, "hour12") \
V(_, hourCycle_string, "hourCycle") \
V(_, collation_string, "collation") \ V(_, collation_string, "collation") \
V(_, currency_string, "currency") \ V(_, currency_string, "currency") \
V(_, currencyDisplay_string, "currencyDisplay") \ V(_, currencyDisplay_string, "currencyDisplay") \
V(_, ignorePunctuation_string, "ignorePunctuation") \ V(_, ignorePunctuation_string, "ignorePunctuation") \
V(_, Invalid_Date_string, "Invalid Date") \
V(_, integer_string, "integer") \ V(_, integer_string, "integer") \
V(_, literal_string, "literal") \ V(_, literal_string, "literal") \
V(_, locale_string, "locale") \ V(_, locale_string, "locale") \
V(_, localeWithExtension_string, "localeWithExtension") \
V(_, lower_string, "lower") \ V(_, lower_string, "lower") \
V(_, maximumFractionDigits_string, "maximumFractionDigits") \ V(_, maximumFractionDigits_string, "maximumFractionDigits") \
V(_, maximumSignificantDigits_string, "maximumSignificantDigits") \ V(_, maximumSignificantDigits_string, "maximumSignificantDigits") \
...@@ -44,11 +49,13 @@ ...@@ -44,11 +49,13 @@
V(_, second_string, "second") \ V(_, second_string, "second") \
V(_, sensitivity_string, "sensitivity") \ V(_, sensitivity_string, "sensitivity") \
V(_, style_string, "style") \ V(_, style_string, "style") \
V(_, timeZone_string, "timeZone") \
V(_, timeZoneName_string, "timeZoneName") \ V(_, timeZoneName_string, "timeZoneName") \
V(_, type_string, "type") \ V(_, type_string, "type") \
V(_, upper_string, "upper") \ V(_, upper_string, "upper") \
V(_, usage_string, "usage") \ V(_, usage_string, "usage") \
V(_, useGrouping_string, "useGrouping") \ V(_, useGrouping_string, "useGrouping") \
V(_, UTC_string, "UTC") \
V(_, unit_string, "unit") \ V(_, unit_string, "unit") \
V(_, weekday_string, "weekday") \ V(_, weekday_string, "weekday") \
V(_, year_string, "year") V(_, year_string, "year")
......
...@@ -323,10 +323,8 @@ MaybeHandle<JSCollator> JSCollator::Initialize(Isolate* isolate, ...@@ -323,10 +323,8 @@ MaybeHandle<JSCollator> JSCollator::Initialize(Isolate* isolate,
Intl::ResolveLocale(isolate, "collator", requested_locales, options), Intl::ResolveLocale(isolate, "collator", requested_locales, options),
JSCollator); JSCollator);
Handle<String> locale_with_extension_str = Handle<Object> locale_with_extension_obj = JSObject::GetDataProperty(
isolate->factory()->NewStringFromStaticChars("localeWithExtension"); r, isolate->factory()->localeWithExtension_string());
Handle<Object> locale_with_extension_obj =
JSObject::GetDataProperty(r, locale_with_extension_str);
// The locale_with_extension has to be a string. Either a user // The locale_with_extension has to be a string. Either a user
// provided canonicalized string or the default locale. // provided canonicalized string or the default locale.
......
...@@ -180,14 +180,14 @@ void SetPropertyFromPattern(Isolate* isolate, const std::string& pattern, ...@@ -180,14 +180,14 @@ void SetPropertyFromPattern(Isolate* isolate, const std::string& pattern,
// iii. Else if, hc is "h23" or "h24", let v be false. // iii. Else if, hc is "h23" or "h24", let v be false.
// iv. Else, let v be undefined. // iv. Else, let v be undefined.
if (pattern.find('h') != std::string::npos) { if (pattern.find('h') != std::string::npos) {
CHECK(JSReceiver::CreateDataProperty( CHECK(JSReceiver::CreateDataProperty(isolate, options,
isolate, options, factory->NewStringFromStaticChars("hour12"), factory->hour12_string(),
factory->true_value(), kDontThrow) factory->true_value(), kDontThrow)
.FromJust()); .FromJust());
} else if (pattern.find('H') != std::string::npos) { } else if (pattern.find('H') != std::string::npos) {
CHECK(JSReceiver::CreateDataProperty( CHECK(JSReceiver::CreateDataProperty(isolate, options,
isolate, options, factory->NewStringFromStaticChars("hour12"), factory->hour12_string(),
factory->false_value(), kDontThrow) factory->false_value(), kDontThrow)
.FromJust()); .FromJust());
} }
} }
...@@ -329,7 +329,7 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions( ...@@ -329,7 +329,7 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions(
calendar_str = "ethioaa"; calendar_str = "ethioaa";
} }
CHECK(JSReceiver::CreateDataProperty( CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->NewStringFromStaticChars("calendar"), isolate, options, factory->calendar_string(),
factory->NewStringFromAsciiChecked(calendar_str.c_str()), factory->NewStringFromAsciiChecked(calendar_str.c_str()),
kDontThrow) kDontThrow)
.FromJust()); .FromJust());
...@@ -366,21 +366,21 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions( ...@@ -366,21 +366,21 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions(
// ecma402#sec-canonicalizetimezonename step 3 // ecma402#sec-canonicalizetimezonename step 3
if (canonical_time_zone == UNICODE_STRING_SIMPLE("Etc/UTC") || if (canonical_time_zone == UNICODE_STRING_SIMPLE("Etc/UTC") ||
canonical_time_zone == UNICODE_STRING_SIMPLE("Etc/GMT")) { canonical_time_zone == UNICODE_STRING_SIMPLE("Etc/GMT")) {
timezone_value = factory->NewStringFromStaticChars("UTC"); timezone_value = factory->UTC_string();
} else { } else {
ASSIGN_RETURN_ON_EXCEPTION(isolate, timezone_value, ASSIGN_RETURN_ON_EXCEPTION(isolate, timezone_value,
Intl::ToString(isolate, canonical_time_zone), Intl::ToString(isolate, canonical_time_zone),
JSObject); JSObject);
} }
CHECK(JSReceiver::CreateDataProperty( CHECK(JSReceiver::CreateDataProperty(isolate, options,
isolate, options, factory->NewStringFromStaticChars("timeZone"), factory->timeZone_string(),
timezone_value, kDontThrow) timezone_value, kDontThrow)
.FromJust()); .FromJust());
} else { } else {
// Somehow on Windows we will reach here. // Somehow on Windows we will reach here.
CHECK(JSReceiver::CreateDataProperty( CHECK(JSReceiver::CreateDataProperty(isolate, options,
isolate, options, factory->NewStringFromStaticChars("timeZone"), factory->timeZone_string(),
factory->undefined_value(), kDontThrow) factory->undefined_value(), kDontThrow)
.FromJust()); .FromJust());
} }
...@@ -451,14 +451,14 @@ MaybeHandle<String> JSDateTimeFormat::ToLocaleDateTime( ...@@ -451,14 +451,14 @@ MaybeHandle<String> JSDateTimeFormat::ToLocaleDateTime(
if (!date->IsJSDate()) { if (!date->IsJSDate()) {
THROW_NEW_ERROR(isolate, THROW_NEW_ERROR(isolate,
NewTypeError(MessageTemplate::kMethodInvokedOnWrongType, NewTypeError(MessageTemplate::kMethodInvokedOnWrongType,
factory->NewStringFromStaticChars("Date")), factory->Date_string()),
String); String);
} }
double const x = Handle<JSDate>::cast(date)->value()->Number(); double const x = Handle<JSDate>::cast(date)->value()->Number();
// 2. If x is NaN, return "Invalid Date" // 2. If x is NaN, return "Invalid Date"
if (std::isnan(x)) { if (std::isnan(x)) {
return factory->NewStringFromStaticChars("Invalid Date"); return factory->Invalid_Date_string();
} }
// 3. Let options be ? ToDateTimeOptions(options, required, defaults). // 3. Let options be ? ToDateTimeOptions(options, required, defaults).
...@@ -768,10 +768,8 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::Initialize( ...@@ -768,10 +768,8 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::Initialize(
// 9. Set opt.[[hc]] to hourCycle. // 9. Set opt.[[hc]] to hourCycle.
// TODO(ftang): change behavior based on hour_cycle. // TODO(ftang): change behavior based on hour_cycle.
Handle<String> locale_with_extension_str = Handle<Object> locale_with_extension_obj = JSObject::GetDataProperty(
isolate->factory()->NewStringFromStaticChars("localeWithExtension"); r, isolate->factory()->localeWithExtension_string());
Handle<Object> locale_with_extension_obj =
JSObject::GetDataProperty(r, locale_with_extension_str);
// The locale_with_extension has to be a string. Either a user // The locale_with_extension has to be a string. Either a user
// provided canonicalized string or the default locale. // provided canonicalized string or the default locale.
......
...@@ -231,10 +231,8 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::Initialize( ...@@ -231,10 +231,8 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::Initialize(
Intl::ResolveLocale(isolate, "numberformat", requested_locales, options), Intl::ResolveLocale(isolate, "numberformat", requested_locales, options),
JSNumberFormat); JSNumberFormat);
Handle<String> locale_with_extension_str = Handle<Object> locale_with_extension_obj = JSObject::GetDataProperty(
isolate->factory()->NewStringFromStaticChars("localeWithExtension"); r, isolate->factory()->localeWithExtension_string());
Handle<Object> locale_with_extension_obj =
JSObject::GetDataProperty(r, locale_with_extension_str);
// The locale_with_extension has to be a string. Either a user // The locale_with_extension has to be a string. Either a user
// provided canonicalized string or the default locale. // provided canonicalized string or the default locale.
......
...@@ -295,41 +295,41 @@ KNOWN_MAPS = { ...@@ -295,41 +295,41 @@ KNOWN_MAPS = {
("RO_SPACE", 0x02699): (171, "Tuple2Map"), ("RO_SPACE", 0x02699): (171, "Tuple2Map"),
("RO_SPACE", 0x02739): (173, "ArrayBoilerplateDescriptionMap"), ("RO_SPACE", 0x02739): (173, "ArrayBoilerplateDescriptionMap"),
("RO_SPACE", 0x02a79): (161, "InterceptorInfoMap"), ("RO_SPACE", 0x02a79): (161, "InterceptorInfoMap"),
("RO_SPACE", 0x04e81): (153, "AccessCheckInfoMap"), ("RO_SPACE", 0x04f49): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x04ed1): (154, "AccessorInfoMap"), ("RO_SPACE", 0x04f99): (154, "AccessorInfoMap"),
("RO_SPACE", 0x04f21): (155, "AccessorPairMap"), ("RO_SPACE", 0x04fe9): (155, "AccessorPairMap"),
("RO_SPACE", 0x04f71): (156, "AliasedArgumentsEntryMap"), ("RO_SPACE", 0x05039): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x04fc1): (157, "AllocationMementoMap"), ("RO_SPACE", 0x05089): (157, "AllocationMementoMap"),
("RO_SPACE", 0x05011): (158, "AsyncGeneratorRequestMap"), ("RO_SPACE", 0x050d9): (158, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x05061): (159, "DebugInfoMap"), ("RO_SPACE", 0x05129): (159, "DebugInfoMap"),
("RO_SPACE", 0x050b1): (160, "FunctionTemplateInfoMap"), ("RO_SPACE", 0x05179): (160, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x05101): (162, "InterpreterDataMap"), ("RO_SPACE", 0x051c9): (162, "InterpreterDataMap"),
("RO_SPACE", 0x05151): (163, "ModuleInfoEntryMap"), ("RO_SPACE", 0x05219): (163, "ModuleInfoEntryMap"),
("RO_SPACE", 0x051a1): (164, "ModuleMap"), ("RO_SPACE", 0x05269): (164, "ModuleMap"),
("RO_SPACE", 0x051f1): (165, "ObjectTemplateInfoMap"), ("RO_SPACE", 0x052b9): (165, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x05241): (166, "PromiseCapabilityMap"), ("RO_SPACE", 0x05309): (166, "PromiseCapabilityMap"),
("RO_SPACE", 0x05291): (167, "PromiseReactionMap"), ("RO_SPACE", 0x05359): (167, "PromiseReactionMap"),
("RO_SPACE", 0x052e1): (168, "PrototypeInfoMap"), ("RO_SPACE", 0x053a9): (168, "PrototypeInfoMap"),
("RO_SPACE", 0x05331): (169, "ScriptMap"), ("RO_SPACE", 0x053f9): (169, "ScriptMap"),
("RO_SPACE", 0x05381): (170, "StackFrameInfoMap"), ("RO_SPACE", 0x05449): (170, "StackFrameInfoMap"),
("RO_SPACE", 0x053d1): (172, "Tuple3Map"), ("RO_SPACE", 0x05499): (172, "Tuple3Map"),
("RO_SPACE", 0x05421): (174, "WasmDebugInfoMap"), ("RO_SPACE", 0x054e9): (174, "WasmDebugInfoMap"),
("RO_SPACE", 0x05471): (175, "WasmExportedFunctionDataMap"), ("RO_SPACE", 0x05539): (175, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x054c1): (176, "CallableTaskMap"), ("RO_SPACE", 0x05589): (176, "CallableTaskMap"),
("RO_SPACE", 0x05511): (177, "CallbackTaskMap"), ("RO_SPACE", 0x055d9): (177, "CallbackTaskMap"),
("RO_SPACE", 0x05561): (178, "PromiseFulfillReactionJobTaskMap"), ("RO_SPACE", 0x05629): (178, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x055b1): (179, "PromiseRejectReactionJobTaskMap"), ("RO_SPACE", 0x05679): (179, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x05601): (180, "PromiseResolveThenableJobTaskMap"), ("RO_SPACE", 0x056c9): (180, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x05651): (181, "MicrotaskQueueMap"), ("RO_SPACE", 0x05719): (181, "MicrotaskQueueMap"),
("RO_SPACE", 0x056a1): (182, "AllocationSiteWithWeakNextMap"), ("RO_SPACE", 0x05769): (182, "AllocationSiteWithWeakNextMap"),
("RO_SPACE", 0x056f1): (182, "AllocationSiteWithoutWeakNextMap"), ("RO_SPACE", 0x057b9): (182, "AllocationSiteWithoutWeakNextMap"),
("RO_SPACE", 0x05741): (214, "LoadHandler1Map"), ("RO_SPACE", 0x05809): (214, "LoadHandler1Map"),
("RO_SPACE", 0x05791): (214, "LoadHandler2Map"), ("RO_SPACE", 0x05859): (214, "LoadHandler2Map"),
("RO_SPACE", 0x057e1): (214, "LoadHandler3Map"), ("RO_SPACE", 0x058a9): (214, "LoadHandler3Map"),
("RO_SPACE", 0x05831): (221, "StoreHandler0Map"), ("RO_SPACE", 0x058f9): (221, "StoreHandler0Map"),
("RO_SPACE", 0x05881): (221, "StoreHandler1Map"), ("RO_SPACE", 0x05949): (221, "StoreHandler1Map"),
("RO_SPACE", 0x058d1): (221, "StoreHandler2Map"), ("RO_SPACE", 0x05999): (221, "StoreHandler2Map"),
("RO_SPACE", 0x05921): (221, "StoreHandler3Map"), ("RO_SPACE", 0x059e9): (221, "StoreHandler3Map"),
("MAP_SPACE", 0x00139): (1057, "ExternalMap"), ("MAP_SPACE", 0x00139): (1057, "ExternalMap"),
("MAP_SPACE", 0x00189): (1073, "JSMessageObjectMap"), ("MAP_SPACE", 0x00189): (1073, "JSMessageObjectMap"),
} }
......
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