Remove harmony-strings flag.

String functions are shipping since 4.1/Chrome M41, it is time to unflag.

R=yanngguo@chromium.org,rossberg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1024813002

Cr-Commit-Position: refs/heads/master@{#27337}
This commit is contained in:
dslomov 2015-03-20 03:43:32 -07:00 committed by Commit bot
parent 3072ac5349
commit af04fdfec8
14 changed files with 169 additions and 222 deletions

View File

@ -259,7 +259,6 @@ action("js2c_experimental") {
"src/macros.py",
"src/proxy.js",
"src/generator.js",
"src/harmony-string.js",
"src/harmony-array.js",
"src/harmony-array-includes.js",
"src/harmony-typedarray.js",

View File

@ -1652,7 +1652,6 @@ void Genesis::InitializeBuiltinTypedArrays() {
void Genesis::InstallNativeFunctions_##id() {}
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_modules)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_strings)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrays)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_array_includes)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_classes)
@ -1685,7 +1684,6 @@ void Genesis::InstallNativeFunctions_harmony_proxies() {
void Genesis::InitializeGlobal_##id() {}
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_strings)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrays)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_classes)
@ -2308,8 +2306,6 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_array_includes_natives[] = {
"native harmony-array-includes.js", NULL};
static const char* harmony_proxies_natives[] = {"native proxy.js", NULL};
static const char* harmony_strings_natives[] = {"native harmony-string.js",
NULL};
static const char* harmony_classes_natives[] = {NULL};
static const char* harmony_modules_natives[] = {NULL};
static const char* harmony_object_literals_natives[] = {NULL};

View File

@ -203,7 +203,6 @@ DEFINE_IMPLICATION(es_staging, harmony)
// Features that are shipping (turned on by default, but internal flag remains).
#define HARMONY_SHIPPING(V) \
V(harmony_numeric_literals, "harmony numeric literals") \
V(harmony_strings, "harmony string methods") \
V(harmony_templates, "harmony template literals") \
V(harmony_classes, "harmony classes (implies object literal extension)") \
V(harmony_object_literals, "harmony object literal extensions")

View File

@ -1,194 +0,0 @@
// Copyright 2014 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.
"use strict";
// This file relies on the fact that the following declaration has been made
// in runtime.js:
// var $String = global.String;
// var $Array = global.Array;
// -------------------------------------------------------------------
// ES6 draft 01-20-14, section 21.1.3.13
function StringRepeat(count) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.repeat");
var s = TO_STRING_INLINE(this);
var n = ToInteger(count);
// The maximum string length is stored in a smi, so a longer repeat
// must result in a range error.
if (n < 0 || n > %_MaxSmi()) {
throw MakeRangeError("invalid_count_value", []);
}
var r = "";
while (true) {
if (n & 1) r += s;
n >>= 1;
if (n === 0) return r;
s += s;
}
}
// ES6 draft 04-05-14, section 21.1.3.18
function StringStartsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.startsWith");
var s = TO_STRING_INLINE(this);
if (IS_REGEXP(searchString)) {
throw MakeTypeError("first_argument_not_regexp",
["String.prototype.startsWith"]);
}
var ss = TO_STRING_INLINE(searchString);
var pos = 0;
if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position
pos = ToInteger(pos);
}
var s_len = s.length;
var start = $min($max(pos, 0), s_len);
var ss_len = ss.length;
if (ss_len + start > s_len) {
return false;
}
return %StringIndexOf(s, ss, start) === start;
}
// ES6 draft 04-05-14, section 21.1.3.7
function StringEndsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith");
var s = TO_STRING_INLINE(this);
if (IS_REGEXP(searchString)) {
throw MakeTypeError("first_argument_not_regexp",
["String.prototype.endsWith"]);
}
var ss = TO_STRING_INLINE(searchString);
var s_len = s.length;
var pos = s_len;
if (%_ArgumentsLength() > 1) {
var arg = %_Arguments(1); // position
if (!IS_UNDEFINED(arg)) {
pos = ToInteger(arg);
}
}
var end = $min($max(pos, 0), s_len);
var ss_len = ss.length;
var start = end - ss_len;
if (start < 0) {
return false;
}
return %StringLastIndexOf(s, ss, start) === start;
}
// ES6 draft 04-05-14, section 21.1.3.6
function StringIncludes(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes");
var s = TO_STRING_INLINE(this);
if (IS_REGEXP(searchString)) {
throw MakeTypeError("first_argument_not_regexp",
["String.prototype.includes"]);
}
var ss = TO_STRING_INLINE(searchString);
var pos = 0;
if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position
pos = ToInteger(pos);
}
var s_len = s.length;
var start = $min($max(pos, 0), s_len);
var ss_len = ss.length;
if (ss_len + start > s_len) {
return false;
}
return %StringIndexOf(s, ss, start) !== -1;
}
// ES6 Draft 05-22-2014, section 21.1.3.3
function StringCodePointAt(pos) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.codePointAt");
var string = TO_STRING_INLINE(this);
var size = string.length;
pos = TO_INTEGER(pos);
if (pos < 0 || pos >= size) {
return UNDEFINED;
}
var first = %_StringCharCodeAt(string, pos);
if (first < 0xD800 || first > 0xDBFF || pos + 1 == size) {
return first;
}
var second = %_StringCharCodeAt(string, pos + 1);
if (second < 0xDC00 || second > 0xDFFF) {
return first;
}
return (first - 0xD800) * 0x400 + second + 0x2400;
}
// ES6 Draft 05-22-2014, section 21.1.2.2
function StringFromCodePoint(_) { // length = 1
var code;
var length = %_ArgumentsLength();
var index;
var result = "";
for (index = 0; index < length; index++) {
code = %_Arguments(index);
if (!%_IsSmi(code)) {
code = ToNumber(code);
}
if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) {
throw MakeRangeError("invalid_code_point", [code]);
}
if (code <= 0xFFFF) {
result += %_StringCharFromCode(code);
} else {
code -= 0x10000;
result += %_StringCharFromCode((code >>> 10) & 0x3FF | 0xD800);
result += %_StringCharFromCode(code & 0x3FF | 0xDC00);
}
}
return result;
}
// -------------------------------------------------------------------
function ExtendStringPrototype() {
%CheckIsBootstrapping();
// Set up the non-enumerable functions on the String object.
InstallFunctions($String, DONT_ENUM, $Array(
"fromCodePoint", StringFromCodePoint
));
// Set up the non-enumerable functions on the String prototype object.
InstallFunctions($String.prototype, DONT_ENUM, $Array(
"codePointAt", StringCodePointAt,
"includes", StringIncludes,
"endsWith", StringEndsWith,
"repeat", StringRepeat,
"startsWith", StringStartsWith
));
}
ExtendStringPrototype();

View File

@ -931,6 +931,167 @@ function StringSup() {
return "<sup>" + this + "</sup>";
}
// ES6 draft 01-20-14, section 21.1.3.13
function StringRepeat(count) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.repeat");
var s = TO_STRING_INLINE(this);
var n = ToInteger(count);
// The maximum string length is stored in a smi, so a longer repeat
// must result in a range error.
if (n < 0 || n > %_MaxSmi()) {
throw MakeRangeError("invalid_count_value", []);
}
var r = "";
while (true) {
if (n & 1) r += s;
n >>= 1;
if (n === 0) return r;
s += s;
}
}
// ES6 draft 04-05-14, section 21.1.3.18
function StringStartsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.startsWith");
var s = TO_STRING_INLINE(this);
if (IS_REGEXP(searchString)) {
throw MakeTypeError("first_argument_not_regexp",
["String.prototype.startsWith"]);
}
var ss = TO_STRING_INLINE(searchString);
var pos = 0;
if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position
pos = ToInteger(pos);
}
var s_len = s.length;
var start = $min($max(pos, 0), s_len);
var ss_len = ss.length;
if (ss_len + start > s_len) {
return false;
}
return %StringIndexOf(s, ss, start) === start;
}
// ES6 draft 04-05-14, section 21.1.3.7
function StringEndsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith");
var s = TO_STRING_INLINE(this);
if (IS_REGEXP(searchString)) {
throw MakeTypeError("first_argument_not_regexp",
["String.prototype.endsWith"]);
}
var ss = TO_STRING_INLINE(searchString);
var s_len = s.length;
var pos = s_len;
if (%_ArgumentsLength() > 1) {
var arg = %_Arguments(1); // position
if (!IS_UNDEFINED(arg)) {
pos = ToInteger(arg);
}
}
var end = $min($max(pos, 0), s_len);
var ss_len = ss.length;
var start = end - ss_len;
if (start < 0) {
return false;
}
return %StringLastIndexOf(s, ss, start) === start;
}
// ES6 draft 04-05-14, section 21.1.3.6
function StringIncludes(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes");
var s = TO_STRING_INLINE(this);
if (IS_REGEXP(searchString)) {
throw MakeTypeError("first_argument_not_regexp",
["String.prototype.includes"]);
}
var ss = TO_STRING_INLINE(searchString);
var pos = 0;
if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position
pos = ToInteger(pos);
}
var s_len = s.length;
var start = $min($max(pos, 0), s_len);
var ss_len = ss.length;
if (ss_len + start > s_len) {
return false;
}
return %StringIndexOf(s, ss, start) !== -1;
}
// ES6 Draft 05-22-2014, section 21.1.3.3
function StringCodePointAt(pos) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.codePointAt");
var string = TO_STRING_INLINE(this);
var size = string.length;
pos = TO_INTEGER(pos);
if (pos < 0 || pos >= size) {
return UNDEFINED;
}
var first = %_StringCharCodeAt(string, pos);
if (first < 0xD800 || first > 0xDBFF || pos + 1 == size) {
return first;
}
var second = %_StringCharCodeAt(string, pos + 1);
if (second < 0xDC00 || second > 0xDFFF) {
return first;
}
return (first - 0xD800) * 0x400 + second + 0x2400;
}
// ES6 Draft 05-22-2014, section 21.1.2.2
function StringFromCodePoint(_) { // length = 1
var code;
var length = %_ArgumentsLength();
var index;
var result = "";
for (index = 0; index < length; index++) {
code = %_Arguments(index);
if (!%_IsSmi(code)) {
code = ToNumber(code);
}
if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) {
throw MakeRangeError("invalid_code_point", [code]);
}
if (code <= 0xFFFF) {
result += %_StringCharFromCode(code);
} else {
code -= 0x10000;
result += %_StringCharFromCode((code >>> 10) & 0x3FF | 0xD800);
result += %_StringCharFromCode(code & 0x3FF | 0xDC00);
}
}
return result;
}
// -------------------------------------------------------------------
// Set the String function and constructor.
@ -943,7 +1104,8 @@ function StringSup() {
// Set up the non-enumerable functions on the String object.
InstallFunctions(GlobalString, DONT_ENUM, GlobalArray(
"fromCharCode", StringFromCharCode
"fromCharCode", StringFromCharCode,
"fromCodePoint", StringFromCodePoint
));
// Set up the non-enumerable functions on the String prototype object.
@ -952,18 +1114,23 @@ InstallFunctions(GlobalString.prototype, DONT_ENUM, GlobalArray(
"toString", StringToString,
"charAt", StringCharAtJS,
"charCodeAt", StringCharCodeAtJS,
"codePointAt", StringCodePointAt,
"concat", StringConcat,
"endsWith", StringEndsWith,
"includes", StringIncludes,
"indexOf", StringIndexOfJS,
"lastIndexOf", StringLastIndexOfJS,
"localeCompare", StringLocaleCompareJS,
"match", StringMatchJS,
"normalize", StringNormalizeJS,
"repeat", StringRepeat,
"replace", StringReplace,
"search", StringSearch,
"slice", StringSlice,
"split", StringSplitJS,
"substring", StringSubstring,
"substr", StringSubstr,
"startsWith", StringStartsWith,
"toLowerCase", StringToLowerCaseJS,
"toLocaleLowerCase", StringToLocaleLowerCase,
"toUpperCase", StringToUpperCaseJS,
@ -971,6 +1138,7 @@ InstallFunctions(GlobalString.prototype, DONT_ENUM, GlobalArray(
"trim", StringTrimJS,
"trimLeft", StringTrimLeft,
"trimRight", StringTrimRight,
"link", StringLink,
"anchor", StringAnchor,
"fontcolor", StringFontcolor,

View File

@ -60,7 +60,6 @@
"path": ["Strings"],
"main": "run.js",
"resources": ["harmony-string.js"],
"flags": ["--harmony-strings"],
"results_regexp": "^%s\\-Strings\\(Score\\): (.+)$",
"tests": [
{"name": "StringFunctions"}

View File

@ -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-strings
// Tests taken from:
// https://github.com/mathiasbynens/String.prototype.codePointAt

View File

@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-strings
assertEquals(1, String.prototype.endsWith.length);
var testString = "Hello World";

View File

@ -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-strings
// Tests taken from:
// https://github.com/mathiasbynens/String.fromCodePoint

View File

@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-strings
assertEquals(1, String.prototype.includes.length);
var reString = "asdf[a-z]+(asdf)?";

View File

@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-strings
assertEquals("000", String.prototype.repeat.call(0, 3));
assertEquals("-1-1-1", String.prototype.repeat.call(-1, 3));
assertEquals("2.12.12.1", String.prototype.repeat.call(2.1, 3));

View File

@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-strings
assertEquals(1, String.prototype.startsWith.length);
var testString = "Hello World";

View File

@ -1,7 +0,0 @@
// Copyright 2014 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: --noharmony-strings
assertEquals(undefined, String.prototype.includes);

View File

@ -1713,7 +1713,6 @@
'../../src/macros.py',
'../../src/proxy.js',
'../../src/generator.js',
'../../src/harmony-string.js',
'../../src/harmony-array.js',
'../../src/harmony-array-includes.js',
'../../src/harmony-tostring.js',