Bug 911578 - Backout of invalid packed array optimizations for array extras that can turn packed arrays into non-packed ones. r=me

--HG--
extra : rebase_source : 610323b286427d7b42645aecf0f7771ebb4c6dd9
This commit is contained in:
Till Schneidereit 2013-11-30 14:16:13 +01:00
parent e9ae7af602
commit 528f5f6e17

View File

@ -132,22 +132,13 @@ function ArrayEvery(callbackfn/*, thisArg*/) {
/* Steps 6-7. */ /* Steps 6-7. */
/* Steps a (implicit), and d. */ /* Steps a (implicit), and d. */
if (IsPackedArray(O)) { for (var k = 0; k < len; k++) {
for (var k = 0; k < len; k++) { /* Step b */
/* Step b (omitted). */ if (k in O) {
/* Step c. */ /* Step c. */
if (!callFunction(callbackfn, T, O[k], k, O)) if (!callFunction(callbackfn, T, O[k], k, O))
return false; return false;
} }
} else {
for (var k = 0; k < len; k++) {
/* Step b. */
if (k in O) {
/* Step c. */
if (!callFunction(callbackfn, T, O[k], k, O))
return false;
}
}
} }
/* Step 8. */ /* Step 8. */
@ -182,22 +173,13 @@ function ArraySome(callbackfn/*, thisArg*/) {
/* Steps 6-7. */ /* Steps 6-7. */
/* Steps a (implicit), and d. */ /* Steps a (implicit), and d. */
if (IsPackedArray(O)) { for (var k = 0; k < len; k++) {
for (var k = 0; k < len; k++) { /* Step b */
/* Step b (omitted). */ if (k in O) {
/* Step c. */ /* Step c. */
if (callFunction(callbackfn, T, O[k], k, O)) if (callFunction(callbackfn, T, O[k], k, O))
return true; return true;
} }
} else {
for (var k = 0; k < len; k++) {
/* Step b */
if (k in O) {
/* Step c. */
if (callFunction(callbackfn, T, O[k], k, O))
return true;
}
}
} }
/* Step 8. */ /* Step 8. */
@ -232,20 +214,12 @@ function ArrayForEach(callbackfn/*, thisArg*/) {
/* Steps 6-7. */ /* Steps 6-7. */
/* Steps a (implicit), and d. */ /* Steps a (implicit), and d. */
if (IsPackedArray(O)) { for (var k = 0; k < len; k++) {
for (var k = 0; k < len; k++) { /* Step b */
/* Step b (omitted). */ if (k in O) {
/* Step c. */ /* Step c. */
callFunction(callbackfn, T, O[k], k, O); callFunction(callbackfn, T, O[k], k, O);
} }
} else {
for (var k = 0; k < len; k++) {
/* Step b. */
if (k in O) {
/* Step c. */
callFunction(callbackfn, T, O[k], k, O);
}
}
} }
/* Step 8. */ /* Step 8. */
@ -274,24 +248,14 @@ function ArrayMap(callbackfn/*, thisArg*/) {
/* Step 7-8. */ /* Step 7-8. */
/* Step a (implicit), and d. */ /* Step a (implicit), and d. */
if (IsPackedArray(O)) { for (var k = 0; k < len; k++) {
for (var k = 0; k < len; k++) { /* Step b */
/* Step b (omitted). */ if (k in O) {
/* Step c.i-iii. */ /* Step c.i-iii. */
var mappedValue = callFunction(callbackfn, T, O[k], k, O); var mappedValue = callFunction(callbackfn, T, O[k], k, O);
// UnsafePutElements doesn't invoke setters, so we can use it here. // UnsafePutElements doesn't invoke setters, so we can use it here.
UnsafePutElements(A, k, mappedValue); UnsafePutElements(A, k, mappedValue);
} }
} else {
for (var k = 0; k < len; k++) {
/* Step b. */
if (k in O) {
/* Step c.i-iii. */
var mappedValue = callFunction(callbackfn, T, O[k], k, O);
// UnsafePutElements doesn't invoke setters, so we can use it here.
UnsafePutElements(A, k, mappedValue);
}
}
} }
/* Step 9. */ /* Step 9. */
@ -333,8 +297,6 @@ function ArrayReduce(callbackfn/*, initialValue*/) {
/* Step 6. */ /* Step 6. */
var k = 0; var k = 0;
var isPacked = IsPackedArray(O);
/* Steps 5, 7-8. */ /* Steps 5, 7-8. */
var accumulator; var accumulator;
if (arguments.length > 1) { if (arguments.length > 1) {
@ -343,7 +305,7 @@ function ArrayReduce(callbackfn/*, initialValue*/) {
/* Step 5. */ /* Step 5. */
if (len === 0) if (len === 0)
ThrowError(JSMSG_EMPTY_ARRAY_REDUCE); ThrowError(JSMSG_EMPTY_ARRAY_REDUCE);
if (isPacked) { if (IsPackedArray(O)) {
accumulator = O[k++]; accumulator = O[k++];
} else { } else {
var kPresent = false; var kPresent = false;
@ -362,20 +324,12 @@ function ArrayReduce(callbackfn/*, initialValue*/) {
/* Step 9. */ /* Step 9. */
/* Steps a (implicit), and d. */ /* Steps a (implicit), and d. */
if (isPacked) { for (; k < len; k++) {
for (; k < len; k++) { /* Step b */
/* Step b (omitted). */ if (k in O) {
/* Step c. */ /* Step c. */
accumulator = callbackfn(accumulator, O[k], k, O); accumulator = callbackfn(accumulator, O[k], k, O);
} }
} else {
for (; k < len; k++) {
/* Step b. */
if (k in O) {
/* Step c. */
accumulator = callbackfn(accumulator, O[k], k, O);
}
}
} }
/* Step 10. */ /* Step 10. */
@ -410,8 +364,6 @@ function ArrayReduceRight(callbackfn/*, initialValue*/) {
/* Step 6. */ /* Step 6. */
var k = len - 1; var k = len - 1;
var isPacked = IsPackedArray(O);
/* Steps 5, 7-8. */ /* Steps 5, 7-8. */
var accumulator; var accumulator;
if (arguments.length > 1) { if (arguments.length > 1) {
@ -420,7 +372,7 @@ function ArrayReduceRight(callbackfn/*, initialValue*/) {
/* Step 5. */ /* Step 5. */
if (len === 0) if (len === 0)
ThrowError(JSMSG_EMPTY_ARRAY_REDUCE); ThrowError(JSMSG_EMPTY_ARRAY_REDUCE);
if (isPacked) { if (IsPackedArray(O)) {
accumulator = O[k--]; accumulator = O[k--];
} else { } else {
var kPresent = false; var kPresent = false;
@ -439,20 +391,12 @@ function ArrayReduceRight(callbackfn/*, initialValue*/) {
/* Step 9. */ /* Step 9. */
/* Steps a (implicit), and d. */ /* Steps a (implicit), and d. */
if (isPacked) { for (; k >= 0; k--) {
for (; k >= 0; k--) { /* Step b */
/* Step b (omitted). */ if (k in O) {
/* Step c. */ /* Step c. */
accumulator = callbackfn(accumulator, O[k], k, O); accumulator = callbackfn(accumulator, O[k], k, O);
} }
} else {
for (; k >= 0; k--) {
/* Step b. */
if (k in O) {
/* Step c. */
accumulator = callbackfn(accumulator, O[k], k, O);
}
}
} }
/* Step 10. */ /* Step 10. */
@ -494,25 +438,14 @@ function ArrayFind(predicate/*, thisArg*/) {
* var obj = { 18014398509481984: true, length: 18014398509481988 }; * var obj = { 18014398509481984: true, length: 18014398509481988 };
* Array.prototype.find.call(obj, () => true); * Array.prototype.find.call(obj, () => true);
*/ */
var k; for (var k = 0; k < len; k++) {
if (IsPackedArray(O)) { /* Steps b and c (implicit) */
for (k = 0; k < len; k++) { if (k in O) {
/* Steps b (omitted) and c (implicit). */
/* Step d. */ /* Step d. */
var kValue = O[k]; var kValue = O[k];
if (callFunction(predicate, T, kValue, k, O)) if (callFunction(predicate, T, kValue, k, O))
return kValue; return kValue;
} }
} else {
for (k = 0; k < len; k++) {
/* Steps b and c (implicit). */
if (k in O) {
/* Step d. */
var kValue = O[k];
if (callFunction(predicate, T, kValue, k, O))
return kValue;
}
}
} }
/* Step 10. */ /* Step 10. */
@ -543,23 +476,13 @@ function ArrayFindIndex(predicate/*, thisArg*/) {
* var obj = { 18014398509481984: true, length: 18014398509481988 }; * var obj = { 18014398509481984: true, length: 18014398509481988 };
* Array.prototype.find.call(obj, () => true); * Array.prototype.find.call(obj, () => true);
*/ */
var k; for (var k = 0; k < len; k++) {
if (IsPackedArray(O)) { /* Steps b and c (implicit) */
for (k = 0; k < len; k++) { if (k in O) {
/* Steps b (omitted) and c (implicit). */
/* Step d. */ /* Step d. */
if (callFunction(predicate, T, O[k], k, O)) if (callFunction(predicate, T, O[k], k, O))
return k; return k;
} }
} else {
for (k = 0; k < len; k++) {
/* Steps b and c (implicit). */
if (k in O) {
/* Step d. */
if (callFunction(predicate, T, O[k], k, O))
return k;
}
}
} }
/* Step 10. */ /* Step 10. */