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

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

Issue 2146293003: [builtins] implement Array.prototype.includes in TurboFan (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix BranchIfSimd128Equal Created 4 years, 4 months 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 10 matching lines...) Expand all
21 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype; 21 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype;
22 var GlobalDataView = global.DataView; 22 var GlobalDataView = global.DataView;
23 var GlobalObject = global.Object; 23 var GlobalObject = global.Object;
24 var InnerArrayCopyWithin; 24 var InnerArrayCopyWithin;
25 var InnerArrayEvery; 25 var InnerArrayEvery;
26 var InnerArrayFill; 26 var InnerArrayFill;
27 var InnerArrayFilter; 27 var InnerArrayFilter;
28 var InnerArrayFind; 28 var InnerArrayFind;
29 var InnerArrayFindIndex; 29 var InnerArrayFindIndex;
30 var InnerArrayForEach; 30 var InnerArrayForEach;
31 var InnerArrayIncludes;
32 var InnerArrayIndexOf; 31 var InnerArrayIndexOf;
33 var InnerArrayJoin; 32 var InnerArrayJoin;
34 var InnerArrayLastIndexOf; 33 var InnerArrayLastIndexOf;
35 var InnerArrayReduce; 34 var InnerArrayReduce;
36 var InnerArrayReduceRight; 35 var InnerArrayReduceRight;
37 var InnerArraySome; 36 var InnerArraySome;
38 var InnerArraySort; 37 var InnerArraySort;
39 var InnerArrayToLocaleString; 38 var InnerArrayToLocaleString;
40 var InternalArray = utils.InternalArray; 39 var InternalArray = utils.InternalArray;
41 var IsNaN; 40 var IsNaN;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ArrayValues = from.ArrayValues; 74 ArrayValues = from.ArrayValues;
76 GetIterator = from.GetIterator; 75 GetIterator = from.GetIterator;
77 GetMethod = from.GetMethod; 76 GetMethod = from.GetMethod;
78 InnerArrayCopyWithin = from.InnerArrayCopyWithin; 77 InnerArrayCopyWithin = from.InnerArrayCopyWithin;
79 InnerArrayEvery = from.InnerArrayEvery; 78 InnerArrayEvery = from.InnerArrayEvery;
80 InnerArrayFill = from.InnerArrayFill; 79 InnerArrayFill = from.InnerArrayFill;
81 InnerArrayFilter = from.InnerArrayFilter; 80 InnerArrayFilter = from.InnerArrayFilter;
82 InnerArrayFind = from.InnerArrayFind; 81 InnerArrayFind = from.InnerArrayFind;
83 InnerArrayFindIndex = from.InnerArrayFindIndex; 82 InnerArrayFindIndex = from.InnerArrayFindIndex;
84 InnerArrayForEach = from.InnerArrayForEach; 83 InnerArrayForEach = from.InnerArrayForEach;
85 InnerArrayIncludes = from.InnerArrayIncludes;
86 InnerArrayIndexOf = from.InnerArrayIndexOf; 84 InnerArrayIndexOf = from.InnerArrayIndexOf;
87 InnerArrayJoin = from.InnerArrayJoin; 85 InnerArrayJoin = from.InnerArrayJoin;
88 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; 86 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf;
89 InnerArrayReduce = from.InnerArrayReduce; 87 InnerArrayReduce = from.InnerArrayReduce;
90 InnerArrayReduceRight = from.InnerArrayReduceRight; 88 InnerArrayReduceRight = from.InnerArrayReduceRight;
91 InnerArraySome = from.InnerArraySome; 89 InnerArraySome = from.InnerArraySome;
92 InnerArraySort = from.InnerArraySort; 90 InnerArraySort = from.InnerArraySort;
93 InnerArrayToLocaleString = from.InnerArrayToLocaleString; 91 InnerArrayToLocaleString = from.InnerArrayToLocaleString;
94 IsNaN = from.IsNaN; 92 IsNaN = from.IsNaN;
95 MakeRangeError = from.MakeRangeError; 93 MakeRangeError = from.MakeRangeError;
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 return array; 704 return array;
707 } 705 }
708 706
709 707
710 // ES2016 draft, section 22.2.3.14 708 // ES2016 draft, section 22.2.3.14
711 function TypedArrayIncludes(searchElement, fromIndex) { 709 function TypedArrayIncludes(searchElement, fromIndex) {
712 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); 710 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
713 711
714 var length = %_TypedArrayGetLength(this); 712 var length = %_TypedArrayGetLength(this);
715 713
716 return InnerArrayIncludes(searchElement, fromIndex, this, length); 714 if (length === 0) return false;
715 var n = TO_INTEGER(fromIndex);
716
717 var k;
718 if (n >= 0) {
719 k = n;
720 } else {
721 k = length + n;
722 if (k < 0) {
723 k = 0;
724 }
725 }
726
727 while (k < length) {
728 var elementK = this[k];
729 if (%SameValueZero(searchElement, elementK)) {
730 return true;
731 }
732
733 ++k;
734 }
735
736 return false;
717 } 737 }
718 %FunctionSetLength(TypedArrayIncludes, 1); 738 %FunctionSetLength(TypedArrayIncludes, 1);
719 739
720 740
721 // ES6 draft 08-24-14, section 22.2.2.2 741 // ES6 draft 08-24-14, section 22.2.2.2
722 function TypedArrayOf() { 742 function TypedArrayOf() {
723 var length = arguments.length; 743 var length = arguments.length;
724 var array = TypedArrayCreate(this, length); 744 var array = TypedArrayCreate(this, length);
725 for (var i = 0; i < length; i++) { 745 for (var i = 0; i < length; i++) {
726 array[i] = arguments[i]; 746 array[i] = arguments[i];
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 "setUint32", DataViewSetUint32JS, 926 "setUint32", DataViewSetUint32JS,
907 927
908 "getFloat32", DataViewGetFloat32JS, 928 "getFloat32", DataViewGetFloat32JS,
909 "setFloat32", DataViewSetFloat32JS, 929 "setFloat32", DataViewSetFloat32JS,
910 930
911 "getFloat64", DataViewGetFloat64JS, 931 "getFloat64", DataViewGetFloat64JS,
912 "setFloat64", DataViewSetFloat64JS 932 "setFloat64", DataViewSetFloat64JS
913 ]); 933 ]);
914 934
915 }) 935 })
OLDNEW
« no previous file with comments | « src/js/array.js ('k') | src/objects.h » ('j') | test/mjsunit/es7/array-includes-receiver.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698