From 371d7dbcc35771eddb083f8643836076f9955818 Mon Sep 17 00:00:00 2001 From: Clemens Backes Date: Tue, 8 Dec 2020 13:25:40 +0000 Subject: [PATCH] Revert "[intl] Clean up intl_segmenter flag" This reverts commit c9c3ec4c14868e7cd1554b1a273f5aebb6bc4052. Reason for revert: Speculative revert for https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Linux64%20GC%20Stress%20-%20custom%20snapshot/34616/overview (looks unrelated, but fails consistently since this CL) Original change's description: > [intl] Clean up intl_segmenter flag > > Intl.Segmenter shipped in m87 and launched. > > Bug: v8:11225 > Change-Id: I4213e261e1aea717c1281f19785a8c29ff1bbd8b > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2570461 > Commit-Queue: Frank Tang > Reviewed-by: Shu-yu Guo > Cr-Commit-Position: refs/heads/master@{#71653} TBR=jkummerow@chromium.org,ftang@chromium.org,syg@chromium.org Change-Id: Ic1d1b02abb9ae7faa41307eee694bb7e40d0fae2 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:11225 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2578979 Reviewed-by: Clemens Backes Commit-Queue: Clemens Backes Cr-Commit-Position: refs/heads/master@{#71657} --- src/flags/flag-definitions.h | 4 +- src/init/bootstrapper.cc | 188 ++++++++++-------- test/intl/general/supported-locales-of.js | 2 + test/intl/regress-1121156.js | 2 +- test/intl/regress-900013.js | 2 + test/intl/segmenter/check-lb-option.js | 2 + test/intl/segmenter/constructor-order.js | 2 + test/intl/segmenter/constructor.js | 2 + test/intl/segmenter/grapheme-containing.js | 2 + test/intl/segmenter/grapheme-nested-next.js | 2 + .../grapheme-next-after-containing.js | 2 + test/intl/segmenter/segment-grapheme.js | 2 + .../segment-iterator-ownPropertyDescriptor.js | 2 + test/intl/segmenter/segment-sentence.js | 2 + test/intl/segmenter/segment-word.js | 2 + test/intl/segmenter/segment.js | 2 + test/intl/segmenter/subclassing.js | 2 + test/intl/segmenter/supported-locale.js | 2 + test/intl/segmenter/word-containing.js | 2 + test/test262/testcfg.py | 2 + 20 files changed, 145 insertions(+), 83 deletions(-) diff --git a/src/flags/flag-definitions.h b/src/flags/flag-definitions.h index 2208ff71e6..a02cd921ee 100644 --- a/src/flags/flag-definitions.h +++ b/src/flags/flag-definitions.h @@ -287,7 +287,9 @@ DEFINE_IMPLICATION(harmony_weak_refs_with_cleanup_some, harmony_weak_refs) V(harmony_relative_indexing_methods, "harmony relative indexing methods") #ifdef V8_INTL_SUPPORT -#define HARMONY_SHIPPING(V) HARMONY_SHIPPING_BASE(V) +#define HARMONY_SHIPPING(V) \ + HARMONY_SHIPPING_BASE(V) \ + V(harmony_intl_segmenter, "Intl.Segmenter") #else #define HARMONY_SHIPPING(V) HARMONY_SHIPPING_BASE(V) #endif diff --git a/src/init/bootstrapper.cc b/src/init/bootstrapper.cc index 512f6ac64f..65b49e26e4 100644 --- a/src/init/bootstrapper.cc +++ b/src/init/bootstrapper.cc @@ -3182,87 +3182,6 @@ void Genesis::InitializeGlobal(Handle global_object, Builtins::kDisplayNamesPrototypeOf, 1, false); } } - - { // -- S e g m e n t e r - Handle segmenter_fun = InstallFunction( - isolate(), intl, "Segmenter", JS_SEGMENTER_TYPE, - JSSegmenter::kHeaderSize, 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); - { - // Setup %SegmenterPrototype%. - Handle prototype( - JSObject::cast(segmenter_fun->instance_prototype()), isolate()); - // #sec-intl.segmenter.prototype-@@tostringtag - // - // Intl.Segmenter.prototype [ @@toStringTag ] - // - // The initial value of the @@toStringTag property is the String value - // "Intl.Segmenter". - InstallToStringTag(isolate(), prototype, "Intl.Segmenter"); - SimpleInstallFunction(isolate(), prototype, "resolvedOptions", - Builtins::kSegmenterPrototypeResolvedOptions, 0, - false); - SimpleInstallFunction(isolate(), prototype, "segment", - Builtins::kSegmenterPrototypeSegment, 1, false); - } - { - // Setup %SegmentsPrototype%. - Handle prototype = factory->NewJSObject( - isolate()->object_function(), AllocationType::kOld); - Handle name_string = - Name::ToFunctionName(isolate(), factory->Segments_string()) - .ToHandleChecked(); - Handle segments_fun = CreateFunction( - isolate(), name_string, JS_SEGMENTS_TYPE, JSSegments::kHeaderSize, - 0, prototype, Builtins::kIllegal); - segments_fun->shared().set_native(false); - segments_fun->shared().set_length(0); - segments_fun->shared().DontAdaptArguments(); - SimpleInstallFunction(isolate(), prototype, "containing", - Builtins::kSegmentsPrototypeContaining, 1, false); - InstallFunctionAtSymbol(isolate_, prototype, factory->iterator_symbol(), - "[Symbol.iterator]", - Builtins::kSegmentsPrototypeIterator, 0, true, - DONT_ENUM); - Handle segments_map(segments_fun->initial_map(), isolate()); - native_context()->set_intl_segments_map(*segments_map); - } - { - // Setup %SegmentIteratorPrototype%. - Handle iterator_prototype( - native_context()->initial_iterator_prototype(), isolate()); - Handle prototype = factory->NewJSObject( - isolate()->object_function(), AllocationType::kOld); - JSObject::ForceSetPrototype(prototype, iterator_prototype); - // #sec-%segmentiteratorprototype%.@@tostringtag - // - // %SegmentIteratorPrototype% [ @@toStringTag ] - // - // The initial value of the @@toStringTag property is the String value - // "Segmenter String Iterator". - InstallToStringTag(isolate(), prototype, "Segmenter String Iterator"); - SimpleInstallFunction(isolate(), prototype, "next", - Builtins::kSegmentIteratorPrototypeNext, 0, - false); - // Setup SegmentIterator constructor. - Handle name_string = - Name::ToFunctionName(isolate(), factory->SegmentIterator_string()) - .ToHandleChecked(); - Handle segment_iterator_fun = CreateFunction( - isolate(), name_string, JS_SEGMENT_ITERATOR_TYPE, - JSSegmentIterator::kHeaderSize, 0, prototype, Builtins::kIllegal); - segment_iterator_fun->shared().set_native(false); - Handle segment_iterator_map(segment_iterator_fun->initial_map(), - isolate()); - native_context()->set_intl_segment_iterator_map(*segment_iterator_map); - } - } } #endif // V8_INTL_SUPPORT @@ -4517,6 +4436,113 @@ void Genesis::InitializeGlobal_harmony_relative_indexing_methods() { } } +#ifdef V8_INTL_SUPPORT + +void Genesis::InitializeGlobal_harmony_intl_segmenter() { + if (!FLAG_harmony_intl_segmenter) return; + Handle intl = Handle::cast( + JSReceiver::GetProperty( + isolate(), + Handle(native_context()->global_object(), isolate()), + factory()->InternalizeUtf8String("Intl")) + .ToHandleChecked()); + + Handle segmenter_fun = InstallFunction( + isolate(), intl, "Segmenter", JS_SEGMENTER_TYPE, JSSegmenter::kHeaderSize, + 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); + + { + // Setup %SegmenterPrototype%. + Handle prototype( + JSObject::cast(segmenter_fun->instance_prototype()), isolate()); + + // #sec-intl.segmenter.prototype-@@tostringtag + // + // Intl.Segmenter.prototype [ @@toStringTag ] + // + // The initial value of the @@toStringTag property is the String value + // "Intl.Segmenter". + InstallToStringTag(isolate(), prototype, "Intl.Segmenter"); + + SimpleInstallFunction(isolate(), prototype, "resolvedOptions", + Builtins::kSegmenterPrototypeResolvedOptions, 0, + false); + + SimpleInstallFunction(isolate(), prototype, "segment", + Builtins::kSegmenterPrototypeSegment, 1, false); + } + + { + // Setup %SegmentsPrototype%. + Handle prototype = factory()->NewJSObject( + isolate()->object_function(), AllocationType::kOld); + + Handle name_string = + Name::ToFunctionName(isolate(), isolate()->factory()->Segments_string()) + .ToHandleChecked(); + Handle segments_fun = CreateFunction( + isolate(), name_string, JS_SEGMENTS_TYPE, JSSegments::kHeaderSize, 0, + prototype, Builtins::kIllegal); + segments_fun->shared().set_native(false); + segments_fun->shared().set_length(0); + segments_fun->shared().DontAdaptArguments(); + + SimpleInstallFunction(isolate(), prototype, "containing", + Builtins::kSegmentsPrototypeContaining, 1, false); + + InstallFunctionAtSymbol( + isolate_, prototype, factory()->iterator_symbol(), "[Symbol.iterator]", + Builtins::kSegmentsPrototypeIterator, 0, true, DONT_ENUM); + + Handle segments_map(segments_fun->initial_map(), isolate()); + native_context()->set_intl_segments_map(*segments_map); + } + + { + // Setup %SegmentIteratorPrototype%. + Handle iterator_prototype( + native_context()->initial_iterator_prototype(), isolate()); + + Handle prototype = factory()->NewJSObject( + isolate()->object_function(), AllocationType::kOld); + JSObject::ForceSetPrototype(prototype, iterator_prototype); + + // #sec-%segmentiteratorprototype%.@@tostringtag + // + // %SegmentIteratorPrototype% [ @@toStringTag ] + // + // The initial value of the @@toStringTag property is the String value + // "Segmenter String Iterator". + InstallToStringTag(isolate(), prototype, "Segmenter String Iterator"); + + SimpleInstallFunction(isolate(), prototype, "next", + Builtins::kSegmentIteratorPrototypeNext, 0, false); + + // Setup SegmentIterator constructor. + Handle name_string = + Name::ToFunctionName(isolate(), + isolate()->factory()->SegmentIterator_string()) + .ToHandleChecked(); + Handle segment_iterator_fun = CreateFunction( + isolate(), name_string, JS_SEGMENT_ITERATOR_TYPE, + JSSegmentIterator::kHeaderSize, 0, prototype, Builtins::kIllegal); + segment_iterator_fun->shared().set_native(false); + + Handle segment_iterator_map(segment_iterator_fun->initial_map(), + isolate()); + native_context()->set_intl_segment_iterator_map(*segment_iterator_map); + } +} + +#endif // V8_INTL_SUPPORT + Handle Genesis::CreateArrayBuffer( Handle name, ArrayBufferKind array_buffer_kind) { // Create the %ArrayBufferPrototype% diff --git a/test/intl/general/supported-locales-of.js b/test/intl/general/supported-locales-of.js index 05c75c2b0b..aeb5f328e7 100644 --- a/test/intl/general/supported-locales-of.js +++ b/test/intl/general/supported-locales-of.js @@ -27,6 +27,8 @@ // Tests supportedLocalesOf method. +// Flags: --harmony-intl-segmenter + var services = [ Intl.Collator, Intl.DateTimeFormat, diff --git a/test/intl/regress-1121156.js b/test/intl/regress-1121156.js index 75c02b4b70..cf0f245c3a 100644 --- a/test/intl/regress-1121156.js +++ b/test/intl/regress-1121156.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-gc +// Flags: --harmony-intl-segmenter --expose-gc let segmenter = new Intl.Segmenter(); let segments = segmenter.segment(undefined); diff --git a/test/intl/regress-900013.js b/test/intl/regress-900013.js index 55b168d369..c7cdc65895 100644 --- a/test/intl/regress-900013.js +++ b/test/intl/regress-900013.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + // Regression test to ensure no Intl["SegmentIterator"] assertThrows(() => new Intl["SegmentIterator"](), TypeError); diff --git a/test/intl/segmenter/check-lb-option.js b/test/intl/segmenter/check-lb-option.js index b214c66412..0e54d18202 100644 --- a/test/intl/segmenter/check-lb-option.js +++ b/test/intl/segmenter/check-lb-option.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + let invalid_lb = [ "invalid", "abce", diff --git a/test/intl/segmenter/constructor-order.js b/test/intl/segmenter/constructor-order.js index 67f6681c8c..e43fb9f963 100644 --- a/test/intl/segmenter/constructor-order.js +++ b/test/intl/segmenter/constructor-order.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + // Throws only once during construction. // Check for all getters to prevent regression. // Preserve the order of getter initialization. diff --git a/test/intl/segmenter/constructor.js b/test/intl/segmenter/constructor.js index 7cf8243056..6612e1eab6 100644 --- a/test/intl/segmenter/constructor.js +++ b/test/intl/segmenter/constructor.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + // Segmenter constructor can't be called as function. assertThrows(() => Intl.Segmenter(["sr"]), TypeError); diff --git a/test/intl/segmenter/grapheme-containing.js b/test/intl/segmenter/grapheme-containing.js index 6464c2224e..193a26e601 100644 --- a/test/intl/segmenter/grapheme-containing.js +++ b/test/intl/segmenter/grapheme-containing.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + const segmenter = new Intl.Segmenter(); const waving_hand_light_skin_tone = "\uD83D\uDC4B\uD83C\uDFFB"; const man_light_skin_tone_red_hair = diff --git a/test/intl/segmenter/grapheme-nested-next.js b/test/intl/segmenter/grapheme-nested-next.js index 022ed2303c..21be34326f 100644 --- a/test/intl/segmenter/grapheme-nested-next.js +++ b/test/intl/segmenter/grapheme-nested-next.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + // Test to ensure the nested calling of the next method won't caused // confusion to each other. const segmenter = new Intl.Segmenter(); diff --git a/test/intl/segmenter/grapheme-next-after-containing.js b/test/intl/segmenter/grapheme-next-after-containing.js index aec1f9db03..5ad97f6810 100644 --- a/test/intl/segmenter/grapheme-next-after-containing.js +++ b/test/intl/segmenter/grapheme-next-after-containing.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + // Test to ensure the calling of containing() won't impact the calling of // the next() method. const segmenter = new Intl.Segmenter(); diff --git a/test/intl/segmenter/segment-grapheme.js b/test/intl/segmenter/segment-grapheme.js index f36aafe955..3e28142e64 100644 --- a/test/intl/segmenter/segment-grapheme.js +++ b/test/intl/segmenter/segment-grapheme.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + const seg = new Intl.Segmenter([], {granularity: "grapheme"}) for (const text of [ "Hello world!", // English diff --git a/test/intl/segmenter/segment-iterator-ownPropertyDescriptor.js b/test/intl/segmenter/segment-iterator-ownPropertyDescriptor.js index 2626f8cac0..2aba164c05 100644 --- a/test/intl/segmenter/segment-iterator-ownPropertyDescriptor.js +++ b/test/intl/segmenter/segment-iterator-ownPropertyDescriptor.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + let seg = new Intl.Segmenter(); let descriptor = Object.getOwnPropertyDescriptor( Intl.Segmenter, "supportedLocalesOf"); diff --git a/test/intl/segmenter/segment-sentence.js b/test/intl/segmenter/segment-sentence.js index aa70953c85..6bfcebd2b4 100644 --- a/test/intl/segmenter/segment-sentence.js +++ b/test/intl/segmenter/segment-sentence.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + const seg = new Intl.Segmenter([], {granularity: "sentence"}) for (const text of [ "Hello world!", // English diff --git a/test/intl/segmenter/segment-word.js b/test/intl/segmenter/segment-word.js index 4961baf0e0..c2919e5911 100644 --- a/test/intl/segmenter/segment-word.js +++ b/test/intl/segmenter/segment-word.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + const seg = new Intl.Segmenter([], {granularity: "word"}) for (const text of [ "Hello world!", // English diff --git a/test/intl/segmenter/segment.js b/test/intl/segmenter/segment.js index 25f3244ea7..a4c44f3452 100644 --- a/test/intl/segmenter/segment.js +++ b/test/intl/segmenter/segment.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + assertEquals("function", typeof Intl.Segmenter.prototype.segment); assertEquals(1, Intl.Segmenter.prototype.segment.length); diff --git a/test/intl/segmenter/subclassing.js b/test/intl/segmenter/subclassing.js index 69db0aaf92..2bea1e88ce 100644 --- a/test/intl/segmenter/subclassing.js +++ b/test/intl/segmenter/subclassing.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + // Test subclassing of Segmenter class CustomSegmenter extends Intl.Segmenter { constructor(locales, options) { diff --git a/test/intl/segmenter/supported-locale.js b/test/intl/segmenter/supported-locale.js index b09832a04d..b1a0353156 100644 --- a/test/intl/segmenter/supported-locale.js +++ b/test/intl/segmenter/supported-locale.js @@ -1,6 +1,8 @@ // Copyright 2018 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. + +// Flags: --harmony-intl-segmenter assertEquals( typeof Intl.Segmenter.supportedLocalesOf, "function", diff --git a/test/intl/segmenter/word-containing.js b/test/intl/segmenter/word-containing.js index b6e43d3d7d..8c68eed373 100644 --- a/test/intl/segmenter/word-containing.js +++ b/test/intl/segmenter/word-containing.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-intl-segmenter + const segmenter = new Intl.Segmenter(undefined, {granularity: 'word'}); const waving_hand_light_skin_tone = "\uD83D\uDC4B\uD83C\uDFFB"; const man_light_skin_tone_red_hair = diff --git a/test/test262/testcfg.py b/test/test262/testcfg.py index 24e02607d6..76314c0449 100644 --- a/test/test262/testcfg.py +++ b/test/test262/testcfg.py @@ -44,7 +44,9 @@ from testrunner.outproc import test262 # TODO(littledan): move the flag mapping into the status file FEATURE_FLAGS = { + 'Intl.Segmenter': '--harmony-intl-segmenter', 'Intl.DateTimeFormat-dayPeriod': '--harmony-intl-dateformat-day-period', + 'Intl.DateTimeFormat-quarter': '--harmony-intl-dateformat-quarter', 'String.prototype.replaceAll': '--harmony_string_replaceall', 'Symbol.prototype.description': '--harmony-symbol-description', 'FinalizationRegistry': '--harmony-weak-refs-with-cleanup-some',