Commit 397caa92 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

[Intl] Install intrinsic default prototypes for Intl constructors

Install intrinsic default prototypes for Intl.ListFormat,
Intl.PluralRules, Intl.RelativeTimeFormat, and Intl.Segmenter.
Observable when attempting to construct cross-realm via a
new.target with a non-Object .prototype property.

Bug: v8:9712
Change-Id: I77ae75e5ea1ee8e9a01cf5788b664a5945aa1f7e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1801252Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63774}
parent 2afe87cd
......@@ -3024,6 +3024,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
JSPluralRules::kSize, 0, factory->the_hole_value(),
Builtins::kPluralRulesConstructor);
plural_rules_constructor->shared().DontAdaptArguments();
InstallWithIntrinsicDefaultProto(
isolate_, plural_rules_constructor,
Context::INTL_PLURAL_RULES_FUNCTION_INDEX);
SimpleInstallFunction(isolate(), plural_rules_constructor,
"supportedLocalesOf",
......@@ -3042,13 +3045,16 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kPluralRulesPrototypeSelect, 1, false);
}
{ // -- R e l a t i v e T i m e F o r m a t e
{ // -- R e l a t i v e T i m e F o r m a t
Handle<JSFunction> relative_time_format_fun = InstallFunction(
isolate(), intl, "RelativeTimeFormat",
JS_INTL_RELATIVE_TIME_FORMAT_TYPE, JSRelativeTimeFormat::kSize, 0,
factory->the_hole_value(), Builtins::kRelativeTimeFormatConstructor);
relative_time_format_fun->shared().set_length(0);
relative_time_format_fun->shared().DontAdaptArguments();
InstallWithIntrinsicDefaultProto(
isolate_, relative_time_format_fun,
Context::INTL_RELATIVE_TIME_FORMAT_FUNCTION_INDEX);
SimpleInstallFunction(
isolate(), relative_time_format_fun, "supportedLocalesOf",
......@@ -3079,6 +3085,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kListFormatConstructor);
list_format_fun->shared().set_length(0);
list_format_fun->shared().DontAdaptArguments();
InstallWithIntrinsicDefaultProto(
isolate_, list_format_fun, Context::INTL_LIST_FORMAT_FUNCTION_INDEX);
SimpleInstallFunction(isolate(), list_format_fun, "supportedLocalesOf",
Builtins::kListFormatSupportedLocalesOf, 1, false);
......@@ -4454,6 +4462,8 @@ void Genesis::InitializeGlobal_harmony_intl_segmenter() {
0, factory()->the_hole_value(), Builtins::kSegmenterConstructor);
segmenter_fun->shared().set_length(0);
segmenter_fun->shared().DontAdaptArguments();
InstallWithIntrinsicDefaultProto(isolate_, segmenter_fun,
Context::INTL_SEGMENTER_FUNCTION_INDEX);
SimpleInstallFunction(isolate(), segmenter_fun, "supportedLocalesOf",
Builtins::kSegmenterSupportedLocalesOf, 1, false);
......
......@@ -159,6 +159,11 @@ enum ContextLookupFlags {
V(INTL_NUMBER_FORMAT_FUNCTION_INDEX, JSFunction, \
intl_number_format_function) \
V(INTL_LOCALE_FUNCTION_INDEX, JSFunction, intl_locale_function) \
V(INTL_LIST_FORMAT_FUNCTION_INDEX, JSFunction, intl_list_format_function) \
V(INTL_PLURAL_RULES_FUNCTION_INDEX, JSFunction, intl_plural_rules_function) \
V(INTL_RELATIVE_TIME_FORMAT_FUNCTION_INDEX, JSFunction, \
intl_relative_time_format_function) \
V(INTL_SEGMENTER_FUNCTION_INDEX, JSFunction, intl_segmenter_function) \
V(INTL_SEGMENT_ITERATOR_MAP_INDEX, Map, intl_segment_iterator_map) \
V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \
V(JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX, Map, \
......
......@@ -792,9 +792,6 @@
'language/statements/class/ident-name-method-def-while-escaped': [FAIL],
'language/statements/class/ident-name-method-def-with-escaped': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=9712
'intl402/PluralRules/proto-from-ctor-realm': [FAIL],
######################## NEEDS INVESTIGATION ###########################
# https://bugs.chromium.org/p/v8/issues/detail?id=7833
......
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