Commit b951f7f8 authored by machenbach's avatar machenbach Committed by Commit bot

Revert of [builtins] Also migrate String.prototype.toLowerCase/toUpperCase to...

Revert of [builtins] Also migrate String.prototype.toLowerCase/toUpperCase to C++. (patchset #2 id:20001 of https://codereview.chromium.org/2018983002/ )

Reason for revert:
Please rebase blink first (if intended):
https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Linux%2064/builds/7092

Original issue's description:
> [builtins] Also migrate String.prototype.toLowerCase/toUpperCase to C++.
>
> These builtins always call into C++ anyways and so there's no point in
> having the JavaScript wrapper around them, but instead they can be
> implemented as C++ builtins directly.
>
> R=franzih@chromium.org
> BUG=v8:5049
>
> Committed: https://crrev.com/4e66888869bf04c73b41e5747e4595747a7b20df
> Cr-Commit-Position: refs/heads/master@{#36569}

TBR=franzih@chromium.org,bmeurer@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:5049

Review-Url: https://codereview.chromium.org/2023753002
Cr-Commit-Position: refs/heads/master@{#36572}
parent e24f019b
......@@ -1340,17 +1340,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
1, true);
SimpleInstallFunction(prototype, "charCodeAt",
Builtins::kStringPrototypeCharCodeAt, 1, true);
// TODO(bmeurer): One day we will want to install the correct i18n functions
// here directly instead of first installing the dummy, and overriding those
// in i18n.js later.
SimpleInstallFunction(prototype, "toLocaleLowerCase",
Builtins::kStringPrototypeToLowerCase, 0, false);
SimpleInstallFunction(prototype, "toLocaleUpperCase",
Builtins::kStringPrototypeToUpperCase, 0, false);
SimpleInstallFunction(prototype, "toLowerCase",
Builtins::kStringPrototypeToLowerCase, 0, false);
SimpleInstallFunction(prototype, "toUpperCase",
Builtins::kStringPrototypeToUpperCase, 0, false);
SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0,
false);
SimpleInstallFunction(prototype, "trimLeft",
......
......@@ -4554,24 +4554,6 @@ void Builtins::Generate_StringPrototypeCharCodeAt(
assembler->Return(result);
}
// ES6 section 21.1.3.22 String.prototype.toLowerCase ( )
BUILTIN(StringPrototypeToLowerCase) {
HandleScope scope(isolate);
TO_THIS_STRING(string, "String.prototype.toLowerCase");
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string,
String::ToLowerCase(string));
return *string;
}
// ES6 section 21.1.3.24 String.prototype.toUpperCase ( )
BUILTIN(StringPrototypeToUpperCase) {
HandleScope scope(isolate);
TO_THIS_STRING(string, "String.prototype.toUpperCase");
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string,
String::ToUpperCase(string));
return *string;
}
// ES6 section 21.1.3.25 String.prototype.trim ()
BUILTIN(StringPrototypeTrim) {
HandleScope scope(isolate);
......
......@@ -172,8 +172,6 @@ inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) {
V(ReflectSetPrototypeOf, kNone) \
\
V(StringFromCharCode, kNone) \
V(StringPrototypeToLowerCase, kNone) \
V(StringPrototypeToUpperCase, kNone) \
V(StringPrototypeTrim, kNone) \
V(StringPrototypeTrimLeft, kNone) \
V(StringPrototypeTrimRight, kNone) \
......
......@@ -84,8 +84,6 @@ enum BindingFlags {
V(REFLECT_CONSTRUCT_INDEX, JSFunction, reflect_construct) \
V(REFLECT_DEFINE_PROPERTY_INDEX, JSFunction, reflect_define_property) \
V(REFLECT_DELETE_PROPERTY_INDEX, JSFunction, reflect_delete_property) \
V(STRING_TO_LOWER_CASE_INDEX, JSFunction, string_to_lower_case) \
V(STRING_TO_UPPER_CASE_INDEX, JSFunction, string_to_upper_case) \
V(SPREAD_ARGUMENTS_INDEX, JSFunction, spread_arguments) \
V(SPREAD_ITERABLE_INDEX, JSFunction, spread_iterable) \
V(MATH_FLOOR, JSFunction, math_floor) \
......
......@@ -46,8 +46,6 @@ var StringLastIndexOf;
var StringSplit;
var StringSubstr;
var StringSubstring;
var StringToLowerCase = GlobalString.prototype.toLowerCase;
var StringToUpperCase = GlobalString.prototype.toUpperCase;
utils.Import(function(from) {
ArrayIndexOf = from.ArrayIndexOf;
......@@ -695,8 +693,8 @@ function addWECPropertyIfDefined(object, property, value) {
* Returns titlecased word, aMeRricA -> America.
*/
function toTitleCaseWord(word) {
return %_Call(StringToUpperCase, %_Call(StringSubstr, word, 0, 1)) +
%_Call(StringToLowerCase, %_Call(StringSubstr, word, 1));
return %StringToUpperCase(%_Call(StringSubstr, word, 0, 1)) +
%StringToLowerCase(%_Call(StringSubstr, word, 1));
}
/**
......@@ -717,7 +715,7 @@ function toTitleCaseTimezoneLocation(location) {
var parts = %_Call(StringSplit, match[2], separator);
for (var i = 1; i < parts.length; i++) {
var part = parts[i]
var lowercasedPart = %_Call(StringToLowerCase, part);
var lowercasedPart = %StringToLowerCase(part);
result = result + separator +
((lowercasedPart !== 'es' &&
lowercasedPart !== 'of' && lowercasedPart !== 'au') ?
......@@ -1157,8 +1155,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
var currencyDisplay = getOption(
'currencyDisplay', 'string', ['code', 'symbol', 'name'], 'symbol');
if (internalOptions.style === 'currency') {
defineWEProperty(internalOptions, 'currency',
%_Call(StringToUpperCase, currency));
defineWEProperty(internalOptions, 'currency', %StringToUpperCase(currency));
defineWEProperty(internalOptions, 'currencyDisplay', currencyDisplay);
}
......@@ -1792,7 +1789,7 @@ function canonicalizeTimeZoneID(tzID) {
}
// Special case handling (UTC, GMT).
var upperID = %_Call(StringToUpperCase, tzID);
var upperID = %StringToUpperCase(tzID);
if (upperID === 'UTC' || upperID === 'GMT' ||
upperID === 'ETC/UTC' || upperID === 'ETC/GMT') {
return 'UTC';
......
......@@ -487,6 +487,38 @@ function StringSubstr(start, n) {
}
// ECMA-262, 15.5.4.16
function StringToLowerCaseJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
return %StringToLowerCase(TO_STRING(this));
}
// ECMA-262, 15.5.4.17
function StringToLocaleLowerCase() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
return %StringToLowerCase(TO_STRING(this));
}
// ECMA-262, 15.5.4.18
function StringToUpperCaseJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toUpperCase");
return %StringToUpperCase(TO_STRING(this));
}
// ECMA-262, 15.5.4.19
function StringToLocaleUpperCase() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleUpperCase");
return %StringToUpperCase(TO_STRING(this));
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1
function HtmlEscape(str) {
return %_Call(StringReplace, TO_STRING(str), /"/g, "&quot;");
......@@ -795,6 +827,10 @@ utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [
"substring", StringSubstring,
"substr", StringSubstr,
"startsWith", StringStartsWith,
"toLowerCase", StringToLowerCaseJS,
"toLocaleLowerCase", StringToLocaleLowerCase,
"toUpperCase", StringToUpperCaseJS,
"toLocaleUpperCase", StringToLocaleUpperCase,
"link", StringLink,
"anchor", StringAnchor,
......
This diff is collapsed.
......@@ -8861,12 +8861,6 @@ class String: public Name {
// Conversion.
inline bool AsArrayIndex(uint32_t* index);
// Case conversion.
static MaybeHandle<String> ToLowerCase(Handle<String> string)
WARN_UNUSED_RESULT;
static MaybeHandle<String> ToUpperCase(Handle<String> string)
WARN_UNUSED_RESULT;
// Trimming.
enum TrimMode { kTrim, kTrimLeft, kTrimRight };
static Handle<String> Trim(Handle<String> string, TrimMode mode);
......
This diff is collapsed.
......@@ -829,6 +829,8 @@ namespace internal {
F(StringBuilderJoin, 3, 1) \
F(SparseJoinWithSeparator, 3, 1) \
F(StringToArray, 2, 1) \
F(StringToLowerCase, 1, 1) \
F(StringToUpperCase, 1, 1) \
F(StringLessThan, 2, 1) \
F(StringLessThanOrEqual, 2, 1) \
F(StringGreaterThan, 2, 1) \
......
......@@ -80,7 +80,7 @@ bytecodes: [
/* 15 S> */ B(LdrUndefined), R(0),
B(CreateArrayLiteral), U8(0), U8(0), U8(3),
B(Star), R(1),
B(CallJSRuntime), U8(124), R(0), U8(2),
B(CallJSRuntime), U8(122), R(0), U8(2),
/* 44 S> */ B(Return),
]
constant pool: [
......
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