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

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

Issue 2232063002: [builtins] WIP: Array indexOf in TurboFan/Runtime (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 InnerArrayIndexOf;
32 var InnerArrayJoin; 31 var InnerArrayJoin;
33 var InnerArrayLastIndexOf; 32 var InnerArrayLastIndexOf;
34 var InnerArrayReduce; 33 var InnerArrayReduce;
35 var InnerArrayReduceRight; 34 var InnerArrayReduceRight;
36 var InnerArraySome; 35 var InnerArraySome;
37 var InnerArraySort; 36 var InnerArraySort;
38 var InnerArrayToLocaleString; 37 var InnerArrayToLocaleString;
39 var InternalArray = utils.InternalArray; 38 var InternalArray = utils.InternalArray;
40 var IsNaN; 39 var IsNaN;
41 var MaxSimple; 40 var MaxSimple;
(...skipping 30 matching lines...) Expand all
72 ArrayValues = from.ArrayValues; 71 ArrayValues = from.ArrayValues;
73 GetIterator = from.GetIterator; 72 GetIterator = from.GetIterator;
74 GetMethod = from.GetMethod; 73 GetMethod = from.GetMethod;
75 InnerArrayCopyWithin = from.InnerArrayCopyWithin; 74 InnerArrayCopyWithin = from.InnerArrayCopyWithin;
76 InnerArrayEvery = from.InnerArrayEvery; 75 InnerArrayEvery = from.InnerArrayEvery;
77 InnerArrayFill = from.InnerArrayFill; 76 InnerArrayFill = from.InnerArrayFill;
78 InnerArrayFilter = from.InnerArrayFilter; 77 InnerArrayFilter = from.InnerArrayFilter;
79 InnerArrayFind = from.InnerArrayFind; 78 InnerArrayFind = from.InnerArrayFind;
80 InnerArrayFindIndex = from.InnerArrayFindIndex; 79 InnerArrayFindIndex = from.InnerArrayFindIndex;
81 InnerArrayForEach = from.InnerArrayForEach; 80 InnerArrayForEach = from.InnerArrayForEach;
82 InnerArrayIndexOf = from.InnerArrayIndexOf;
83 InnerArrayJoin = from.InnerArrayJoin; 81 InnerArrayJoin = from.InnerArrayJoin;
84 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; 82 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf;
85 InnerArrayReduce = from.InnerArrayReduce; 83 InnerArrayReduce = from.InnerArrayReduce;
86 InnerArrayReduceRight = from.InnerArrayReduceRight; 84 InnerArrayReduceRight = from.InnerArrayReduceRight;
87 InnerArraySome = from.InnerArraySome; 85 InnerArraySome = from.InnerArraySome;
88 InnerArraySort = from.InnerArraySort; 86 InnerArraySort = from.InnerArraySort;
89 InnerArrayToLocaleString = from.InnerArrayToLocaleString; 87 InnerArrayToLocaleString = from.InnerArrayToLocaleString;
90 IsNaN = from.IsNaN; 88 IsNaN = from.IsNaN;
91 MaxSimple = from.MaxSimple; 89 MaxSimple = from.MaxSimple;
92 MinSimple = from.MinSimple; 90 MinSimple = from.MinSimple;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 563
566 return InnerArraySort(this, length, comparefn); 564 return InnerArraySort(this, length, comparefn);
567 } 565 }
568 566
569 567
570 // ES6 section 22.2.3.13 568 // ES6 section 22.2.3.13
571 function TypedArrayIndexOf(element, index) { 569 function TypedArrayIndexOf(element, index) {
572 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 570 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
573 571
574 var length = %_TypedArrayGetLength(this); 572 var length = %_TypedArrayGetLength(this);
575 return InnerArrayIndexOf(this, element, index, length); 573
Benedikt Meurer 2016/08/11 04:02:24 You could do this change to typedarray.js as a sep
mattloring 2016/08/11 17:32:57 Opened here: https://codereview.chromium.org/22435
574 if (length === 0) return -1;
575 var n = TO_INTEGER(index);
576
577 var k;
578 if (n >= 0) {
579 k = n;
580 } else {
581 k = length + n;
582 if (k < 0) {
583 k = 0;
584 }
585 }
586
587 while (k < length) {
588 var elementK = this[k];
589 if (k in this && element === elementK) {
590 return k;
591 }
592 ++k;
593 }
594 return -1;
576 } 595 }
577 %FunctionSetLength(TypedArrayIndexOf, 1); 596 %FunctionSetLength(TypedArrayIndexOf, 1);
578 597
579 598
580 // ES6 section 22.2.3.16 599 // ES6 section 22.2.3.16
581 function TypedArrayLastIndexOf(element, index) { 600 function TypedArrayLastIndexOf(element, index) {
582 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 601 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
583 602
584 var length = %_TypedArrayGetLength(this); 603 var length = %_TypedArrayGetLength(this);
585 604
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 "setUint32", DataViewSetUint32JS, 941 "setUint32", DataViewSetUint32JS,
923 942
924 "getFloat32", DataViewGetFloat32JS, 943 "getFloat32", DataViewGetFloat32JS,
925 "setFloat32", DataViewSetFloat32JS, 944 "setFloat32", DataViewSetFloat32JS,
926 945
927 "getFloat64", DataViewGetFloat64JS, 946 "getFloat64", DataViewGetFloat64JS,
928 "setFloat64", DataViewSetFloat64JS 947 "setFloat64", DataViewSetFloat64JS
929 ]); 948 ]);
930 949
931 }) 950 })
OLDNEW
« no previous file with comments | « src/js/string.js ('k') | src/runtime/runtime.h » ('j') | src/runtime/runtime-array.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698