Commit 1163aba7 authored by Jungshik Shin's avatar Jungshik Shin Committed by Commit Bot

Remove icu_case_mapping flag

icu-case-mapping was shipped a few months ago. By dropping
the flag, unibrow's case conversion code won't be included
by default because V8_INTL_SUPPORT is on by default.

BUG=v8:4477, v8:4476
TEST=test262/{built-ins,intl402}/Strings/*, webkit/fast/js/*,
     mjsunit/string-case, intl/general/case*

Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: I78be9cc64b4588bc5af79ecbbadf93af6e84a1df
Reviewed-on: https://chromium-review.googlesource.com/534541
Commit-Queue: Jungshik Shin <jshin@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarDaniel Ehrenberg <littledan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46304}
parent cb61fad8
......@@ -1855,6 +1855,12 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kStringPrototypeTrimLeft, 0, false);
SimpleInstallFunction(prototype, "trimRight",
Builtins::kStringPrototypeTrimRight, 0, false);
#ifdef V8_INTL_SUPPORT
SimpleInstallFunction(prototype, "toLowerCase",
Builtins::kStringPrototypeToLowerCaseIntl, 0, true);
SimpleInstallFunction(prototype, "toUpperCase",
Builtins::kStringPrototypeToUpperCaseIntl, 0, false);
#else
SimpleInstallFunction(prototype, "toLocaleLowerCase",
Builtins::kStringPrototypeToLocaleLowerCase, 0,
false);
......@@ -1865,6 +1871,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kStringPrototypeToLowerCase, 0, false);
SimpleInstallFunction(prototype, "toUpperCase",
Builtins::kStringPrototypeToUpperCase, 0, false);
#endif
SimpleInstallFunction(prototype, "valueOf",
Builtins::kStringPrototypeValueOf, 0, true);
......@@ -4155,59 +4162,6 @@ void Genesis::InitializeGlobal_harmony_regexp_dotall() {
native_context()->set_regexp_prototype_map(*prototype_map);
}
#ifdef V8_INTL_SUPPORT
namespace {
void SetFunction(Handle<JSObject> target, Handle<JSFunction> function,
Handle<Name> name, PropertyAttributes attributes = DONT_ENUM) {
JSObject::SetOwnPropertyIgnoreAttributes(target, name, function, attributes)
.ToHandleChecked();
}
} // namespace
void Genesis::InitializeGlobal_icu_case_mapping() {
if (!FLAG_icu_case_mapping) return;
Handle<JSReceiver> exports_container(
JSReceiver::cast(native_context()->exports_container()));
Handle<JSObject> string_prototype(
JSObject::cast(native_context()->string_function()->prototype()));
{
Handle<String> name = factory()->InternalizeUtf8String("toLowerCase");
Handle<JSFunction> to_lower_case = SimpleCreateFunction(
isolate(), name, Builtins::kStringPrototypeToLowerCaseIntl, 0, true);
SetFunction(string_prototype, to_lower_case, name);
to_lower_case->shared()->set_builtin_function_id(kStringToLowerCaseIntl);
}
{
Handle<String> name = factory()->InternalizeUtf8String("toUpperCase");
Handle<JSFunction> to_upper_case = SimpleCreateFunction(
isolate(), name, Builtins::kStringPrototypeToUpperCaseIntl, 0, false);
SetFunction(string_prototype, to_upper_case, name);
to_upper_case->shared()->set_builtin_function_id(kStringToUpperCaseIntl);
}
Handle<JSFunction> to_locale_lower_case = Handle<JSFunction>::cast(
JSReceiver::GetProperty(
exports_container,
factory()->InternalizeUtf8String("ToLocaleLowerCaseIntl"))
.ToHandleChecked());
SetFunction(string_prototype, to_locale_lower_case,
factory()->InternalizeUtf8String("toLocaleLowerCase"));
Handle<JSFunction> to_locale_upper_case = Handle<JSFunction>::cast(
JSReceiver::GetProperty(
exports_container,
factory()->InternalizeUtf8String("ToLocaleUpperCaseIntl"))
.ToHandleChecked());
SetFunction(string_prototype, to_locale_upper_case,
factory()->InternalizeUtf8String("toLocaleUpperCase"));
}
#endif
Handle<JSFunction> Genesis::CreateArrayBuffer(Handle<String> name,
Builtins::Name call_byteLength,
BuiltinFunctionId byteLength_id,
......
......@@ -917,14 +917,6 @@ namespace internal {
CPP(StringPrototypeStartsWith) \
/* ES6 #sec-string.prototype.tostring */ \
TFJ(StringPrototypeToString, 0) \
/* ES #sec-string.prototype.tolocalelowercase */ \
CPP(StringPrototypeToLocaleLowerCase) \
/* ES #sec-string.prototype.tolocaleuppercase */ \
CPP(StringPrototypeToLocaleUpperCase) \
/* (obsolete) Unibrow version */ \
CPP(StringPrototypeToLowerCase) \
/* (obsolete) Unibrow version */ \
CPP(StringPrototypeToUpperCase) \
CPP(StringPrototypeTrim) \
CPP(StringPrototypeTrimLeft) \
CPP(StringPrototypeTrimRight) \
......@@ -1077,7 +1069,15 @@ namespace internal {
BUILTIN_LIST_BASE(CPP, API, TFJ, TFC, TFS, TFH, ASM, DBG) \
\
/* no-op fallback version */ \
CPP(StringPrototypeNormalize)
CPP(StringPrototypeNormalize) \
/* same as toLowercase; fallback version */ \
CPP(StringPrototypeToLocaleLowerCase) \
/* same as toUppercase; fallback version */ \
CPP(StringPrototypeToLocaleUpperCase) \
/* (obsolete) Unibrow version */ \
CPP(StringPrototypeToLowerCase) \
/* (obsolete) Unibrow version */ \
CPP(StringPrototypeToUpperCase)
#endif // V8_INTL_SUPPORT
// The exception thrown in the following builtins are caught
......
......@@ -368,6 +368,7 @@ BUILTIN(StringPrototypeTrimRight) {
return *String::Trim(string, String::kTrimRight);
}
#ifndef V8_INTL_SUPPORT
namespace {
inline bool ToUpperOverflows(uc32 character) {
......@@ -559,6 +560,7 @@ BUILTIN(StringPrototypeToUpperCase) {
return ConvertCase(string, isolate,
isolate->runtime_state()->to_upper_mapping());
}
#endif // !V8_INTL_SUPPORT
} // namespace internal
} // namespace v8
......@@ -606,8 +606,10 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
case Builtins::kStringPrototypeSubstr:
case Builtins::kStringPrototypeSubstring:
case Builtins::kStringPrototypeToString:
#ifndef V8_INTL_SUPPORT
case Builtins::kStringPrototypeToLowerCase:
case Builtins::kStringPrototypeToUpperCase:
#endif
case Builtins::kStringPrototypeTrim:
case Builtins::kStringPrototypeTrimLeft:
case Builtins::kStringPrototypeTrimRight:
......
......@@ -216,19 +216,11 @@ DEFINE_IMPLICATION(es_staging, harmony)
"constructor")
// Features that are shipping (turned on by default, but internal flag remains).
#define HARMONY_SHIPPING_BASE(V) \
V(harmony_restrictive_generators, \
"harmony restrictions on generator declarations") \
#define HARMONY_SHIPPING(V) \
V(harmony_restrictive_generators, \
"harmony restrictions on generator declarations") \
V(harmony_object_rest_spread, "harmony object rest spread properties")
#ifdef V8_INTL_SUPPORT
#define HARMONY_SHIPPING(V) \
HARMONY_SHIPPING_BASE(V) \
V(icu_case_mapping, "case mapping with ICU rather than Unibrow")
#else
#define HARMONY_SHIPPING(V) HARMONY_SHIPPING_BASE(V)
#endif
// Once a shipping feature has proved stable in the wild, it will be dropped
// from HARMONY_SHIPPING, all occurrences of the FLAG_ variable are removed,
// and associated tests are moved from the harmony directory to the appropriate
......
......@@ -1991,7 +1991,7 @@ DEFINE_METHOD(
var StringPrototypeMethods = {};
DEFINE_METHODS_LEN(
StringPrototypeMethods,
GlobalString.prototype,
{
toLocaleLowerCase(locales) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
......@@ -2093,9 +2093,4 @@ DEFINE_METHOD(
}
);
utils.Export(function(to) {
to.ToLocaleLowerCaseIntl = StringPrototypeMethods.toLocaleLowerCase;
to.ToLocaleUpperCaseIntl = StringPrototypeMethods.toLocaleUpperCase;
});
})
......@@ -804,12 +804,14 @@ class Runtime : public AllStatic {
class RuntimeState {
public:
#ifndef V8_INTL_SUPPORT
unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
return &to_upper_mapping_;
}
unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
return &to_lower_mapping_;
}
#endif
Runtime::Function* redirected_intrinsic_functions() {
return redirected_intrinsic_functions_.get();
......@@ -822,8 +824,10 @@ class RuntimeState {
private:
RuntimeState() {}
#ifndef V8_INTL_SUPPORT
unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
#endif
std::unique_ptr<Runtime::Function[]> redirected_intrinsic_functions_;
......
......@@ -1171,8 +1171,7 @@ bool LineTerminator::Is(uchar c) {
return c == 0xA || c == 0xD || c == 0x2028 || c == 0x2029;
}
// TODO(jshin): Once icu_case_mapping flag is removed, enclose case-mapping
// related tables with #ifndef V8_INTL_SUPPORT.
#ifndef V8_INTL_SUPPORT
static const MultiCharacterSpecialCase<2> kToLowercaseMultiStrings0[2] = { // NOLINT
{{105, 775}}, {{kSentinel}} }; // NOLINT
static const uint16_t kToLowercaseTable0Size = 488; // NOLINT
......@@ -1782,6 +1781,7 @@ int ToUppercase::Convert(uchar c,
default: return 0;
}
}
#endif // !V8_INTL_SUPPORT
static const MultiCharacterSpecialCase<1> kEcma262CanonicalizeMultiStrings0[1] = { // NOLINT
{{kSentinel}} }; // NOLINT
......@@ -3289,9 +3289,6 @@ int UnicodeData::GetByteCount() {
+ kWhiteSpaceTable0Size * sizeof(int32_t) // NOLINT
+ kWhiteSpaceTable1Size * sizeof(int32_t) // NOLINT
+ kWhiteSpaceTable7Size * sizeof(int32_t) // NOLINT
#else
return
#endif // !V8_INTL_SUPPORT
+
kToLowercaseMultiStrings0Size *
sizeof(MultiCharacterSpecialCase<2>) // NOLINT
......@@ -3316,6 +3313,9 @@ int UnicodeData::GetByteCount() {
+
kToUppercaseMultiStrings7Size *
sizeof(MultiCharacterSpecialCase<3>) // NOLINT
#else
return
#endif // !V8_INTL_SUPPORT
+
kEcma262CanonicalizeMultiStrings0Size *
sizeof(MultiCharacterSpecialCase<1>) // NOLINT
......
......@@ -197,6 +197,7 @@ struct V8_EXPORT_PRIVATE WhiteSpace {
struct V8_EXPORT_PRIVATE LineTerminator {
static bool Is(uchar c);
};
#ifndef V8_INTL_SUPPORT
struct ToLowercase {
static const int kMaxWidth = 3;
static const bool kIsToLower = true;
......@@ -213,6 +214,7 @@ struct ToUppercase {
uchar* result,
bool* allow_caching_ptr);
};
#endif
struct Ecma262Canonicalize {
static const int kMaxWidth = 1;
static int Convert(uchar c,
......
......@@ -1596,6 +1596,7 @@ TEST(LatinCanonicalize) {
}
for (uc32 c = 128; c < (1 << 21); c++)
CHECK_GE(canonicalize(c), 128);
#ifndef V8_INTL_SUPPORT
unibrow::Mapping<unibrow::ToUppercase> to_upper;
// Canonicalization is only defined for the Basic Multilingual Plane.
for (uc32 c = 0; c < (1 << 16); c++) {
......@@ -1610,6 +1611,7 @@ TEST(LatinCanonicalize) {
u = c;
CHECK_EQ(u, canonicalize(c));
}
#endif
}
......
......@@ -1496,7 +1496,7 @@ static uint16_t ConvertLatin1(uint16_t c) {
return result[0];
}
#ifndef V8_INTL_SUPPORT
static void CheckCanonicalEquivalence(uint16_t c, uint16_t test) {
uint16_t expect = ConvertLatin1<unibrow::Ecma262UnCanonicalize, true>(c);
if (expect > unibrow::Latin1::kMaxChar) expect = 0;
......@@ -1536,7 +1536,7 @@ TEST(Latin1IgnoreCase) {
CHECK_EQ(Min(upper, lower), test);
}
}
#endif
class DummyResource: public v8::String::ExternalStringResource {
public:
......
......@@ -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: --icu_case_mapping
// Some edge cases that unibrow got wrong
assertEquals("𐐘", "𐑀".toUpperCase());
......
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