Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: src/js/array.js

Issue 1513843006: Remove --harmony-array-includes flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | src/js/harmony-array-includes.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils, extrasUtils) { 5 (function(global, utils, extrasUtils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 11 matching lines...) Expand all
22 var MaxSimple; 22 var MaxSimple;
23 var MinSimple; 23 var MinSimple;
24 var ObjectDefineProperty; 24 var ObjectDefineProperty;
25 var ObjectHasOwnProperty; 25 var ObjectHasOwnProperty;
26 var ObjectIsFrozen; 26 var ObjectIsFrozen;
27 var ObjectIsSealed; 27 var ObjectIsSealed;
28 var ObjectToString = utils.ImportNow("object_to_string"); 28 var ObjectToString = utils.ImportNow("object_to_string");
29 var ObserveBeginPerformSplice; 29 var ObserveBeginPerformSplice;
30 var ObserveEndPerformSplice; 30 var ObserveEndPerformSplice;
31 var ObserveEnqueueSpliceRecord; 31 var ObserveEnqueueSpliceRecord;
32 var SameValueZero;
32 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 33 var iteratorSymbol = utils.ImportNow("iterator_symbol");
33 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); 34 var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
34 35
35 utils.Import(function(from) { 36 utils.Import(function(from) {
36 AddIndexedProperty = from.AddIndexedProperty; 37 AddIndexedProperty = from.AddIndexedProperty;
37 GetIterator = from.GetIterator; 38 GetIterator = from.GetIterator;
38 GetMethod = from.GetMethod; 39 GetMethod = from.GetMethod;
39 MakeTypeError = from.MakeTypeError; 40 MakeTypeError = from.MakeTypeError;
40 MaxSimple = from.MaxSimple; 41 MaxSimple = from.MaxSimple;
41 MinSimple = from.MinSimple; 42 MinSimple = from.MinSimple;
42 ObjectDefineProperty = from.ObjectDefineProperty; 43 ObjectDefineProperty = from.ObjectDefineProperty;
43 ObjectHasOwnProperty = from.ObjectHasOwnProperty; 44 ObjectHasOwnProperty = from.ObjectHasOwnProperty;
44 ObjectIsFrozen = from.ObjectIsFrozen; 45 ObjectIsFrozen = from.ObjectIsFrozen;
45 ObjectIsSealed = from.ObjectIsSealed; 46 ObjectIsSealed = from.ObjectIsSealed;
46 ObserveBeginPerformSplice = from.ObserveBeginPerformSplice; 47 ObserveBeginPerformSplice = from.ObserveBeginPerformSplice;
47 ObserveEndPerformSplice = from.ObserveEndPerformSplice; 48 ObserveEndPerformSplice = from.ObserveEndPerformSplice;
48 ObserveEnqueueSpliceRecord = from.ObserveEnqueueSpliceRecord; 49 ObserveEnqueueSpliceRecord = from.ObserveEnqueueSpliceRecord;
50 SameValueZero = from.SameValueZero;
49 }); 51 });
50 52
51 utils.ImportFromExperimental(function(from) { 53 utils.ImportFromExperimental(function(from) {
52 FLAG_harmony_tolength = from.FLAG_harmony_tolength; 54 FLAG_harmony_tolength = from.FLAG_harmony_tolength;
53 }); 55 });
54 56
55 // ------------------------------------------------------------------- 57 // -------------------------------------------------------------------
56 58
57 // Global list of arrays visited during toString, toLocaleString and 59 // Global list of arrays visited during toString, toLocaleString and
58 // join invocations. 60 // join invocations.
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 function ArrayFill(value, start, end) { 1689 function ArrayFill(value, start, end) {
1688 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill"); 1690 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill");
1689 1691
1690 var array = TO_OBJECT(this); 1692 var array = TO_OBJECT(this);
1691 var length = TO_LENGTH_OR_UINT32(array.length); 1693 var length = TO_LENGTH_OR_UINT32(array.length);
1692 1694
1693 return InnerArrayFill(value, start, end, array, length); 1695 return InnerArrayFill(value, start, end, array, length);
1694 } 1696 }
1695 1697
1696 1698
1699 function InnerArrayIncludes(searchElement, fromIndex, array, length) {
1700 if (length === 0) {
1701 return false;
1702 }
1703
1704 var n = TO_INTEGER(fromIndex);
1705
1706 var k;
1707 if (n >= 0) {
1708 k = n;
1709 } else {
1710 k = length + n;
1711 if (k < 0) {
1712 k = 0;
1713 }
1714 }
1715
1716 while (k < length) {
1717 var elementK = array[k];
1718 if (SameValueZero(searchElement, elementK)) {
1719 return true;
1720 }
1721
1722 ++k;
1723 }
1724
1725 return false;
1726 }
1727
1728
1729 // ES2016 draft, section 22.1.3.11
1730 function ArrayIncludes(searchElement, fromIndex) {
1731 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.includes");
1732
1733 var array = TO_OBJECT(this);
1734 var length = TO_LENGTH(array.length);
1735
1736 return InnerArrayIncludes(searchElement, fromIndex, array, length);
1737 }
1738
1739
1697 function AddArrayElement(constructor, array, i, value) { 1740 function AddArrayElement(constructor, array, i, value) {
1698 if (constructor === GlobalArray) { 1741 if (constructor === GlobalArray) {
1699 AddIndexedProperty(array, i, value); 1742 AddIndexedProperty(array, i, value);
1700 } else { 1743 } else {
1701 ObjectDefineProperty(array, i, { 1744 ObjectDefineProperty(array, i, {
1702 value: value, writable: true, configurable: true, enumerable: true 1745 value: value, writable: true, configurable: true, enumerable: true
1703 }); 1746 });
1704 } 1747 }
1705 } 1748 }
1706 1749
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 "some", getFunction("some", ArraySome, 1), 1888 "some", getFunction("some", ArraySome, 1),
1846 "every", getFunction("every", ArrayEvery, 1), 1889 "every", getFunction("every", ArrayEvery, 1),
1847 "map", getFunction("map", ArrayMap, 1), 1890 "map", getFunction("map", ArrayMap, 1),
1848 "indexOf", getFunction("indexOf", ArrayIndexOf, 1), 1891 "indexOf", getFunction("indexOf", ArrayIndexOf, 1),
1849 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), 1892 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1),
1850 "reduce", getFunction("reduce", ArrayReduce, 1), 1893 "reduce", getFunction("reduce", ArrayReduce, 1),
1851 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1), 1894 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1),
1852 "copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2), 1895 "copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2),
1853 "find", getFunction("find", ArrayFind, 1), 1896 "find", getFunction("find", ArrayFind, 1),
1854 "findIndex", getFunction("findIndex", ArrayFindIndex, 1), 1897 "findIndex", getFunction("findIndex", ArrayFindIndex, 1),
1855 "fill", getFunction("fill", ArrayFill, 1) 1898 "fill", getFunction("fill", ArrayFill, 1),
1899 "includes", getFunction("includes", ArrayIncludes, 1),
1856 ]); 1900 ]);
1857 1901
1858 %FinishArrayPrototypeSetup(GlobalArray.prototype); 1902 %FinishArrayPrototypeSetup(GlobalArray.prototype);
1859 1903
1860 // The internal Array prototype doesn't need to be fancy, since it's never 1904 // The internal Array prototype doesn't need to be fancy, since it's never
1861 // exposed to user code. 1905 // exposed to user code.
1862 // Adding only the functions that are actually used. 1906 // Adding only the functions that are actually used.
1863 utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [ 1907 utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [
1864 "indexOf", getFunction("indexOf", ArrayIndexOf), 1908 "indexOf", getFunction("indexOf", ArrayIndexOf),
1865 "join", getFunction("join", ArrayJoin), 1909 "join", getFunction("join", ArrayJoin),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 to.ArrayJoin = ArrayJoin; 1941 to.ArrayJoin = ArrayJoin;
1898 to.ArrayPush = ArrayPush; 1942 to.ArrayPush = ArrayPush;
1899 to.ArrayToString = ArrayToString; 1943 to.ArrayToString = ArrayToString;
1900 to.InnerArrayCopyWithin = InnerArrayCopyWithin; 1944 to.InnerArrayCopyWithin = InnerArrayCopyWithin;
1901 to.InnerArrayEvery = InnerArrayEvery; 1945 to.InnerArrayEvery = InnerArrayEvery;
1902 to.InnerArrayFill = InnerArrayFill; 1946 to.InnerArrayFill = InnerArrayFill;
1903 to.InnerArrayFilter = InnerArrayFilter; 1947 to.InnerArrayFilter = InnerArrayFilter;
1904 to.InnerArrayFind = InnerArrayFind; 1948 to.InnerArrayFind = InnerArrayFind;
1905 to.InnerArrayFindIndex = InnerArrayFindIndex; 1949 to.InnerArrayFindIndex = InnerArrayFindIndex;
1906 to.InnerArrayForEach = InnerArrayForEach; 1950 to.InnerArrayForEach = InnerArrayForEach;
1951 to.InnerArrayIncludes = InnerArrayIncludes;
1907 to.InnerArrayIndexOf = InnerArrayIndexOf; 1952 to.InnerArrayIndexOf = InnerArrayIndexOf;
1908 to.InnerArrayJoin = InnerArrayJoin; 1953 to.InnerArrayJoin = InnerArrayJoin;
1909 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf; 1954 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf;
1910 to.InnerArrayMap = InnerArrayMap; 1955 to.InnerArrayMap = InnerArrayMap;
1911 to.InnerArrayReduce = InnerArrayReduce; 1956 to.InnerArrayReduce = InnerArrayReduce;
1912 to.InnerArrayReduceRight = InnerArrayReduceRight; 1957 to.InnerArrayReduceRight = InnerArrayReduceRight;
1913 to.InnerArraySome = InnerArraySome; 1958 to.InnerArraySome = InnerArraySome;
1914 to.InnerArraySort = InnerArraySort; 1959 to.InnerArraySort = InnerArraySort;
1915 to.InnerArrayToLocaleString = InnerArrayToLocaleString; 1960 to.InnerArrayToLocaleString = InnerArrayToLocaleString;
1916 to.PackedArrayReverse = PackedArrayReverse; 1961 to.PackedArrayReverse = PackedArrayReverse;
1917 }); 1962 });
1918 1963
1919 %InstallToContext([ 1964 %InstallToContext([
1920 "array_pop", ArrayPop, 1965 "array_pop", ArrayPop,
1921 "array_push", ArrayPush, 1966 "array_push", ArrayPush,
1922 "array_shift", ArrayShift, 1967 "array_shift", ArrayShift,
1923 "array_splice", ArraySplice, 1968 "array_splice", ArraySplice,
1924 "array_slice", ArraySlice, 1969 "array_slice", ArraySlice,
1925 "array_unshift", ArrayUnshift, 1970 "array_unshift", ArrayUnshift,
1926 ]); 1971 ]);
1927 1972
1928 }); 1973 });
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/js/harmony-array-includes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698