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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: src/js/typedarray.js
diff --git a/src/js/typedarray.js b/src/js/typedarray.js
index 8e7d9ee77e4ed3c8011e400c490e132cf6ef1664..15bc7296624036a65d3d6d185a325a491dbb1f5b 100644
--- a/src/js/typedarray.js
+++ b/src/js/typedarray.js
@@ -28,7 +28,6 @@ var InnerArrayFilter;
var InnerArrayFind;
var InnerArrayFindIndex;
var InnerArrayForEach;
-var InnerArrayIncludes;
var InnerArrayIndexOf;
var InnerArrayJoin;
var InnerArrayLastIndexOf;
@@ -82,7 +81,6 @@ 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;
@@ -713,7 +711,29 @@ function TypedArrayIncludes(searchElement, fromIndex) {
var length = %_TypedArrayGetLength(this);
- return InnerArrayIncludes(searchElement, fromIndex, this, 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 = this[k];
+ if (%SameValueZero(searchElement, elementK)) {
+ return true;
+ }
+
+ ++k;
+ }
+
+ return false;
}
%FunctionSetLength(TypedArrayIncludes, 1);
« 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