Commit a229c9b9 authored by adamk's avatar adamk Committed by Commit bot

Remove --harmony-array-includes flag

Array.prototype.includes shipped in Chrome 47.

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

Cr-Commit-Position: refs/heads/master@{#32818}
parent 819c429c
......@@ -281,7 +281,6 @@ action("js2c_experimental") {
"src/js/proxy.js",
"src/js/generator.js",
"src/js/harmony-atomics.js",
"src/js/harmony-array-includes.js",
"src/js/harmony-regexp.js",
"src/js/harmony-reflect.js",
"src/js/harmony-object-observe.js",
......
......@@ -2098,7 +2098,6 @@ void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
void Genesis::InitializeGlobal_##id() {}
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let)
......@@ -2622,8 +2621,6 @@ bool Genesis::InstallNatives(ContextType context_type) {
bool Genesis::InstallExperimentalNatives() {
static const char* harmony_array_includes_natives[] = {
"native harmony-array-includes.js", nullptr};
static const char* harmony_proxies_natives[] = {"native proxy.js", nullptr};
static const char* harmony_modules_natives[] = {nullptr};
static const char* harmony_regexps_natives[] = {"native harmony-regexp.js",
......
......@@ -220,7 +220,6 @@ DEFINE_IMPLICATION(es_staging, harmony_destructuring_assignment)
// Features that are shipping (turned on by default, but internal flag remains).
#define HARMONY_SHIPPING(V) \
V(harmony_array_includes, "harmony Array.prototype.includes") \
V(harmony_default_parameters, "harmony default parameters") \
V(harmony_destructuring_bind, "harmony destructuring bind") \
V(harmony_concat_spreadable, "harmony isConcatSpreadable") \
......
......@@ -29,6 +29,7 @@ var ObjectToString = utils.ImportNow("object_to_string");
var ObserveBeginPerformSplice;
var ObserveEndPerformSplice;
var ObserveEnqueueSpliceRecord;
var SameValueZero;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
......@@ -46,6 +47,7 @@ utils.Import(function(from) {
ObserveBeginPerformSplice = from.ObserveBeginPerformSplice;
ObserveEndPerformSplice = from.ObserveEndPerformSplice;
ObserveEnqueueSpliceRecord = from.ObserveEnqueueSpliceRecord;
SameValueZero = from.SameValueZero;
});
utils.ImportFromExperimental(function(from) {
......@@ -1694,6 +1696,47 @@ function ArrayFill(value, start, end) {
}
function InnerArrayIncludes(searchElement, fromIndex, array, length) {
if (length === 0) {
return false;
}
var n = TO_INTEGER(fromIndex);
var k;
if (n >= 0) {
k = n;
} else {
k = length + n;
if (k < 0) {
k = 0;
}
}
while (k < length) {
var elementK = array[k];
if (SameValueZero(searchElement, elementK)) {
return true;
}
++k;
}
return false;
}
// ES2016 draft, section 22.1.3.11
function ArrayIncludes(searchElement, fromIndex) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.includes");
var array = TO_OBJECT(this);
var length = TO_LENGTH(array.length);
return InnerArrayIncludes(searchElement, fromIndex, array, length);
}
function AddArrayElement(constructor, array, i, value) {
if (constructor === GlobalArray) {
AddIndexedProperty(array, i, value);
......@@ -1852,7 +1895,8 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2),
"find", getFunction("find", ArrayFind, 1),
"findIndex", getFunction("findIndex", ArrayFindIndex, 1),
"fill", getFunction("fill", ArrayFill, 1)
"fill", getFunction("fill", ArrayFill, 1),
"includes", getFunction("includes", ArrayIncludes, 1),
]);
%FinishArrayPrototypeSetup(GlobalArray.prototype);
......@@ -1904,6 +1948,7 @@ utils.Export(function(to) {
to.InnerArrayFind = InnerArrayFind;
to.InnerArrayFindIndex = InnerArrayFindIndex;
to.InnerArrayForEach = InnerArrayForEach;
to.InnerArrayIncludes = InnerArrayIncludes;
to.InnerArrayIndexOf = InnerArrayIndexOf;
to.InnerArrayJoin = InnerArrayJoin;
to.InnerArrayLastIndexOf = InnerArrayLastIndexOf;
......
// 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.
(function(global, utils) {
'use strict';
%CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalArray = global.Array;
var MakeTypeError;
var SameValueZero;
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
SameValueZero = from.SameValueZero;
});
// -------------------------------------------------------------------
// Proposed for ES7
// https://github.com/tc39/Array.prototype.includes
// 46c7532ec8499dea3e51aeb940d09e07547ed3f5
function InnerArrayIncludes(searchElement, fromIndex, array, length) {
if (length === 0) {
return false;
}
var n = TO_INTEGER(fromIndex);
var k;
if (n >= 0) {
k = n;
} else {
k = length + n;
if (k < 0) {
k = 0;
}
}
while (k < length) {
var elementK = array[k];
if (SameValueZero(searchElement, elementK)) {
return true;
}
++k;
}
return false;
}
function ArrayIncludes(searchElement, fromIndex) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.includes");
var array = TO_OBJECT(this);
var length = TO_LENGTH(array.length);
return InnerArrayIncludes(searchElement, fromIndex, array, length);
}
function TypedArrayIncludes(searchElement, fromIndex) {
if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
return InnerArrayIncludes(searchElement, fromIndex, this, length);
}
// -------------------------------------------------------------------
%FunctionSetLength(ArrayIncludes, 1);
%FunctionSetLength(TypedArrayIncludes, 1);
// Set up the non-enumerable function on the Array prototype object.
utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"includes", ArrayIncludes
]);
// Set up the non-enumerable function on the typed array prototypes.
// This duplicates some of the machinery in harmony-typedarray.js in order to
// keep includes behind the separate --harmony-array-includes flag.
// TODO(littledan): Fix the TypedArray proto chain (bug v8:4085).
macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(Uint8Array)
FUNCTION(Int8Array)
FUNCTION(Uint16Array)
FUNCTION(Int16Array)
FUNCTION(Uint32Array)
FUNCTION(Int32Array)
FUNCTION(Float32Array)
FUNCTION(Float64Array)
FUNCTION(Uint8ClampedArray)
endmacro
macro DECLARE_GLOBALS(NAME)
var GlobalNAME = global.NAME;
endmacro
macro EXTEND_TYPED_ARRAY(NAME)
// Set up non-enumerable functions on the prototype object.
utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
"includes", TypedArrayIncludes
]);
endmacro
TYPED_ARRAYS(DECLARE_GLOBALS)
TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
})
......@@ -25,6 +25,7 @@ var InnerArrayFilter;
var InnerArrayFind;
var InnerArrayFindIndex;
var InnerArrayForEach;
var InnerArrayIncludes;
var InnerArrayIndexOf;
var InnerArrayJoin;
var InnerArrayLastIndexOf;
......@@ -75,6 +76,7 @@ utils.Import(function(from) {
InnerArrayFind = from.InnerArrayFind;
InnerArrayFindIndex = from.InnerArrayFindIndex;
InnerArrayForEach = from.InnerArrayForEach;
InnerArrayIncludes = from.InnerArrayIncludes;
InnerArrayIndexOf = from.InnerArrayIndexOf;
InnerArrayJoin = from.InnerArrayJoin;
InnerArrayLastIndexOf = from.InnerArrayLastIndexOf;
......@@ -687,6 +689,17 @@ function TypedArraySlice(start, end) {
}
// ES2016 draft, section 22.2.3.14
function TypedArrayIncludes(searchElement, fromIndex) {
if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
return InnerArrayIncludes(searchElement, fromIndex, this, length);
}
%FunctionSetLength(TypedArrayIncludes, 1);
// ES6 draft 08-24-14, section 22.2.2.2
function TypedArrayOf() {
var length = %_ArgumentsLength();
......@@ -744,6 +757,7 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
"filter", TypedArrayFilter,
"find", TypedArrayFind,
"findIndex", TypedArrayFindIndex,
"includes", TypedArrayIncludes,
"indexOf", TypedArrayIndexOf,
"join", TypedArrayJoin,
"lastIndexOf", TypedArrayLastIndexOf,
......
......@@ -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-array-includes
// Ported from
// https://github.com/tc39/Array.prototype.includes/blob/master/test/number-this.js
// using https://www.npmjs.org/package/test262-to-mjsunit
......
......@@ -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-array-includes
// Ported from
// https://github.com/tc39/Array.prototype.includes/blob/master/test/number-this.js
// using https://www.npmjs.org/package/test262-to-mjsunit
......
......@@ -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-array-includes
// Largely ported from
// https://github.com/tc39/Array.prototype.includes/tree/master/test
// using https://www.npmjs.org/package/test262-to-mjsunit with further edits
......
......@@ -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-array-includes
// Largely ported from
// https://github.com/tc39/Array.prototype.includes/tree/master/test/built-ins/TypedArray/prototype/includes
// using https://www.npmjs.org/package/test262-to-mjsunit with further edits
......
......@@ -1906,7 +1906,6 @@
'../../src/js/proxy.js',
'../../src/js/generator.js',
'../../src/js/harmony-atomics.js',
'../../src/js/harmony-array-includes.js',
'../../src/js/harmony-regexp.js',
'../../src/js/harmony-reflect.js',
'../../src/js/harmony-object-observe.js',
......
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