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

Unified Diff: src/js/array.js

Issue 2761783002: Always run our fast array builtins. (Closed)
Patch Set: REBASE. Created 3 years, 9 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/array.js
diff --git a/src/js/array.js b/src/js/array.js
index 6bd31a8ebeac261c33eb6df66bc6cb8de24f02af..ea192a8cd10ce3740c5035681a61af8c0295cc1d 100644
--- a/src/js/array.js
+++ b/src/js/array.js
@@ -1033,85 +1033,24 @@ function ArrayFilter(f, receiver) {
return InnerArrayFilter(f, receiver, array, length, result);
}
-
-function InnerArrayForEach(f, receiver, array, length) {
- if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
-
- if (IS_UNDEFINED(receiver)) {
- for (var i = 0; i < length; i++) {
- if (i in array) {
- var element = array[i];
- f(element, i, array);
- }
- }
- } else {
- for (var i = 0; i < length; i++) {
- if (i in array) {
- var element = array[i];
- %_Call(f, receiver, element, i, array);
- }
- }
- }
-}
-
-
function ArrayForEach(f, receiver) {
- CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach");
-
- // Pull out the length so that modifications to the length in the
- // loop will not affect the looping and side effects are visible.
- var array = TO_OBJECT(this);
- var length = TO_LENGTH(array.length);
- InnerArrayForEach(f, receiver, array, length);
+ // This function is implemented as a code stub builtin.
+ // Defining the signature here makes it easier to install the builtin
Yang 2017/03/20 15:00:24 Do we really need these here? We don't need this f
mvstanton 2017/03/21 21:15:47 Done.
+ // in bootstrapper.cc.
}
-
-function InnerArraySome(f, receiver, array, length) {
- if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
-
- for (var i = 0; i < length; i++) {
- if (i in array) {
- var element = array[i];
- if (%_Call(f, receiver, element, i, array)) return true;
- }
- }
- return false;
-}
-
-
// Executes the function once for each element present in the
// array until it finds one where callback returns true.
function ArraySome(f, receiver) {
- CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some");
-
- // Pull out the length so that modifications to the length in the
- // loop will not affect the looping and side effects are visible.
- var array = TO_OBJECT(this);
- var length = TO_LENGTH(array.length);
- return InnerArraySome(f, receiver, array, length);
-}
-
-
-function InnerArrayEvery(f, receiver, array, length) {
- if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
-
- for (var i = 0; i < length; i++) {
- if (i in array) {
- var element = array[i];
- if (!%_Call(f, receiver, element, i, array)) return false;
- }
- }
- return true;
+ // This function is implemented as a code stub builtin.
+ // Defining the signature here makes it easier to install the builtin
+ // in bootstrapper.cc.
}
function ArrayEvery(f, receiver) {
- CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every");
-
- // Pull out the length so that modifications to the length in the
- // loop will not affect the looping and side effects are visible.
- var array = TO_OBJECT(this);
- var length = TO_LENGTH(array.length);
- return InnerArrayEvery(f, receiver, array, length);
+ // This function is implemented as a code stub builtin.
+ // Defining the signature here makes it easier to install the builtin
+ // in bootstrapper.cc.
}
@@ -1611,15 +1550,13 @@ utils.Export(function(to) {
to.ArrayPush = ArrayPush;
to.ArrayToString = ArrayToString;
to.ArrayValues = IteratorFunctions.values,
- to.InnerArrayEvery = InnerArrayEvery;
+ to.InnerArrayFill = InnerArrayFill;
to.InnerArrayFilter = InnerArrayFilter;
to.InnerArrayFind = InnerArrayFind;
to.InnerArrayFindIndex = InnerArrayFindIndex;
- to.InnerArrayForEach = InnerArrayForEach;
to.InnerArrayJoin = InnerArrayJoin;
to.InnerArrayReduce = InnerArrayReduce;
to.InnerArrayReduceRight = InnerArrayReduceRight;
- to.InnerArraySome = InnerArraySome;
to.InnerArraySort = InnerArraySort;
to.InnerArrayToLocaleString = InnerArrayToLocaleString;
to.PackedArrayReverse = PackedArrayReverse;
« src/bootstrapper.cc ('K') | « src/flag-definitions.h ('k') | src/js/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698