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, ...@@ -1855,6 +1855,12 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kStringPrototypeTrimLeft, 0, false); Builtins::kStringPrototypeTrimLeft, 0, false);
SimpleInstallFunction(prototype, "trimRight", SimpleInstallFunction(prototype, "trimRight",
Builtins::kStringPrototypeTrimRight, 0, false); 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", SimpleInstallFunction(prototype, "toLocaleLowerCase",
Builtins::kStringPrototypeToLocaleLowerCase, 0, Builtins::kStringPrototypeToLocaleLowerCase, 0,
false); false);
...@@ -1865,6 +1871,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1865,6 +1871,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kStringPrototypeToLowerCase, 0, false); Builtins::kStringPrototypeToLowerCase, 0, false);
SimpleInstallFunction(prototype, "toUpperCase", SimpleInstallFunction(prototype, "toUpperCase",
Builtins::kStringPrototypeToUpperCase, 0, false); Builtins::kStringPrototypeToUpperCase, 0, false);
#endif
SimpleInstallFunction(prototype, "valueOf", SimpleInstallFunction(prototype, "valueOf",
Builtins::kStringPrototypeValueOf, 0, true); Builtins::kStringPrototypeValueOf, 0, true);
...@@ -4155,59 +4162,6 @@ void Genesis::InitializeGlobal_harmony_regexp_dotall() { ...@@ -4155,59 +4162,6 @@ void Genesis::InitializeGlobal_harmony_regexp_dotall() {
native_context()->set_regexp_prototype_map(*prototype_map); 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, Handle<JSFunction> Genesis::CreateArrayBuffer(Handle<String> name,
Builtins::Name call_byteLength, Builtins::Name call_byteLength,
BuiltinFunctionId byteLength_id, BuiltinFunctionId byteLength_id,
......
...@@ -917,14 +917,6 @@ namespace internal { ...@@ -917,14 +917,6 @@ namespace internal {
CPP(StringPrototypeStartsWith) \ CPP(StringPrototypeStartsWith) \
/* ES6 #sec-string.prototype.tostring */ \ /* ES6 #sec-string.prototype.tostring */ \
TFJ(StringPrototypeToString, 0) \ 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(StringPrototypeTrim) \
CPP(StringPrototypeTrimLeft) \ CPP(StringPrototypeTrimLeft) \
CPP(StringPrototypeTrimRight) \ CPP(StringPrototypeTrimRight) \
...@@ -1077,7 +1069,15 @@ namespace internal { ...@@ -1077,7 +1069,15 @@ namespace internal {
BUILTIN_LIST_BASE(CPP, API, TFJ, TFC, TFS, TFH, ASM, DBG) \ BUILTIN_LIST_BASE(CPP, API, TFJ, TFC, TFS, TFH, ASM, DBG) \
\ \
/* no-op fallback version */ \ /* 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 #endif // V8_INTL_SUPPORT
// The exception thrown in the following builtins are caught // The exception thrown in the following builtins are caught
......
...@@ -368,6 +368,7 @@ BUILTIN(StringPrototypeTrimRight) { ...@@ -368,6 +368,7 @@ BUILTIN(StringPrototypeTrimRight) {
return *String::Trim(string, String::kTrimRight); return *String::Trim(string, String::kTrimRight);
} }
#ifndef V8_INTL_SUPPORT
namespace { namespace {
inline bool ToUpperOverflows(uc32 character) { inline bool ToUpperOverflows(uc32 character) {
...@@ -559,6 +560,7 @@ BUILTIN(StringPrototypeToUpperCase) { ...@@ -559,6 +560,7 @@ BUILTIN(StringPrototypeToUpperCase) {
return ConvertCase(string, isolate, return ConvertCase(string, isolate,
isolate->runtime_state()->to_upper_mapping()); isolate->runtime_state()->to_upper_mapping());
} }
#endif // !V8_INTL_SUPPORT
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -606,8 +606,10 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) { ...@@ -606,8 +606,10 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
case Builtins::kStringPrototypeSubstr: case Builtins::kStringPrototypeSubstr:
case Builtins::kStringPrototypeSubstring: case Builtins::kStringPrototypeSubstring:
case Builtins::kStringPrototypeToString: case Builtins::kStringPrototypeToString:
#ifndef V8_INTL_SUPPORT
case Builtins::kStringPrototypeToLowerCase: case Builtins::kStringPrototypeToLowerCase:
case Builtins::kStringPrototypeToUpperCase: case Builtins::kStringPrototypeToUpperCase:
#endif
case Builtins::kStringPrototypeTrim: case Builtins::kStringPrototypeTrim:
case Builtins::kStringPrototypeTrimLeft: case Builtins::kStringPrototypeTrimLeft:
case Builtins::kStringPrototypeTrimRight: case Builtins::kStringPrototypeTrimRight:
......
...@@ -216,19 +216,11 @@ DEFINE_IMPLICATION(es_staging, harmony) ...@@ -216,19 +216,11 @@ DEFINE_IMPLICATION(es_staging, harmony)
"constructor") "constructor")
// Features that are shipping (turned on by default, but internal flag remains). // Features that are shipping (turned on by default, but internal flag remains).
#define HARMONY_SHIPPING_BASE(V) \ #define HARMONY_SHIPPING(V) \
V(harmony_restrictive_generators, \ V(harmony_restrictive_generators, \
"harmony restrictions on generator declarations") \ "harmony restrictions on generator declarations") \
V(harmony_object_rest_spread, "harmony object rest spread properties") 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 // 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, // from HARMONY_SHIPPING, all occurrences of the FLAG_ variable are removed,
// and associated tests are moved from the harmony directory to the appropriate // and associated tests are moved from the harmony directory to the appropriate
......
...@@ -1991,7 +1991,7 @@ DEFINE_METHOD( ...@@ -1991,7 +1991,7 @@ DEFINE_METHOD(
var StringPrototypeMethods = {}; var StringPrototypeMethods = {};
DEFINE_METHODS_LEN( DEFINE_METHODS_LEN(
StringPrototypeMethods, GlobalString.prototype,
{ {
toLocaleLowerCase(locales) { toLocaleLowerCase(locales) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase"); CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
...@@ -2093,9 +2093,4 @@ DEFINE_METHOD( ...@@ -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 { ...@@ -804,12 +804,14 @@ class Runtime : public AllStatic {
class RuntimeState { class RuntimeState {
public: public:
#ifndef V8_INTL_SUPPORT
unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() { unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
return &to_upper_mapping_; return &to_upper_mapping_;
} }
unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() { unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
return &to_lower_mapping_; return &to_lower_mapping_;
} }
#endif
Runtime::Function* redirected_intrinsic_functions() { Runtime::Function* redirected_intrinsic_functions() {
return redirected_intrinsic_functions_.get(); return redirected_intrinsic_functions_.get();
...@@ -822,8 +824,10 @@ class RuntimeState { ...@@ -822,8 +824,10 @@ class RuntimeState {
private: private:
RuntimeState() {} RuntimeState() {}
#ifndef V8_INTL_SUPPORT
unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_; unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_; unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
#endif
std::unique_ptr<Runtime::Function[]> redirected_intrinsic_functions_; std::unique_ptr<Runtime::Function[]> redirected_intrinsic_functions_;
......
...@@ -1171,8 +1171,7 @@ bool LineTerminator::Is(uchar c) { ...@@ -1171,8 +1171,7 @@ bool LineTerminator::Is(uchar c) {
return c == 0xA || c == 0xD || c == 0x2028 || c == 0x2029; return c == 0xA || c == 0xD || c == 0x2028 || c == 0x2029;
} }
// TODO(jshin): Once icu_case_mapping flag is removed, enclose case-mapping #ifndef V8_INTL_SUPPORT
// related tables with #ifndef V8_INTL_SUPPORT.
static const MultiCharacterSpecialCase<2> kToLowercaseMultiStrings0[2] = { // NOLINT static const MultiCharacterSpecialCase<2> kToLowercaseMultiStrings0[2] = { // NOLINT
{{105, 775}}, {{kSentinel}} }; // NOLINT {{105, 775}}, {{kSentinel}} }; // NOLINT
static const uint16_t kToLowercaseTable0Size = 488; // NOLINT static const uint16_t kToLowercaseTable0Size = 488; // NOLINT
...@@ -1782,6 +1781,7 @@ int ToUppercase::Convert(uchar c, ...@@ -1782,6 +1781,7 @@ int ToUppercase::Convert(uchar c,
default: return 0; default: return 0;
} }
} }
#endif // !V8_INTL_SUPPORT
static const MultiCharacterSpecialCase<1> kEcma262CanonicalizeMultiStrings0[1] = { // NOLINT static const MultiCharacterSpecialCase<1> kEcma262CanonicalizeMultiStrings0[1] = { // NOLINT
{{kSentinel}} }; // NOLINT {{kSentinel}} }; // NOLINT
...@@ -3289,9 +3289,6 @@ int UnicodeData::GetByteCount() { ...@@ -3289,9 +3289,6 @@ int UnicodeData::GetByteCount() {
+ kWhiteSpaceTable0Size * sizeof(int32_t) // NOLINT + kWhiteSpaceTable0Size * sizeof(int32_t) // NOLINT
+ kWhiteSpaceTable1Size * sizeof(int32_t) // NOLINT + kWhiteSpaceTable1Size * sizeof(int32_t) // NOLINT
+ kWhiteSpaceTable7Size * sizeof(int32_t) // NOLINT + kWhiteSpaceTable7Size * sizeof(int32_t) // NOLINT
#else
return
#endif // !V8_INTL_SUPPORT
+ +
kToLowercaseMultiStrings0Size * kToLowercaseMultiStrings0Size *
sizeof(MultiCharacterSpecialCase<2>) // NOLINT sizeof(MultiCharacterSpecialCase<2>) // NOLINT
...@@ -3316,6 +3313,9 @@ int UnicodeData::GetByteCount() { ...@@ -3316,6 +3313,9 @@ int UnicodeData::GetByteCount() {
+ +
kToUppercaseMultiStrings7Size * kToUppercaseMultiStrings7Size *
sizeof(MultiCharacterSpecialCase<3>) // NOLINT sizeof(MultiCharacterSpecialCase<3>) // NOLINT
#else
return
#endif // !V8_INTL_SUPPORT
+ +
kEcma262CanonicalizeMultiStrings0Size * kEcma262CanonicalizeMultiStrings0Size *
sizeof(MultiCharacterSpecialCase<1>) // NOLINT sizeof(MultiCharacterSpecialCase<1>) // NOLINT
......
...@@ -197,6 +197,7 @@ struct V8_EXPORT_PRIVATE WhiteSpace { ...@@ -197,6 +197,7 @@ struct V8_EXPORT_PRIVATE WhiteSpace {
struct V8_EXPORT_PRIVATE LineTerminator { struct V8_EXPORT_PRIVATE LineTerminator {
static bool Is(uchar c); static bool Is(uchar c);
}; };
#ifndef V8_INTL_SUPPORT
struct ToLowercase { struct ToLowercase {
static const int kMaxWidth = 3; static const int kMaxWidth = 3;
static const bool kIsToLower = true; static const bool kIsToLower = true;
...@@ -213,6 +214,7 @@ struct ToUppercase { ...@@ -213,6 +214,7 @@ struct ToUppercase {
uchar* result, uchar* result,
bool* allow_caching_ptr); bool* allow_caching_ptr);
}; };
#endif
struct Ecma262Canonicalize { struct Ecma262Canonicalize {
static const int kMaxWidth = 1; static const int kMaxWidth = 1;
static int Convert(uchar c, static int Convert(uchar c,
......
...@@ -1596,6 +1596,7 @@ TEST(LatinCanonicalize) { ...@@ -1596,6 +1596,7 @@ TEST(LatinCanonicalize) {
} }
for (uc32 c = 128; c < (1 << 21); c++) for (uc32 c = 128; c < (1 << 21); c++)
CHECK_GE(canonicalize(c), 128); CHECK_GE(canonicalize(c), 128);
#ifndef V8_INTL_SUPPORT
unibrow::Mapping<unibrow::ToUppercase> to_upper; unibrow::Mapping<unibrow::ToUppercase> to_upper;
// Canonicalization is only defined for the Basic Multilingual Plane. // Canonicalization is only defined for the Basic Multilingual Plane.
for (uc32 c = 0; c < (1 << 16); c++) { for (uc32 c = 0; c < (1 << 16); c++) {
...@@ -1610,6 +1611,7 @@ TEST(LatinCanonicalize) { ...@@ -1610,6 +1611,7 @@ TEST(LatinCanonicalize) {
u = c; u = c;
CHECK_EQ(u, canonicalize(c)); CHECK_EQ(u, canonicalize(c));
} }
#endif
} }
......
...@@ -1496,7 +1496,7 @@ static uint16_t ConvertLatin1(uint16_t c) { ...@@ -1496,7 +1496,7 @@ static uint16_t ConvertLatin1(uint16_t c) {
return result[0]; return result[0];
} }
#ifndef V8_INTL_SUPPORT
static void CheckCanonicalEquivalence(uint16_t c, uint16_t test) { static void CheckCanonicalEquivalence(uint16_t c, uint16_t test) {
uint16_t expect = ConvertLatin1<unibrow::Ecma262UnCanonicalize, true>(c); uint16_t expect = ConvertLatin1<unibrow::Ecma262UnCanonicalize, true>(c);
if (expect > unibrow::Latin1::kMaxChar) expect = 0; if (expect > unibrow::Latin1::kMaxChar) expect = 0;
...@@ -1536,7 +1536,7 @@ TEST(Latin1IgnoreCase) { ...@@ -1536,7 +1536,7 @@ TEST(Latin1IgnoreCase) {
CHECK_EQ(Min(upper, lower), test); CHECK_EQ(Min(upper, lower), test);
} }
} }
#endif
class DummyResource: public v8::String::ExternalStringResource { class DummyResource: public v8::String::ExternalStringResource {
public: public:
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --icu_case_mapping
// Some edge cases that unibrow got wrong // Some edge cases that unibrow got wrong
assertEquals("𐐘", "𐑀".toUpperCase()); 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