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

Unified Diff: src/array.js

Issue 9419044: Fix sequence of element access in array builtins. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1790.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/array.js
diff --git a/src/array.js b/src/array.js
index 16e37c5a7be4ccb0ac1bf38add1e3ef0ceb94eaa..513e7a97600ee8460baa36b607d07b686073da7c 100644
--- a/src/array.js
+++ b/src/array.js
@@ -1024,10 +1024,10 @@ function ArrayFilter(f, receiver) {
var accumulator = new InternalArray();
var accumulator_length = 0;
for (var i = 0; i < length; i++) {
- var current = array[i];
- if (!IS_UNDEFINED(current) || i in array) {
- if (%_CallFunction(receiver, current, i, array, f)) {
- accumulator[accumulator_length++] = current;
+ if (i in array) {
+ var element = array[i];
+ if (%_CallFunction(receiver, element, i, array, f)) {
+ accumulator[accumulator_length++] = element;
}
}
}
@@ -1057,9 +1057,9 @@ function ArrayForEach(f, receiver) {
}
for (var i = 0; i < length; i++) {
- var current = array[i];
- if (!IS_UNDEFINED(current) || i in array) {
- %_CallFunction(receiver, current, i, array, f);
+ if (i in array) {
+ var element = array[i];
+ %_CallFunction(receiver, element, i, array, f);
}
}
}
@@ -1088,9 +1088,9 @@ function ArraySome(f, receiver) {
}
for (var i = 0; i < length; i++) {
- var current = array[i];
- if (!IS_UNDEFINED(current) || i in array) {
- if (%_CallFunction(receiver, current, i, array, f)) return true;
+ if (i in array) {
+ var element = array[i];
+ if (%_CallFunction(receiver, element, i, array, f)) return true;
}
}
return false;
@@ -1118,9 +1118,9 @@ function ArrayEvery(f, receiver) {
}
for (var i = 0; i < length; i++) {
- var current = array[i];
- if (!IS_UNDEFINED(current) || i in array) {
- if (!%_CallFunction(receiver, current, i, array, f)) return false;
+ if (i in array) {
+ var element = array[i];
+ if (!%_CallFunction(receiver, element, i, array, f)) return false;
}
}
return true;
@@ -1149,9 +1149,9 @@ function ArrayMap(f, receiver) {
var result = new $Array();
var accumulator = new InternalArray(length);
for (var i = 0; i < length; i++) {
- var current = array[i];
- if (!IS_UNDEFINED(current) || i in array) {
- accumulator[i] = %_CallFunction(receiver, current, i, array, f);
+ if (i in array) {
+ var element = array[i];
+ accumulator[i] = %_CallFunction(receiver, element, i, array, f);
}
}
%MoveArrayContents(accumulator, result);
@@ -1308,8 +1308,8 @@ function ArrayReduce(callback, current) {
var receiver = %GetDefaultReceiver(callback);
for (; i < length; i++) {
- var element = array[i];
- if (!IS_UNDEFINED(element) || i in array) {
+ if (i in array) {
+ var element = array[i];
current = %_CallFunction(receiver, current, element, i, array, callback);
}
}
@@ -1345,8 +1345,8 @@ function ArrayReduceRight(callback, current) {
var receiver = %GetDefaultReceiver(callback);
for (; i >= 0; i--) {
- var element = array[i];
- if (!IS_UNDEFINED(element) || i in array) {
+ if (i in array) {
+ var element = array[i];
current = %_CallFunction(receiver, current, element, i, array, callback);
}
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1790.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698