Commit 2d436790 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Add quarter, dayPeriod and fractionalSecondDigits options

quarter option- see https://github.com/tc39/ecma402/pull/345
dayPeriod option- see https://github.com/tc39/ecma402/pull/346
fractionalSecondDigits option- see https://github.com/tc39/ecma402/pull/347
2019-6-5 TC39 presentation- http://shorturl.at/mtB12
test262: https://github.com/tc39/test262/pull/2194
I2I: http://shorturl.at/beCNV (for quarter)
I2I: http://shorturl.at/bekrZ (for dayPeriod)
I2I: http://shorturl.at/flwF5 (for fractionalSecondDigits)

Bug: v8:9282,v8:9283,v8:9284

Change-Id: I99f4c0f861507c7451497b735a276780bb8aead6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1621445
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62041}
parent 64ec1e48
......@@ -209,7 +209,13 @@ DEFINE_IMPLICATION(harmony_import_meta, harmony_dynamic_import)
V(harmony_weak_refs, "harmony weak references")
#ifdef V8_INTL_SUPPORT
#define HARMONY_INPROGRESS(V) HARMONY_INPROGRESS_BASE(V)
#define HARMONY_INPROGRESS(V) \
HARMONY_INPROGRESS_BASE(V) \
V(harmony_intl_dateformat_day_period, \
"Add dayPeriod option to DateTimeFormat") \
V(harmony_intl_dateformat_fractional_second_digits, \
"Add fractionalSecondDigits option to DateTimeFormat") \
V(harmony_intl_dateformat_quarter, "Add quarter option to DateTimeFormat")
#else
#define HARMONY_INPROGRESS(V) HARMONY_INPROGRESS_BASE(V)
#endif
......
......@@ -4236,6 +4236,10 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_hashbang)
#ifdef V8_INTL_SUPPORT
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_add_calendar_numbering_system)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_bigint)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_dateformat_day_period)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(
harmony_intl_dateformat_fractional_second_digits)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_dateformat_quarter)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_datetime_style)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_numberformat_unified)
#endif // V8_INTL_SUPPORT
......
......@@ -31,11 +31,13 @@
V(_, era_string, "era") \
V(_, first_string, "first") \
V(_, format_string, "format") \
V(_, fractionalSecond_string, "fractionalSecond") \
V(_, except_zero_string, "except-zero") \
V(_, exponentInteger_string, "exponentInteger") \
V(_, exponentMinusSign_string, "exponentMinusSign") \
V(_, exponentSeparator_string, "exponentSeparator") \
V(_, fraction_string, "fraction") \
V(_, fractionalSecondDigits_string, "fractionalSecondDigits") \
V(_, full_string, "full") \
V(_, granularity_string, "granularity") \
V(_, grapheme_string, "grapheme") \
......
......@@ -1117,8 +1117,10 @@ Maybe<int> DefaultNumberOption(Isolate* isolate, Handle<Object> value, int min,
return Just(FastD2I(floor(value_num->Number())));
}
} // namespace
// ecma402/#sec-getnumberoption
Maybe<int> GetNumberOption(Isolate* isolate, Handle<JSReceiver> options,
Maybe<int> Intl::GetNumberOption(Isolate* isolate, Handle<JSReceiver> options,
Handle<String> property, int min, int max,
int fallback) {
// 1. Let value be ? Get(options, property).
......@@ -1131,25 +1133,17 @@ Maybe<int> GetNumberOption(Isolate* isolate, Handle<JSReceiver> options,
return DefaultNumberOption(isolate, value, min, max, fallback, property);
}
Maybe<int> GetNumberOption(Isolate* isolate, Handle<JSReceiver> options,
const char* property, int min, int max,
int fallback) {
Handle<String> property_str =
isolate->factory()->NewStringFromAsciiChecked(property);
return GetNumberOption(isolate, options, property_str, min, max, fallback);
}
} // namespace
Maybe<Intl::NumberFormatDigitOptions> Intl::SetNumberFormatDigitOptions(
Isolate* isolate, Handle<JSReceiver> options, int mnfd_default,
int mxfd_default) {
Factory* factory = isolate->factory();
Intl::NumberFormatDigitOptions digit_options;
// 5. Let mnid be ? GetNumberOption(options, "minimumIntegerDigits,", 1, 21,
// 1).
int mnid;
if (!GetNumberOption(isolate, options, "minimumIntegerDigits", 1, 21, 1)
if (!Intl::GetNumberOption(isolate, options,
factory->minimumIntegerDigits_string(), 1, 21, 1)
.To(&mnid)) {
return Nothing<NumberFormatDigitOptions>();
}
......@@ -1157,7 +1151,8 @@ Maybe<Intl::NumberFormatDigitOptions> Intl::SetNumberFormatDigitOptions(
// 6. Let mnfd be ? GetNumberOption(options, "minimumFractionDigits", 0, 20,
// mnfdDefault).
int mnfd;
if (!GetNumberOption(isolate, options, "minimumFractionDigits", 0, 20,
if (!Intl::GetNumberOption(isolate, options,
factory->minimumFractionDigits_string(), 0, 20,
mnfd_default)
.To(&mnfd)) {
return Nothing<NumberFormatDigitOptions>();
......@@ -1169,7 +1164,8 @@ Maybe<Intl::NumberFormatDigitOptions> Intl::SetNumberFormatDigitOptions(
// 8. Let mxfd be ? GetNumberOption(options,
// "maximumFractionDigits", mnfd, 20, mxfdActualDefault).
int mxfd;
if (!GetNumberOption(isolate, options, "maximumFractionDigits", mnfd, 20,
if (!Intl::GetNumberOption(isolate, options,
factory->maximumFractionDigits_string(), mnfd, 20,
mxfd_actual_default)
.To(&mxfd)) {
return Nothing<NumberFormatDigitOptions>();
......@@ -1177,16 +1173,14 @@ Maybe<Intl::NumberFormatDigitOptions> Intl::SetNumberFormatDigitOptions(
// 9. Let mnsd be ? Get(options, "minimumSignificantDigits").
Handle<Object> mnsd_obj;
Handle<String> mnsd_str =
isolate->factory()->minimumSignificantDigits_string();
Handle<String> mnsd_str = factory->minimumSignificantDigits_string();
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, mnsd_obj, JSReceiver::GetProperty(isolate, options, mnsd_str),
Nothing<NumberFormatDigitOptions>());
// 10. Let mxsd be ? Get(options, "maximumSignificantDigits").
Handle<Object> mxsd_obj;
Handle<String> mxsd_str =
isolate->factory()->maximumSignificantDigits_string();
Handle<String> mxsd_str = factory->maximumSignificantDigits_string();
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, mxsd_obj, JSReceiver::GetProperty(isolate, options, mxsd_str),
Nothing<NumberFormatDigitOptions>());
......
......@@ -126,6 +126,10 @@ class Intl {
Isolate* isolate, Handle<JSReceiver> options, const char* property,
const char* service, bool* result);
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<int> GetNumberOption(
Isolate* isolate, Handle<JSReceiver> options, Handle<String> property,
int min, int max, int fallback);
// Canonicalize the locale.
// https://tc39.github.io/ecma402/#sec-canonicalizelanguagetag,
// including type check and structural validity check.
......
This diff is collapsed.
......@@ -286,51 +286,51 @@ KNOWN_MAPS = {
("read_only_space", 0x02371): (87, "EnumCacheMap"),
("read_only_space", 0x02411): (105, "ArrayBoilerplateDescriptionMap"),
("read_only_space", 0x02601): (90, "InterceptorInfoMap"),
("read_only_space", 0x04d99): (78, "AccessCheckInfoMap"),
("read_only_space", 0x04de9): (79, "AccessorInfoMap"),
("read_only_space", 0x04e39): (80, "AccessorPairMap"),
("read_only_space", 0x04e89): (81, "AliasedArgumentsEntryMap"),
("read_only_space", 0x04ed9): (82, "AllocationMementoMap"),
("read_only_space", 0x04f29): (83, "AsmWasmDataMap"),
("read_only_space", 0x04f79): (84, "AsyncGeneratorRequestMap"),
("read_only_space", 0x04fc9): (85, "ClassPositionsMap"),
("read_only_space", 0x05019): (86, "DebugInfoMap"),
("read_only_space", 0x05069): (88, "FunctionTemplateInfoMap"),
("read_only_space", 0x050b9): (89, "FunctionTemplateRareDataMap"),
("read_only_space", 0x05109): (91, "InterpreterDataMap"),
("read_only_space", 0x05159): (92, "ModuleInfoEntryMap"),
("read_only_space", 0x051a9): (93, "ModuleMap"),
("read_only_space", 0x051f9): (94, "ObjectTemplateInfoMap"),
("read_only_space", 0x05249): (95, "PromiseCapabilityMap"),
("read_only_space", 0x05299): (96, "PromiseReactionMap"),
("read_only_space", 0x052e9): (97, "PrototypeInfoMap"),
("read_only_space", 0x05339): (98, "ScriptMap"),
("read_only_space", 0x05389): (99, "SourcePositionTableWithFrameCacheMap"),
("read_only_space", 0x053d9): (100, "StackFrameInfoMap"),
("read_only_space", 0x05429): (101, "StackTraceFrameMap"),
("read_only_space", 0x05479): (102, "TemplateObjectDescriptionMap"),
("read_only_space", 0x054c9): (103, "Tuple2Map"),
("read_only_space", 0x05519): (104, "Tuple3Map"),
("read_only_space", 0x05569): (106, "WasmCapiFunctionDataMap"),
("read_only_space", 0x055b9): (107, "WasmDebugInfoMap"),
("read_only_space", 0x05609): (108, "WasmExceptionTagMap"),
("read_only_space", 0x05659): (109, "WasmExportedFunctionDataMap"),
("read_only_space", 0x056a9): (110, "WasmJSFunctionDataMap"),
("read_only_space", 0x056f9): (111, "CallableTaskMap"),
("read_only_space", 0x05749): (112, "CallbackTaskMap"),
("read_only_space", 0x05799): (113, "PromiseFulfillReactionJobTaskMap"),
("read_only_space", 0x057e9): (114, "PromiseRejectReactionJobTaskMap"),
("read_only_space", 0x05839): (115, "PromiseResolveThenableJobTaskMap"),
("read_only_space", 0x05889): (116, "FinalizationGroupCleanupJobTaskMap"),
("read_only_space", 0x058d9): (117, "AllocationSiteWithWeakNextMap"),
("read_only_space", 0x05929): (117, "AllocationSiteWithoutWeakNextMap"),
("read_only_space", 0x05979): (152, "LoadHandler1Map"),
("read_only_space", 0x059c9): (152, "LoadHandler2Map"),
("read_only_space", 0x05a19): (152, "LoadHandler3Map"),
("read_only_space", 0x05a69): (160, "StoreHandler0Map"),
("read_only_space", 0x05ab9): (160, "StoreHandler1Map"),
("read_only_space", 0x05b09): (160, "StoreHandler2Map"),
("read_only_space", 0x05b59): (160, "StoreHandler3Map"),
("read_only_space", 0x04de1): (78, "AccessCheckInfoMap"),
("read_only_space", 0x04e31): (79, "AccessorInfoMap"),
("read_only_space", 0x04e81): (80, "AccessorPairMap"),
("read_only_space", 0x04ed1): (81, "AliasedArgumentsEntryMap"),
("read_only_space", 0x04f21): (82, "AllocationMementoMap"),
("read_only_space", 0x04f71): (83, "AsmWasmDataMap"),
("read_only_space", 0x04fc1): (84, "AsyncGeneratorRequestMap"),
("read_only_space", 0x05011): (85, "ClassPositionsMap"),
("read_only_space", 0x05061): (86, "DebugInfoMap"),
("read_only_space", 0x050b1): (88, "FunctionTemplateInfoMap"),
("read_only_space", 0x05101): (89, "FunctionTemplateRareDataMap"),
("read_only_space", 0x05151): (91, "InterpreterDataMap"),
("read_only_space", 0x051a1): (92, "ModuleInfoEntryMap"),
("read_only_space", 0x051f1): (93, "ModuleMap"),
("read_only_space", 0x05241): (94, "ObjectTemplateInfoMap"),
("read_only_space", 0x05291): (95, "PromiseCapabilityMap"),
("read_only_space", 0x052e1): (96, "PromiseReactionMap"),
("read_only_space", 0x05331): (97, "PrototypeInfoMap"),
("read_only_space", 0x05381): (98, "ScriptMap"),
("read_only_space", 0x053d1): (99, "SourcePositionTableWithFrameCacheMap"),
("read_only_space", 0x05421): (100, "StackFrameInfoMap"),
("read_only_space", 0x05471): (101, "StackTraceFrameMap"),
("read_only_space", 0x054c1): (102, "TemplateObjectDescriptionMap"),
("read_only_space", 0x05511): (103, "Tuple2Map"),
("read_only_space", 0x05561): (104, "Tuple3Map"),
("read_only_space", 0x055b1): (106, "WasmCapiFunctionDataMap"),
("read_only_space", 0x05601): (107, "WasmDebugInfoMap"),
("read_only_space", 0x05651): (108, "WasmExceptionTagMap"),
("read_only_space", 0x056a1): (109, "WasmExportedFunctionDataMap"),
("read_only_space", 0x056f1): (110, "WasmJSFunctionDataMap"),
("read_only_space", 0x05741): (111, "CallableTaskMap"),
("read_only_space", 0x05791): (112, "CallbackTaskMap"),
("read_only_space", 0x057e1): (113, "PromiseFulfillReactionJobTaskMap"),
("read_only_space", 0x05831): (114, "PromiseRejectReactionJobTaskMap"),
("read_only_space", 0x05881): (115, "PromiseResolveThenableJobTaskMap"),
("read_only_space", 0x058d1): (116, "FinalizationGroupCleanupJobTaskMap"),
("read_only_space", 0x05921): (117, "AllocationSiteWithWeakNextMap"),
("read_only_space", 0x05971): (117, "AllocationSiteWithoutWeakNextMap"),
("read_only_space", 0x059c1): (152, "LoadHandler1Map"),
("read_only_space", 0x05a11): (152, "LoadHandler2Map"),
("read_only_space", 0x05a61): (152, "LoadHandler3Map"),
("read_only_space", 0x05ab1): (160, "StoreHandler0Map"),
("read_only_space", 0x05b01): (160, "StoreHandler1Map"),
("read_only_space", 0x05b51): (160, "StoreHandler2Map"),
("read_only_space", 0x05ba1): (160, "StoreHandler3Map"),
("map_space", 0x00139): (1057, "ExternalMap"),
("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