Commit c9c3ec4c authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[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 <ftang@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71653}
parent ed4914d3
......@@ -287,9 +287,7 @@ 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) \
V(harmony_intl_segmenter, "Intl.Segmenter")
#define HARMONY_SHIPPING(V) HARMONY_SHIPPING_BASE(V)
#else
#define HARMONY_SHIPPING(V) HARMONY_SHIPPING_BASE(V)
#endif
......
......@@ -3182,6 +3182,87 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kDisplayNamesPrototypeOf, 1, false);
}
}
{ // -- S e g m e n t e r
Handle<JSFunction> 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<JSObject> 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<JSObject> prototype = factory->NewJSObject(
isolate()->object_function(), AllocationType::kOld);
Handle<String> name_string =
Name::ToFunctionName(isolate(), factory->Segments_string())
.ToHandleChecked();
Handle<JSFunction> 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<Map> segments_map(segments_fun->initial_map(), isolate());
native_context()->set_intl_segments_map(*segments_map);
}
{
// Setup %SegmentIteratorPrototype%.
Handle<JSObject> iterator_prototype(
native_context()->initial_iterator_prototype(), isolate());
Handle<JSObject> 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<String> name_string =
Name::ToFunctionName(isolate(), factory->SegmentIterator_string())
.ToHandleChecked();
Handle<JSFunction> 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<Map> segment_iterator_map(segment_iterator_fun->initial_map(),
isolate());
native_context()->set_intl_segment_iterator_map(*segment_iterator_map);
}
}
}
#endif // V8_INTL_SUPPORT
......@@ -4436,113 +4517,6 @@ void Genesis::InitializeGlobal_harmony_relative_indexing_methods() {
}
}
#ifdef V8_INTL_SUPPORT
void Genesis::InitializeGlobal_harmony_intl_segmenter() {
if (!FLAG_harmony_intl_segmenter) return;
Handle<JSObject> intl = Handle<JSObject>::cast(
JSReceiver::GetProperty(
isolate(),
Handle<JSReceiver>(native_context()->global_object(), isolate()),
factory()->InternalizeUtf8String("Intl"))
.ToHandleChecked());
Handle<JSFunction> 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<JSObject> 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<JSObject> prototype = factory()->NewJSObject(
isolate()->object_function(), AllocationType::kOld);
Handle<String> name_string =
Name::ToFunctionName(isolate(), isolate()->factory()->Segments_string())
.ToHandleChecked();
Handle<JSFunction> 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<Map> segments_map(segments_fun->initial_map(), isolate());
native_context()->set_intl_segments_map(*segments_map);
}
{
// Setup %SegmentIteratorPrototype%.
Handle<JSObject> iterator_prototype(
native_context()->initial_iterator_prototype(), isolate());
Handle<JSObject> 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<String> name_string =
Name::ToFunctionName(isolate(),
isolate()->factory()->SegmentIterator_string())
.ToHandleChecked();
Handle<JSFunction> 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<Map> segment_iterator_map(segment_iterator_fun->initial_map(),
isolate());
native_context()->set_intl_segment_iterator_map(*segment_iterator_map);
}
}
#endif // V8_INTL_SUPPORT
Handle<JSFunction> Genesis::CreateArrayBuffer(
Handle<String> name, ArrayBufferKind array_buffer_kind) {
// Create the %ArrayBufferPrototype%
......
......@@ -27,8 +27,6 @@
// Tests supportedLocalesOf method.
// Flags: --harmony-intl-segmenter
var services = [
Intl.Collator,
Intl.DateTimeFormat,
......
......@@ -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: --harmony-intl-segmenter --expose-gc
// Flags: --expose-gc
let segmenter = new Intl.Segmenter();
let segments = segmenter.segment(undefined);
......
......@@ -2,8 +2,6 @@
// 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);
......@@ -2,8 +2,6 @@
// 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",
......
......@@ -2,8 +2,6 @@
// 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.
......
......@@ -2,8 +2,6 @@
// 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);
......
......@@ -2,8 +2,6 @@
// 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 =
......
......@@ -2,8 +2,6 @@
// 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();
......
......@@ -2,8 +2,6 @@
// 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();
......
......@@ -2,8 +2,6 @@
// 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
......
......@@ -2,8 +2,6 @@
// 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");
......
......@@ -2,8 +2,6 @@
// 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
......
......@@ -2,8 +2,6 @@
// 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
......
......@@ -2,8 +2,6 @@
// 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);
......
......@@ -2,8 +2,6 @@
// 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) {
......
// 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",
......
......@@ -2,8 +2,6 @@
// 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 =
......
......@@ -44,9 +44,7 @@ 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',
......
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