Commit 4274d2f1 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] add Intl.Segmenter - part 1

Add the JSSegmenter and hook up constructor,
supportedLocales and resolvedOptions only
Desgin Doc- https://goo.gl/fgc2Cp

TBR: bmeurer@chromium.org
Bug: v8:6891
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Ief25fb31d724c55c43c0fdf3080294fa83486e4f
Reviewed-on: https://chromium-review.googlesource.com/c/1247362
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56393}
parent 8f65ce3b
......@@ -2249,6 +2249,9 @@ v8_source_set("v8_base") {
"src/objects/js-relative-time-format-inl.h",
"src/objects/js-relative-time-format.cc",
"src/objects/js-relative-time-format.h",
"src/objects/js-segmenter-inl.h",
"src/objects/js-segmenter.cc",
"src/objects/js-segmenter.h",
"src/objects/literal-objects-inl.h",
"src/objects/literal-objects.cc",
"src/objects/literal-objects.h",
......@@ -2970,6 +2973,9 @@ v8_source_set("v8_base") {
"src/objects/js-relative-time-format-inl.h",
"src/objects/js-relative-time-format.cc",
"src/objects/js-relative-time-format.h",
"src/objects/js-segmenter-inl.h",
"src/objects/js-segmenter.cc",
"src/objects/js-segmenter.h",
"src/runtime/runtime-intl.cc",
]
}
......
......@@ -42,6 +42,7 @@
#include "src/objects/js-regexp.h"
#ifdef V8_INTL_SUPPORT
#include "src/objects/js-relative-time-format.h"
#include "src/objects/js-segmenter.h"
#endif // V8_INTL_SUPPORT
#include "src/objects/templates.h"
#include "src/snapshot/natives.h"
......@@ -4738,6 +4739,37 @@ void Genesis::InitializeGlobal_harmony_intl_relative_time_format() {
false);
}
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_INTL_SEGMENTER_TYPE, JSSegmenter::kSize,
0, factory()->the_hole_value(), Builtins::kSegmenterConstructor);
segmenter_fun->shared()->set_length(0);
segmenter_fun->shared()->DontAdaptArguments();
SimpleInstallFunction(isolate(), segmenter_fun, "supportedLocalesOf",
Builtins::kSegmenterSupportedLocalesOf, 1, false);
// Setup %SegmenterPrototype%.
Handle<JSObject> prototype(
JSObject::cast(segmenter_fun->instance_prototype()), isolate());
// Install the @@toStringTag property on the {prototype}.
JSObject::AddProperty(isolate(), prototype, factory()->to_string_tag_symbol(),
factory()->NewStringFromStaticChars("Intl.Segmenter"),
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
SimpleInstallFunction(isolate(), prototype, "resolvedOptions",
Builtins::kSegmenterPrototypeResolvedOptions, 0, false);
}
#endif // V8_INTL_SUPPORT
Handle<JSFunction> Genesis::CreateArrayBuffer(
......
......@@ -1436,6 +1436,12 @@ namespace internal {
/* ES #sec-string.prototype.touppercase */ \
CPP(StringPrototypeToUpperCaseIntl) \
TFS(StringToLowerCaseIntl, kString) \
/* ecma402 #sec-Intl.Segmenter */ \
CPP(SegmenterConstructor) \
/* ecma402 #sec-Intl.Segmenter.prototype.resolvedOptions */ \
CPP(SegmenterPrototypeResolvedOptions) \
/* ecma402 #sec-Intl.Segmenter.supportedLocalesOf */ \
CPP(SegmenterSupportedLocalesOf) \
CPP(V8BreakIteratorConstructor) \
CPP(V8BreakIteratorInternalAdoptText) \
CPP(V8BreakIteratorInternalBreakType) \
......
......@@ -26,6 +26,7 @@
#include "src/objects/js-number-format-inl.h"
#include "src/objects/js-plural-rules-inl.h"
#include "src/objects/js-relative-time-format-inl.h"
#include "src/objects/js-segmenter-inl.h"
#include "src/property-descriptor.h"
#include "unicode/datefmt.h"
......@@ -995,6 +996,51 @@ BUILTIN(CollatorInternalCompare) {
return *Intl::CompareStrings(isolate, collator_holder, string_x, string_y);
}
BUILTIN(SegmenterConstructor) {
HandleScope scope(isolate);
isolate->CountUsage(v8::Isolate::UseCounterFeature::kSegmenter);
// 1. If NewTarget is undefined, throw a TypeError exception.
if (args.new_target()->IsUndefined(isolate)) { // [[Call]]
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kConstructorNotFunction,
isolate->factory()->NewStringFromStaticChars(
"Intl.Segmenter")));
}
// [[Construct]]
Handle<JSFunction> target = args.target();
Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
Handle<JSObject> result;
// 2. Let segmenter be OrdinaryCreateFromConstructor(NewTarget,
// "%SegmenterPrototype%").
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
JSObject::New(target, new_target, Handle<AllocationSite>::null()));
Handle<JSSegmenter> segmenter = Handle<JSSegmenter>::cast(result);
segmenter->set_flags(0);
Handle<Object> locales = args.atOrUndefined(isolate, 1);
Handle<Object> options = args.atOrUndefined(isolate, 2);
RETURN_RESULT_OR_FAILURE(
isolate, JSSegmenter::Initialize(isolate, segmenter, locales, options));
}
BUILTIN(SegmenterSupportedLocalesOf) {
HandleScope scope(isolate);
RETURN_RESULT_OR_FAILURE(
isolate, SupportedLocalesOfCommon(isolate, "segmenter", args));
}
BUILTIN(SegmenterPrototypeResolvedOptions) {
HandleScope scope(isolate);
CHECK_RECEIVER(JSSegmenter, segmenter_holder,
"Intl.Segmenter.prototype.resolvedOptions");
return *JSSegmenter::ResolvedOptions(isolate, segmenter_holder);
}
BUILTIN(V8BreakIteratorConstructor) {
HandleScope scope(isolate);
Handle<JSReceiver> new_target;
......
......@@ -42,6 +42,7 @@ class JSNumberFormat;
class JSPluralRules;
class JSRegExpStringIterator;
class JSRelativeTimeFormat;
class JSSegmenter;
class JSV8BreakIterator;
class JSWeakCollection;
class JSWeakMap;
......
......@@ -218,6 +218,7 @@ Type::bitset BitsetType::Lub(const MapRefLike& map) {
case JS_INTL_NUMBER_FORMAT_TYPE:
case JS_INTL_PLURAL_RULES_TYPE:
case JS_INTL_RELATIVE_TIME_FORMAT_TYPE:
case JS_INTL_SEGMENTER_TYPE:
#endif // V8_INTL_SUPPORT
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
case JS_GENERATOR_OBJECT_TYPE:
......
......@@ -216,10 +216,11 @@ DEFINE_IMPLICATION(harmony_class_fields, harmony_private_fields)
V(harmony_regexp_sequence, "RegExp Unicode sequence properties")
#ifdef V8_INTL_SUPPORT
#define HARMONY_INPROGRESS(V) \
HARMONY_INPROGRESS_BASE(V) \
V(harmony_locale, "Intl.Locale") \
V(harmony_intl_list_format, "Intl.ListFormat")
#define HARMONY_INPROGRESS(V) \
HARMONY_INPROGRESS_BASE(V) \
V(harmony_locale, "Intl.Locale") \
V(harmony_intl_list_format, "Intl.ListFormat") \
V(harmony_intl_segmenter, "Intl.Segmenter")
#else
#define HARMONY_INPROGRESS(V) HARMONY_INPROGRESS_BASE(V)
#endif
......
......@@ -101,6 +101,8 @@
V(_, getPrototypeOf_string, "getPrototypeOf") \
V(_, global_string, "global") \
V(_, globalThis_string, "globalThis") \
V(_, granularity_string, "granularity") \
V(_, grapheme_string, "grapheme") \
V(_, group_string, "group") \
V(_, groups_string, "groups") \
V(_, has_string, "has") \
......@@ -125,11 +127,13 @@
V(_, lastIndex_string, "lastIndex") \
V(_, length_string, "length") \
V(_, let_string, "let") \
V(_, lineBreakStyle_string, "lineBreakStyle") \
V(_, line_string, "line") \
V(_, LinkError_string, "LinkError") \
V(_, literal_string, "literal") \
V(_, locale_string, "locale") \
V(_, long_string, "long") \
V(_, loose_string, "loose") \
V(_, Map_string, "Map") \
V(_, MapIterator_string, "Map Iterator") \
V(_, maximumFractionDigits_string, "maximumFractionDigits") \
......@@ -157,6 +161,7 @@
V(_, NFKC_string, "NFKC") \
V(_, NFKD_string, "NFKD") \
V(_, not_equal, "not-equal") \
V(_, normal_string, "normal") \
V(_, null_string, "null") \
V(_, null_to_string, "[object Null]") \
V(_, Number_string, "Number") \
......@@ -213,6 +218,7 @@
V(_, stackTraceLimit_string, "stackTraceLimit") \
V(_, star_default_star_string, "*default*") \
V(_, sticky_string, "sticky") \
V(_, strict_string, "strict") \
V(_, String_string, "String") \
V(_, string_string, "string") \
V(_, string_to_string, "[object String]") \
......
......@@ -31,7 +31,8 @@ enum class IcuService {
kPluralRules,
kResourceBundle,
kRelativeDateTimeFormatter,
kListFormatter
kListFormatter,
kSegmenter
};
const UChar* GetUCharBufferFromFlat(const String::FlatContent& flat,
......
......@@ -57,6 +57,7 @@ var AVAILABLE_LOCALES = {
'pluralrules': UNDEFINED,
'relativetimeformat': UNDEFINED,
'listformat': UNDEFINED,
'segmenter': UNDEFINED,
};
/**
......
......@@ -810,6 +810,7 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
case JS_INTL_NUMBER_FORMAT_TYPE:
case JS_INTL_PLURAL_RULES_TYPE:
case JS_INTL_RELATIVE_TIME_FORMAT_TYPE:
case JS_INTL_SEGMENTER_TYPE:
#endif // V8_INTL_SUPPORT
case WASM_EXCEPTION_TYPE:
case WASM_GLOBAL_TYPE:
......
......@@ -38,6 +38,7 @@
#include "src/objects/js-regexp-string-iterator-inl.h"
#ifdef V8_INTL_SUPPORT
#include "src/objects/js-relative-time-format-inl.h"
#include "src/objects/js-segmenter-inl.h"
#endif // V8_INTL_SUPPORT
#include "src/objects/literal-objects-inl.h"
#include "src/objects/maybe-object.h"
......@@ -389,6 +390,9 @@ void HeapObject::HeapObjectVerify(Isolate* isolate) {
case JS_INTL_RELATIVE_TIME_FORMAT_TYPE:
JSRelativeTimeFormat::cast(this)->JSRelativeTimeFormatVerify(isolate);
break;
case JS_INTL_SEGMENTER_TYPE:
JSSegmenter::cast(this)->JSSegmenterVerify(isolate);
break;
#endif // V8_INTL_SUPPORT
#define MAKE_STRUCT_CASE(TYPE, Name, name) \
......@@ -1959,6 +1963,13 @@ void JSRelativeTimeFormat::JSRelativeTimeFormatVerify(Isolate* isolate) {
VerifyObjectField(isolate, kICUFormatterOffset);
VerifyObjectField(isolate, kFlagsOffset);
}
void JSSegmenter::JSSegmenterVerify(Isolate* isolate) {
JSObjectVerify(isolate);
VerifyObjectField(isolate, kLocaleOffset);
VerifyObjectField(isolate, kICUBreakIteratorOffset);
VerifyObjectField(isolate, kFlagsOffset);
}
#endif // V8_INTL_SUPPORT
#endif // VERIFY_HEAP
......
......@@ -228,6 +228,7 @@ namespace internal {
V(JS_INTL_NUMBER_FORMAT_TYPE) \
V(JS_INTL_PLURAL_RULES_TYPE) \
V(JS_INTL_RELATIVE_TIME_FORMAT_TYPE) \
V(JS_INTL_SEGMENTER_TYPE) \
INSTANCE_TYPE_LIST_AFTER_INTL(V)
#else
#define INSTANCE_TYPE_LIST(V) \
......
......@@ -38,6 +38,7 @@
#include "src/objects/js-regexp-string-iterator-inl.h"
#ifdef V8_INTL_SUPPORT
#include "src/objects/js-relative-time-format-inl.h"
#include "src/objects/js-segmenter-inl.h"
#endif // V8_INTL_SUPPORT
#include "src/objects/literal-objects-inl.h"
#include "src/objects/microtask-inl.h"
......@@ -342,6 +343,9 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
case JS_INTL_RELATIVE_TIME_FORMAT_TYPE:
JSRelativeTimeFormat::cast(this)->JSRelativeTimeFormatPrint(os);
break;
case JS_INTL_SEGMENTER_TYPE:
JSSegmenter::cast(this)->JSSegmenterPrint(os);
break;
#endif // V8_INTL_SUPPORT
#define MAKE_STRUCT_CASE(TYPE, Name, name) \
case TYPE: \
......@@ -2031,6 +2035,15 @@ void JSRelativeTimeFormat::JSRelativeTimeFormatPrint(
os << "\n - icu formatter: " << Brief(icu_formatter());
os << "\n";
}
void JSSegmenter::JSSegmenterPrint(std::ostream& os) { // NOLINT
JSObjectPrintHeader(os, this, "JSSegmenter");
os << "\n - locale: " << Brief(locale());
os << "\n - granularity: " << GranularityAsString();
os << "\n - lineBreakStyle: " << LineBreakStyleAsString();
os << "\n - icubreak iterator: " << Brief(icu_break_iterator());
os << "\n";
}
#endif // V8_INTL_SUPPORT
namespace {
......
......@@ -79,6 +79,7 @@
#include "src/objects/js-regexp-string-iterator.h"
#ifdef V8_INTL_SUPPORT
#include "src/objects/js-relative-time-format.h"
#include "src/objects/js-segmenter.h"
#endif // V8_INTL_SUPPORT
#include "src/objects/literal-objects-inl.h"
#include "src/objects/map.h"
......@@ -1476,6 +1477,8 @@ int JSObject::GetHeaderSize(InstanceType type,
return JSPluralRules::kSize;
case JS_INTL_RELATIVE_TIME_FORMAT_TYPE:
return JSRelativeTimeFormat::kSize;
case JS_INTL_SEGMENTER_TYPE:
return JSSegmenter::kSize;
#endif // V8_INTL_SUPPORT
case WASM_GLOBAL_TYPE:
return WasmGlobalObject::kSize;
......@@ -3225,6 +3228,7 @@ VisitorId Map::GetVisitorId(Map* map) {
case JS_INTL_NUMBER_FORMAT_TYPE:
case JS_INTL_PLURAL_RULES_TYPE:
case JS_INTL_RELATIVE_TIME_FORMAT_TYPE:
case JS_INTL_SEGMENTER_TYPE:
#endif // V8_INTL_SUPPORT
case WASM_EXCEPTION_TYPE:
case WASM_GLOBAL_TYPE:
......@@ -12987,6 +12991,7 @@ bool CanSubclassHaveInobjectProperties(InstanceType instance_type) {
case JS_INTL_NUMBER_FORMAT_TYPE:
case JS_INTL_PLURAL_RULES_TYPE:
case JS_INTL_RELATIVE_TIME_FORMAT_TYPE:
case JS_INTL_SEGMENTER_TYPE:
case JS_INTL_V8_BREAK_ITERATOR_TYPE:
#endif
case JS_ASYNC_GENERATOR_OBJECT_TYPE:
......
......@@ -84,6 +84,7 @@
// - JSNumberFormat // If V8_INTL_SUPPORT enabled.
// - JSPluralRules // If V8_INTL_SUPPORT enabled.
// - JSRelativeTimeFormat // If V8_INTL_SUPPORT enabled.
// - JSSegmenter // If V8_INTL_SUPPORT enabled.
// - WasmExceptionObject
// - WasmGlobalObject
// - WasmInstanceObject
......@@ -532,6 +533,7 @@ enum InstanceType : uint16_t {
JS_INTL_NUMBER_FORMAT_TYPE,
JS_INTL_PLURAL_RULES_TYPE,
JS_INTL_RELATIVE_TIME_FORMAT_TYPE,
JS_INTL_SEGMENTER_TYPE,
#endif // V8_INTL_SUPPORT
WASM_EXCEPTION_TYPE,
......@@ -854,7 +856,8 @@ class ZoneForwardList;
V(JSLocale) \
V(JSNumberFormat) \
V(JSPluralRules) \
V(JSRelativeTimeFormat)
V(JSRelativeTimeFormat) \
V(JSSegmenter)
#else
#define HEAP_OBJECT_ORDINARY_TYPE_LIST(V) HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V)
#endif // V8_INTL_SUPPORT
......@@ -970,16 +973,17 @@ class ZoneForwardList;
V(WeakArrayList, WEAK_ARRAY_LIST_TYPE)
#ifdef V8_INTL_SUPPORT
#define INSTANCE_TYPE_CHECKERS_SINGLE(V) \
INSTANCE_TYPE_CHECKERS_SINGLE_BASE(V) \
V(JSV8BreakIterator, JS_INTL_V8_BREAK_ITERATOR_TYPE) \
V(JSCollator, JS_INTL_COLLATOR_TYPE) \
V(JSDateTimeFormat, JS_INTL_DATE_TIME_FORMAT_TYPE) \
V(JSListFormat, JS_INTL_LIST_FORMAT_TYPE) \
V(JSLocale, JS_INTL_LOCALE_TYPE) \
V(JSNumberFormat, JS_INTL_NUMBER_FORMAT_TYPE) \
V(JSPluralRules, JS_INTL_PLURAL_RULES_TYPE) \
V(JSRelativeTimeFormat, JS_INTL_RELATIVE_TIME_FORMAT_TYPE)
#define INSTANCE_TYPE_CHECKERS_SINGLE(V) \
INSTANCE_TYPE_CHECKERS_SINGLE_BASE(V) \
V(JSV8BreakIterator, JS_INTL_V8_BREAK_ITERATOR_TYPE) \
V(JSCollator, JS_INTL_COLLATOR_TYPE) \
V(JSDateTimeFormat, JS_INTL_DATE_TIME_FORMAT_TYPE) \
V(JSListFormat, JS_INTL_LIST_FORMAT_TYPE) \
V(JSLocale, JS_INTL_LOCALE_TYPE) \
V(JSNumberFormat, JS_INTL_NUMBER_FORMAT_TYPE) \
V(JSPluralRules, JS_INTL_PLURAL_RULES_TYPE) \
V(JSRelativeTimeFormat, JS_INTL_RELATIVE_TIME_FORMAT_TYPE) \
V(JSSegmenter, JS_INTL_SEGMENTER_TYPE)
#else
......
......@@ -183,6 +183,7 @@ std::set<std::string> Intl::GetAvailableLocales(const IcuService& service) {
std::set<std::string> locales;
switch (service) {
case IcuService::kSegmenter:
case IcuService::kBreakIterator:
icu_available_locales = icu::BreakIterator::getAvailableLocales(count);
break;
......@@ -291,6 +292,8 @@ IcuService Intl::StringToIcuService(Handle<String> service) {
return IcuService::kRelativeDateTimeFormatter;
} else if (service->IsUtf8EqualTo(CStrVector("listformat"))) {
return IcuService::kListFormatter;
} else if (service->IsUtf8EqualTo(CStrVector("segmenter"))) {
return IcuService::kSegmenter;
}
UNREACHABLE();
}
......
// 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.
#ifndef V8_INTL_SUPPORT
#error Internationalization is expected to be enabled.
#endif // V8_INTL_SUPPORT
#ifndef V8_OBJECTS_JS_SEGMENTER_INL_H_
#define V8_OBJECTS_JS_SEGMENTER_INL_H_
#include "src/objects-inl.h"
#include "src/objects/js-segmenter.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
// Base segmenter accessors.
ACCESSORS(JSSegmenter, locale, String, kLocaleOffset)
ACCESSORS(JSSegmenter, icu_break_iterator, Managed<icu::BreakIterator>,
kICUBreakIteratorOffset)
SMI_ACCESSORS(JSSegmenter, flags, kFlagsOffset)
inline void JSSegmenter::set_line_break_style(LineBreakStyle line_break_style) {
DCHECK_GT(LineBreakStyle::COUNT, line_break_style);
int hints = flags();
hints = LineBreakStyleBits::update(hints, line_break_style);
set_flags(hints);
}
inline JSSegmenter::LineBreakStyle JSSegmenter::line_break_style() const {
return LineBreakStyleBits::decode(flags());
}
inline void JSSegmenter::set_granularity(Granularity granularity) {
DCHECK_GT(Granularity::COUNT, granularity);
int hints = flags();
hints = GranularityBits::update(hints, granularity);
set_flags(hints);
}
inline JSSegmenter::Granularity JSSegmenter::granularity() const {
return GranularityBits::decode(flags());
}
CAST_ACCESSOR(JSSegmenter);
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_JS_SEGMENTER_INL_H_
// 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.
#ifndef V8_INTL_SUPPORT
#error Internationalization is expected to be enabled.
#endif // V8_INTL_SUPPORT
#include "src/objects/js-segmenter.h"
#include <map>
#include <memory>
#include <string>
#include "src/heap/factory.h"
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "src/objects/intl-objects.h"
#include "src/objects/js-segmenter-inl.h"
#include "src/objects/managed.h"
#include "unicode/brkiter.h"
namespace v8 {
namespace internal {
JSSegmenter::LineBreakStyle JSSegmenter::GetLineBreakStyle(const char* str) {
if (strcmp(str, "strict") == 0) return JSSegmenter::LineBreakStyle::STRICT;
if (strcmp(str, "normal") == 0) return JSSegmenter::LineBreakStyle::NORMAL;
if (strcmp(str, "loose") == 0) return JSSegmenter::LineBreakStyle::LOOSE;
UNREACHABLE();
}
JSSegmenter::Granularity JSSegmenter::GetGranularity(const char* str) {
if (strcmp(str, "grapheme") == 0) return JSSegmenter::Granularity::GRAPHEME;
if (strcmp(str, "word") == 0) return JSSegmenter::Granularity::WORD;
if (strcmp(str, "sentence") == 0) return JSSegmenter::Granularity::SENTENCE;
if (strcmp(str, "line") == 0) return JSSegmenter::Granularity::LINE;
UNREACHABLE();
}
MaybeHandle<JSSegmenter> JSSegmenter::Initialize(
Isolate* isolate, Handle<JSSegmenter> segmenter_holder,
Handle<Object> input_locales, Handle<Object> input_options) {
Factory* factory = isolate->factory();
segmenter_holder->set_flags(0);
// 3. Let requestedLocales be ? CanonicalizeLocaleList(locales).
Handle<JSObject> requested_locales;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, requested_locales,
Intl::CanonicalizeLocaleListJS(isolate, input_locales), JSSegmenter);
// 11. If options is undefined, then
Handle<JSReceiver> options;
if (input_options->IsUndefined(isolate)) {
// a. Let options be ObjectCreate(null).
options = isolate->factory()->NewJSObjectWithNullProto();
// 12. Else
} else {
// a. Let options be ? ToObject(options).
ASSIGN_RETURN_ON_EXCEPTION(isolate, options,
Object::ToObject(isolate, input_options),
JSSegmenter);
}
// 8. Set opt.[[lb]] to lineBreakStyle.
// Because currently we access localeMatcher inside ResolveLocale, we have to
// move ResolveLocale before get lineBreakStyle
// 9. Let r be ResolveLocale(%Segmenter%.[[AvailableLocales]],
// requestedLocales, opt, %Segmenter%.[[RelevantExtensionKeys]]).
Handle<JSObject> r;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, r,
Intl::ResolveLocale(isolate, "segmenter", requested_locales, options),
JSSegmenter);
Handle<Object> locale_obj =
JSObject::GetDataProperty(r, factory->locale_string());
Handle<String> locale;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, locale, Object::ToString(isolate, locale_obj), JSSegmenter);
// 7. Let lineBreakStyle be ? GetOption(options, "lineBreakStyle", "string", «
// "strict", "normal", "loose" », "normal").
std::unique_ptr<char[]> line_break_style_str = nullptr;
const std::vector<const char*> line_break_style_values = {"strict", "normal",
"loose"};
Maybe<bool> maybe_found_line_break_style = Intl::GetStringOption(
isolate, options, "lineBreakStyle", line_break_style_values,
"Intl.Segmenter", &line_break_style_str);
LineBreakStyle line_break_style_enum = LineBreakStyle::NORMAL;
MAYBE_RETURN(maybe_found_line_break_style, MaybeHandle<JSSegmenter>());
if (maybe_found_line_break_style.FromJust()) {
DCHECK_NOT_NULL(line_break_style_str.get());
line_break_style_enum = GetLineBreakStyle(line_break_style_str.get());
}
// 10. Set segmenter.[[Locale]] to the value of r.[[Locale]].
segmenter_holder->set_locale(*locale);
// 13. Let granularity be ? GetOption(options, "granularity", "string", «
// "grapheme", "word", "sentence", "line" », "grapheme").
std::unique_ptr<char[]> granularity_str = nullptr;
const std::vector<const char*> granularity_values = {"grapheme", "word",
"sentence", "line"};
Maybe<bool> maybe_found_granularity =
Intl::GetStringOption(isolate, options, "granularity", granularity_values,
"Intl.Segmenter", &granularity_str);
Granularity granularity_enum = Granularity::GRAPHEME;
MAYBE_RETURN(maybe_found_granularity, MaybeHandle<JSSegmenter>());
if (maybe_found_granularity.FromJust()) {
DCHECK_NOT_NULL(granularity_str.get());
granularity_enum = GetGranularity(granularity_str.get());
}
// 14. Set segmenter.[[SegmenterGranularity]] to granularity.
segmenter_holder->set_granularity(granularity_enum);
// 15. If granularity is "line",
if (granularity_enum == Granularity::LINE) {
// a. Set segmenter.[[SegmenterLineBreakStyle]] to r.[[lb]].
segmenter_holder->set_line_break_style(line_break_style_enum);
} else {
segmenter_holder->set_line_break_style(LineBreakStyle::NOTSET);
}
icu::Locale icu_locale = Intl::CreateICULocale(isolate, locale);
DCHECK(!icu_locale.isBogus());
UErrorCode status = U_ZERO_ERROR;
std::unique_ptr<icu::BreakIterator> icu_break_iterator;
switch (granularity_enum) {
case Granularity::GRAPHEME:
icu_break_iterator.reset(
icu::BreakIterator::createCharacterInstance(icu_locale, status));
break;
case Granularity::WORD:
icu_break_iterator.reset(
icu::BreakIterator::createWordInstance(icu_locale, status));
break;
case Granularity::SENTENCE:
icu_break_iterator.reset(
icu::BreakIterator::createSentenceInstance(icu_locale, status));
break;
case Granularity::LINE:
icu_break_iterator.reset(
icu::BreakIterator::createLineInstance(icu_locale, status));
// 15. If granularity is "line",
// a. Set segmenter.[[SegmenterLineBreakStyle]] to r.[[lb]].
// TBW
break;
case Granularity::COUNT:
UNREACHABLE();
}
CHECK(U_SUCCESS(status));
CHECK_NOT_NULL(icu_break_iterator.get());
Handle<Managed<icu::BreakIterator>> managed_break_iterator =
Managed<icu::BreakIterator>::FromUniquePtr(isolate, 0,
std::move(icu_break_iterator));
segmenter_holder->set_icu_break_iterator(*managed_break_iterator);
return segmenter_holder;
}
Handle<JSObject> JSSegmenter::ResolvedOptions(
Isolate* isolate, Handle<JSSegmenter> segmenter_holder) {
Factory* factory = isolate->factory();
Handle<JSObject> result = factory->NewJSObject(isolate->object_function());
Handle<String> locale(segmenter_holder->locale(), isolate);
JSObject::AddProperty(isolate, result, factory->locale_string(), locale,
NONE);
if (segmenter_holder->line_break_style() != LineBreakStyle::NOTSET) {
JSObject::AddProperty(isolate, result, factory->lineBreakStyle_string(),
segmenter_holder->LineBreakStyleAsString(), NONE);
}
JSObject::AddProperty(isolate, result, factory->granularity_string(),
segmenter_holder->GranularityAsString(), NONE);
return result;
}
Handle<String> JSSegmenter::LineBreakStyleAsString() const {
switch (line_break_style()) {
case LineBreakStyle::STRICT:
return GetReadOnlyRoots().strict_string_handle();
case LineBreakStyle::NORMAL:
return GetReadOnlyRoots().normal_string_handle();
case LineBreakStyle::LOOSE:
return GetReadOnlyRoots().loose_string_handle();
case LineBreakStyle::COUNT:
case LineBreakStyle::NOTSET:
UNREACHABLE();
}
}
Handle<String> JSSegmenter::GranularityAsString() const {
switch (granularity()) {
case Granularity::GRAPHEME:
return GetReadOnlyRoots().grapheme_string_handle();
case Granularity::WORD:
return GetReadOnlyRoots().word_string_handle();
case Granularity::SENTENCE:
return GetReadOnlyRoots().sentence_string_handle();
case Granularity::LINE:
return GetReadOnlyRoots().line_string_handle();
case Granularity::COUNT:
UNREACHABLE();
}
}
} // namespace internal
} // namespace v8
// 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.
#ifndef V8_INTL_SUPPORT
#error Internationalization is expected to be enabled.
#endif // V8_INTL_SUPPORT
#ifndef V8_OBJECTS_JS_SEGMENTER_H_
#define V8_OBJECTS_JS_SEGMENTER_H_
#include "src/heap/factory.h"
#include "src/isolate.h"
#include "src/objects.h"
#include "src/objects/managed.h"
#include "unicode/uversion.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace U_ICU_NAMESPACE {
class BreakIterator;
}
namespace v8 {
namespace internal {
class JSSegmenter : public JSObject {
public:
// Initializes segmenter object with properties derived from input
// locales and options.
V8_WARN_UNUSED_RESULT static MaybeHandle<JSSegmenter> Initialize(
Isolate* isolate, Handle<JSSegmenter> segmenter_holder,
Handle<Object> locales, Handle<Object> options);
V8_WARN_UNUSED_RESULT static Handle<JSObject> ResolvedOptions(
Isolate* isolate, Handle<JSSegmenter> segmenter_holder);
Handle<String> LineBreakStyleAsString() const;
Handle<String> GranularityAsString() const;
DECL_CAST(JSSegmenter)
// Segmenter accessors.
DECL_ACCESSORS(locale, String)
DECL_ACCESSORS(icu_break_iterator, Managed<icu::BreakIterator>)
// LineBreakStyle: identifying the style used for line break.
//
// ecma402 #sec-segmenter-internal-slots
enum class LineBreakStyle {
NOTSET, // While the granularity is not LINE
STRICT, // CSS level 3 line-break=strict, e.g. treat CJ as NS
NORMAL, // CSS level 3 line-break=normal, e.g. treat CJ as ID, break before
// hyphens for ja,zh
LOOSE, // CSS level 3 line-break=loose
COUNT
};
inline void set_line_break_style(LineBreakStyle line_break_style);
inline LineBreakStyle line_break_style() const;
// Granularity: identifying the segmenter used.
//
// ecma402 #sec-segmenter-internal-slots
enum class Granularity {
GRAPHEME, // for character-breaks
WORD, // for word-breaks
SENTENCE, // for sentence-breaks
LINE, // for line-breaks
COUNT
};
inline void set_granularity(Granularity granularity);
inline Granularity granularity() const;
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) \
V(LineBreakStyleBits, LineBreakStyle, 3, _) \
V(GranularityBits, Granularity, 3, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
STATIC_ASSERT(LineBreakStyle::NOTSET <= LineBreakStyleBits::kMax);
STATIC_ASSERT(LineBreakStyle::STRICT <= LineBreakStyleBits::kMax);
STATIC_ASSERT(LineBreakStyle::NORMAL <= LineBreakStyleBits::kMax);
STATIC_ASSERT(LineBreakStyle::LOOSE <= LineBreakStyleBits::kMax);
STATIC_ASSERT(Granularity::GRAPHEME <= GranularityBits::kMax);
STATIC_ASSERT(Granularity::WORD <= GranularityBits::kMax);
STATIC_ASSERT(Granularity::SENTENCE <= GranularityBits::kMax);
STATIC_ASSERT(Granularity::LINE <= GranularityBits::kMax);
// [flags] Bit field containing various flags about the function.
DECL_INT_ACCESSORS(flags)
DECL_PRINTER(JSSegmenter)
DECL_VERIFIER(JSSegmenter)
// Layout description.
static const int kJSSegmenterOffset = JSObject::kHeaderSize;
static const int kLocaleOffset = kJSSegmenterOffset + kPointerSize;
static const int kICUBreakIteratorOffset = kLocaleOffset + kPointerSize;
static const int kFlagsOffset = kICUBreakIteratorOffset + kPointerSize;
static const int kSize = kFlagsOffset + kPointerSize;
private:
static LineBreakStyle GetLineBreakStyle(const char* str);
static Granularity GetGranularity(const char* str);
DISALLOW_IMPLICIT_CONSTRUCTORS(JSSegmenter);
};
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_JS_SEGMENTER_H_
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-lineBreakStyle 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);
// Invalid locale string.
assertThrows(() => new Intl.Segmenter(["abcdefghi"]), RangeError);
assertDoesNotThrow(() => new Intl.Segmenter(["sr"], {}), TypeError);
assertDoesNotThrow(() => new Intl.Segmenter([], {}));
assertDoesNotThrow(() => new Intl.Segmenter(["fr", "ar"], {}));
assertDoesNotThrow(() => new Intl.Segmenter({ 0: "ja", 1: "fr" }, {}));
assertDoesNotThrow(() => new Intl.Segmenter({ 1: "ja", 2: "fr" }, {}));
assertDoesNotThrow(() => new Intl.Segmenter(["sr"]));
assertDoesNotThrow(() => new Intl.Segmenter());
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
lineBreakStyle: "strict",
granularity: "grapheme"
})
);
assertDoesNotThrow(
() => new Intl.Segmenter(["sr"], { granularity: "sentence" })
);
assertDoesNotThrow(() => new Intl.Segmenter(["sr"], { granularity: "word" }));
assertDoesNotThrow(
() => new Intl.Segmenter(["sr"], { granularity: "grapheme" })
);
assertDoesNotThrow(() => new Intl.Segmenter(["sr"], { granularity: "line" }));
assertThrows(
() => new Intl.Segmenter(["sr"], { granularity: "standard" }),
RangeError
);
assertDoesNotThrow(
() => new Intl.Segmenter(["sr"], { lineBreakStyle: "normal" })
);
assertDoesNotThrow(
() => new Intl.Segmenter(["sr"], { lineBreakStyle: "strict" })
);
assertDoesNotThrow(
() => new Intl.Segmenter(["sr"], { lineBreakStyle: "loose" })
);
assertThrows(
() => new Intl.Segmenter(["sr"], { lineBreakStyle: "giant" }),
RangeError
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "sentence",
lineBreakStyle: "normal"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "sentence",
lineBreakStyle: "strict"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "sentence",
lineBreakStyle: "loose"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "word",
lineBreakStyle: "normal"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "word",
lineBreakStyle: "strict"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "word",
lineBreakStyle: "loose"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "grapheme",
lineBreakStyle: "normal"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "grapheme",
lineBreakStyle: "strict"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "grapheme",
lineBreakStyle: "loose"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "line",
lineBreakStyle: "loose"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "line",
lineBreakStyle: "normal"
})
);
assertDoesNotThrow(
() =>
new Intl.Segmenter(["sr"], {
granularity: "line",
lineBreakStyle: "strict"
})
);
// propagate exception from getter
assertThrows(
() =>
new Intl.Segmenter(undefined, {
get localeMatcher() {
throw new TypeError("");
}
}),
TypeError
);
assertThrows(
() =>
new Intl.Segmenter(undefined, {
get lineBreakStyle() {
throw new TypeError("");
}
}),
TypeError
);
assertThrows(
() =>
new Intl.Segmenter(undefined, {
get granularity() {
throw new TypeError("");
}
}),
TypeError
);
// Throws only once during construction.
// Check for all getters to prevent regression.
// Preserve the order of getter initialization.
let getCount = 0;
let localeMatcher = -1;
let lineBreakStyle = -1;
let granularity = -1;
new Intl.Segmenter(["en-US"], {
get localeMatcher() {
localeMatcher = ++getCount;
},
get lineBreakStyle() {
lineBreakStyle = ++getCount;
},
get granularity() {
granularity = ++getCount;
}
});
assertEquals(1, localeMatcher);
assertEquals(2, lineBreakStyle);
assertEquals(3, granularity);
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-lineBreakStyle license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-segmenter
let segmenter = new Intl.Segmenter([], { granularity: "line" });
// The default lineBreakStyle is 'normal'
assertEquals("normal", segmenter.resolvedOptions().lineBreakStyle);
segmenter = new Intl.Segmenter();
assertEquals(undefined, segmenter.resolvedOptions().lineBreakStyle);
// The default granularity is 'grapheme'
assertEquals("grapheme", segmenter.resolvedOptions().granularity);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], { lineBreakStyle: "strict" }).resolvedOptions()
.lineBreakStyle
);
assertEquals(
"grapheme",
new Intl.Segmenter(["sr"], { lineBreakStyle: "strict" }).resolvedOptions()
.granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], { lineBreakStyle: "normal" }).resolvedOptions()
.lineBreakStyle
);
assertEquals(
"grapheme",
new Intl.Segmenter(["sr"], { lineBreakStyle: "normal" }).resolvedOptions()
.granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], { lineBreakStyle: "loose" }).resolvedOptions()
.lineBreakStyle
);
assertEquals(
"grapheme",
new Intl.Segmenter(["sr"], { lineBreakStyle: "loose" }).resolvedOptions()
.granularity
);
assertEquals(
"word",
new Intl.Segmenter(["sr"], { granularity: "word" }).resolvedOptions()
.granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], { granularity: "word" }).resolvedOptions()
.lineBreakStyle
);
assertEquals(
"grapheme",
new Intl.Segmenter(["sr"], { granularity: "grapheme" }).resolvedOptions()
.granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], { granularity: "grapheme" }).resolvedOptions()
.lineBreakStyle
);
assertEquals(
"sentence",
new Intl.Segmenter(["sr"], { granularity: "sentence" }).resolvedOptions()
.granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], { granularity: "sentence" }).resolvedOptions()
.lineBreakStyle
);
assertEquals(
"line",
new Intl.Segmenter(["sr"], { granularity: "line" }).resolvedOptions()
.granularity
);
assertEquals(
"normal",
new Intl.Segmenter(["sr"], { granularity: "line" }).resolvedOptions()
.lineBreakStyle
);
assertEquals(
"grapheme",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "loose",
granularity: "grapheme"
}).resolvedOptions().granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], {
lineBreakStyle: "loose",
granularity: "grapheme"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"grapheme",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "strict",
granularity: "grapheme"
}).resolvedOptions().granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], {
lineBreakStyle: "strict",
granularity: "grapheme"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"grapheme",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "normal",
granularity: "grapheme"
}).resolvedOptions().granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], {
lineBreakStyle: "normal",
granularity: "grapheme"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"word",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "loose",
granularity: "word"
}).resolvedOptions().granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], {
lineBreakStyle: "loose",
granularity: "word"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"word",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "strict",
granularity: "word"
}).resolvedOptions().granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], {
lineBreakStyle: "strict",
granularity: "word"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"word",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "normal",
granularity: "word"
}).resolvedOptions().granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], {
lineBreakStyle: "normal",
granularity: "word"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"sentence",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "loose",
granularity: "sentence"
}).resolvedOptions().granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], {
lineBreakStyle: "loose",
granularity: "sentence"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"sentence",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "strict",
granularity: "sentence"
}).resolvedOptions().granularity
);
assertEquals(
undefined,
new Intl.Segmenter(["sr"], {
lineBreakStyle: "strict",
granularity: "sentence"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"sentence",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "normal",
granularity: "sentence"
}).resolvedOptions().granularity
);
assertEquals(
"normal",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "normal",
granularity: "line"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"line",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "loose",
granularity: "line"
}).resolvedOptions().granularity
);
assertEquals(
"loose",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "loose",
granularity: "line"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"line",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "strict",
granularity: "line"
}).resolvedOptions().granularity
);
assertEquals(
"strict",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "strict",
granularity: "line"
}).resolvedOptions().lineBreakStyle
);
assertEquals(
"line",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "normal",
granularity: "line"
}).resolvedOptions().granularity
);
assertEquals(
"normal",
new Intl.Segmenter(["sr"], {
lineBreakStyle: "normal",
granularity: "line"
}).resolvedOptions().lineBreakStyle
);
assertEquals("ar", new Intl.Segmenter(["ar"]).resolvedOptions().locale);
assertEquals("ar", new Intl.Segmenter(["ar", "en"]).resolvedOptions().locale);
assertEquals("fr", new Intl.Segmenter(["fr", "en"]).resolvedOptions().locale);
assertEquals("ar", new Intl.Segmenter(["xyz", "ar"]).resolvedOptions().locale);
// 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",
"Intl.Segmenter.supportedLocalesOf should be a function"
);
var undef = Intl.Segmenter.supportedLocalesOf();
assertEquals([], undef);
var empty = Intl.Segmenter.supportedLocalesOf([]);
assertEquals([], empty);
var strLocale = Intl.Segmenter.supportedLocalesOf("sr");
assertEquals("sr", strLocale[0]);
var multiLocale = ["sr-Thai-RS", "de", "zh-CN"];
assertEquals(multiLocale, Intl.Segmenter.supportedLocalesOf(multiLocale));
......@@ -52,13 +52,13 @@ FEATURE_FLAGS = {
'Intl.ListFormat': '--harmony-intl-list-format',
'Intl.Locale': '--harmony-locale',
'Intl.RelativeTimeFormat': '--harmony-intl-relative-time-format',
'Intl.Segmenter': '--harmony-intl-segmenter',
'Symbol.prototype.description': '--harmony-symbol-description',
'globalThis': '--harmony-global',
'well-formed-json-stringify': '--harmony-json-stringify',
}
SKIPPED_FEATURES = set(['Intl.Segmenter',
'Object.fromEntries',
SKIPPED_FEATURES = set(['Object.fromEntries',
'export-star-as-namespace-from-module',
'class-fields-private',
'class-static-fields-private',
......
......@@ -168,14 +168,15 @@ INSTANCE_TYPES = {
1089: "JS_INTL_NUMBER_FORMAT_TYPE",
1090: "JS_INTL_PLURAL_RULES_TYPE",
1091: "JS_INTL_RELATIVE_TIME_FORMAT_TYPE",
1092: "WASM_EXCEPTION_TYPE",
1093: "WASM_GLOBAL_TYPE",
1094: "WASM_INSTANCE_TYPE",
1095: "WASM_MEMORY_TYPE",
1096: "WASM_MODULE_TYPE",
1097: "WASM_TABLE_TYPE",
1098: "JS_BOUND_FUNCTION_TYPE",
1099: "JS_FUNCTION_TYPE",
1092: "JS_INTL_SEGMENTER_TYPE",
1093: "WASM_EXCEPTION_TYPE",
1094: "WASM_GLOBAL_TYPE",
1095: "WASM_INSTANCE_TYPE",
1096: "WASM_MEMORY_TYPE",
1097: "WASM_MODULE_TYPE",
1098: "WASM_TABLE_TYPE",
1099: "JS_BOUND_FUNCTION_TYPE",
1100: "JS_FUNCTION_TYPE",
}
# List of known V8 maps.
......@@ -290,41 +291,41 @@ KNOWN_MAPS = {
("RO_SPACE", 0x04761): (171, "Tuple2Map"),
("RO_SPACE", 0x04801): (173, "ArrayBoilerplateDescriptionMap"),
("RO_SPACE", 0x04af1): (161, "InterceptorInfoMap"),
("RO_SPACE", 0x06d79): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x06dc9): (154, "AccessorInfoMap"),
("RO_SPACE", 0x06e19): (155, "AccessorPairMap"),
("RO_SPACE", 0x06e69): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x06eb9): (157, "AllocationMementoMap"),
("RO_SPACE", 0x06f09): (158, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x06f59): (159, "DebugInfoMap"),
("RO_SPACE", 0x06fa9): (160, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x06ff9): (162, "InterpreterDataMap"),
("RO_SPACE", 0x07049): (163, "ModuleInfoEntryMap"),
("RO_SPACE", 0x07099): (164, "ModuleMap"),
("RO_SPACE", 0x070e9): (165, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x07139): (166, "PromiseCapabilityMap"),
("RO_SPACE", 0x07189): (167, "PromiseReactionMap"),
("RO_SPACE", 0x071d9): (168, "PrototypeInfoMap"),
("RO_SPACE", 0x07229): (169, "ScriptMap"),
("RO_SPACE", 0x07279): (170, "StackFrameInfoMap"),
("RO_SPACE", 0x072c9): (172, "Tuple3Map"),
("RO_SPACE", 0x07319): (174, "WasmDebugInfoMap"),
("RO_SPACE", 0x07369): (175, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x073b9): (176, "CallableTaskMap"),
("RO_SPACE", 0x07409): (177, "CallbackTaskMap"),
("RO_SPACE", 0x07459): (178, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x074a9): (179, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x074f9): (180, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x07549): (181, "MicrotaskQueueMap"),
("RO_SPACE", 0x07599): (182, "AllocationSiteWithWeakNextMap"),
("RO_SPACE", 0x075e9): (182, "AllocationSiteWithoutWeakNextMap"),
("RO_SPACE", 0x07639): (214, "LoadHandler1Map"),
("RO_SPACE", 0x07689): (214, "LoadHandler2Map"),
("RO_SPACE", 0x076d9): (214, "LoadHandler3Map"),
("RO_SPACE", 0x07729): (221, "StoreHandler0Map"),
("RO_SPACE", 0x07779): (221, "StoreHandler1Map"),
("RO_SPACE", 0x077c9): (221, "StoreHandler2Map"),
("RO_SPACE", 0x07819): (221, "StoreHandler3Map"),
("RO_SPACE", 0x06e19): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x06e69): (154, "AccessorInfoMap"),
("RO_SPACE", 0x06eb9): (155, "AccessorPairMap"),
("RO_SPACE", 0x06f09): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x06f59): (157, "AllocationMementoMap"),
("RO_SPACE", 0x06fa9): (158, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x06ff9): (159, "DebugInfoMap"),
("RO_SPACE", 0x07049): (160, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x07099): (162, "InterpreterDataMap"),
("RO_SPACE", 0x070e9): (163, "ModuleInfoEntryMap"),
("RO_SPACE", 0x07139): (164, "ModuleMap"),
("RO_SPACE", 0x07189): (165, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x071d9): (166, "PromiseCapabilityMap"),
("RO_SPACE", 0x07229): (167, "PromiseReactionMap"),
("RO_SPACE", 0x07279): (168, "PrototypeInfoMap"),
("RO_SPACE", 0x072c9): (169, "ScriptMap"),
("RO_SPACE", 0x07319): (170, "StackFrameInfoMap"),
("RO_SPACE", 0x07369): (172, "Tuple3Map"),
("RO_SPACE", 0x073b9): (174, "WasmDebugInfoMap"),
("RO_SPACE", 0x07409): (175, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x07459): (176, "CallableTaskMap"),
("RO_SPACE", 0x074a9): (177, "CallbackTaskMap"),
("RO_SPACE", 0x074f9): (178, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x07549): (179, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x07599): (180, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x075e9): (181, "MicrotaskQueueMap"),
("RO_SPACE", 0x07639): (182, "AllocationSiteWithWeakNextMap"),
("RO_SPACE", 0x07689): (182, "AllocationSiteWithoutWeakNextMap"),
("RO_SPACE", 0x076d9): (214, "LoadHandler1Map"),
("RO_SPACE", 0x07729): (214, "LoadHandler2Map"),
("RO_SPACE", 0x07779): (214, "LoadHandler3Map"),
("RO_SPACE", 0x077c9): (221, "StoreHandler0Map"),
("RO_SPACE", 0x07819): (221, "StoreHandler1Map"),
("RO_SPACE", 0x07869): (221, "StoreHandler2Map"),
("RO_SPACE", 0x078b9): (221, "StoreHandler3Map"),
("MAP_SPACE", 0x02201): (1057, "ExternalMap"),
("MAP_SPACE", 0x02251): (1072, "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