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

Unified Diff: src/array.js

Issue 553623004: ES6: Array.prototype.slice and friends should use ToLength instead of ToUint32 Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove failing tests. Created 5 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 | src/harmony-array.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 784f51f0e4419b4b6beec682c5eeda60b85bf345..6299ee2adab64450edc04f738c531025c099cc25 100644
--- a/src/array.js
+++ b/src/array.js
@@ -369,8 +369,7 @@ function ArrayToString() {
function ArrayToLocaleString() {
var array = ToObject(this);
- var arrayLen = array.length;
- var len = TO_UINT32(arrayLen);
+ var len = ToLength(array.length);
if (len === 0) return "";
return Join(array, len, ',', ConvertToLocaleString);
}
@@ -380,7 +379,7 @@ function ArrayJoin(separator) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.join");
var array = TO_OBJECT_INLINE(this);
- var length = TO_UINT32(array.length);
+ var length = ToLength(array.length);
if (IS_UNDEFINED(separator)) {
separator = ',';
} else if (!IS_STRING(separator)) {
@@ -424,7 +423,7 @@ function ArrayPop() {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.pop");
var array = TO_OBJECT_INLINE(this);
- var n = TO_UINT32(array.length);
+ var n = ToLength(array.length);
if (n == 0) {
array.length = n;
return;
@@ -469,7 +468,7 @@ function ArrayPush() {
return ObservedArrayPush.apply(this, arguments);
var array = TO_OBJECT_INLINE(this);
- var n = TO_UINT32(array.length);
+ var n = ToLength(array.length);
var m = %_ArgumentsLength();
for (var i = 0; i < m; i++) {
@@ -548,7 +547,7 @@ function ArrayReverse() {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reverse");
var array = TO_OBJECT_INLINE(this);
- var len = TO_UINT32(array.length);
+ var len = ToLength(array.length);
if (UseSparseVariant(array, len, IS_ARRAY(array), len)) {
%NormalizeElements(array);
@@ -599,7 +598,7 @@ function ArrayShift() {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.shift");
var array = TO_OBJECT_INLINE(this);
- var len = TO_UINT32(array.length);
+ var len = ToLength(array.length);
if (len === 0) {
array.length = 0;
@@ -654,7 +653,7 @@ function ArrayUnshift(arg1) { // length == 1
return ObservedArrayUnshift.apply(this, arguments);
var array = TO_OBJECT_INLINE(this);
- var len = TO_UINT32(array.length);
+ var len = ToLength(array.length);
var num_arguments = %_ArgumentsLength();
if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) &&
@@ -678,7 +677,7 @@ function ArraySlice(start, end) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.slice");
var array = TO_OBJECT_INLINE(this);
- var len = TO_UINT32(array.length);
+ var len = ToLength(array.length);
var start_i = TO_INTEGER(start);
var end_i = len;
@@ -796,7 +795,7 @@ function ArraySplice(start, delete_count) {
var num_arguments = %_ArgumentsLength();
var array = TO_OBJECT_INLINE(this);
- var len = TO_UINT32(array.length);
+ var len = ToLength(array.length);
var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len);
var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len,
start_i);
@@ -1140,7 +1139,7 @@ function ArrayFilter(f, receiver) {
// 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 = ToObject(this);
- var length = ToUint32(array.length);
+ var length = ToLength(array.length);
if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
@@ -1179,7 +1178,7 @@ function ArrayForEach(f, receiver) {
// 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 = ToObject(this);
- var length = TO_UINT32(array.length);
+ var length = ToLength(array.length);
if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
@@ -1213,7 +1212,7 @@ function ArraySome(f, receiver) {
// 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 = ToObject(this);
- var length = TO_UINT32(array.length);
+ var length = ToLength(array.length);
if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
@@ -1246,7 +1245,7 @@ function ArrayEvery(f, receiver) {
// 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 = ToObject(this);
- var length = TO_UINT32(array.length);
+ var length = ToLength(array.length);
if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
@@ -1278,7 +1277,7 @@ function ArrayMap(f, receiver) {
// 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 = ToObject(this);
- var length = TO_UINT32(array.length);
+ var length = ToLength(array.length);
if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
@@ -1311,7 +1310,7 @@ function ArrayMap(f, receiver) {
function ArrayIndexOf(element, index) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf");
- var length = TO_UINT32(this.length);
+ var length = ToLength(this.length);
if (length == 0) return -1;
if (IS_UNDEFINED(index)) {
index = 0;
@@ -1368,7 +1367,7 @@ function ArrayIndexOf(element, index) {
function ArrayLastIndexOf(element, index) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.lastIndexOf");
- var length = TO_UINT32(this.length);
+ var length = ToLength(this.length);
if (length == 0) return -1;
if (%_ArgumentsLength() < 2) {
index = length - 1;
@@ -1424,7 +1423,7 @@ function ArrayReduce(callback, current) {
// 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 = ToObject(this);
- var length = ToUint32(array.length);
+ var length = ToLength(array.length);
if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError('called_non_callable', [callback]);
@@ -1461,7 +1460,7 @@ function ArrayReduceRight(callback, current) {
// Pull out the length so that side effects are visible before the
// callback function is checked.
var array = ToObject(this);
- var length = ToUint32(array.length);
+ var length = ToLength(array.length);
if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError('called_non_callable', [callback]);
« no previous file with comments | « no previous file | src/harmony-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698