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,23 +132,14 @@ function ArrayEvery(callbackfn/*, thisArg*/) {
/* Steps 6-7. */
/* Steps a (implicit), and d. */
if (IsPackedArray(O)) {
for (var k = 0; k < len; k++) {
/* Step b (omitted). */
/* Step c. */
if (!callFunction(callbackfn, T, O[k], k, O))
return false;
}
} else {
for (var k = 0; k < len; k++) {
/* Step b. */
/* Step b */
if (k in O) {
/* Step c. */
if (!callFunction(callbackfn, T, O[k], k, O))
return false;
}
}
}
/* Step 8. */
return true;
@ -182,14 +173,6 @@ function ArraySome(callbackfn/*, thisArg*/) {
/* Steps 6-7. */
/* Steps a (implicit), and d. */
if (IsPackedArray(O)) {
for (var k = 0; k < len; k++) {
/* Step b (omitted). */
/* Step c. */
if (callFunction(callbackfn, T, O[k], k, O))
return true;
}
} else {
for (var k = 0; k < len; k++) {
/* Step b */
if (k in O) {
@ -198,7 +181,6 @@ function ArraySome(callbackfn/*, thisArg*/) {
return true;
}
}
}
/* Step 8. */
return false;
@ -232,21 +214,13 @@ function ArrayForEach(callbackfn/*, thisArg*/) {
/* Steps 6-7. */
/* Steps a (implicit), and d. */
if (IsPackedArray(O)) {
for (var k = 0; k < len; k++) {
/* Step b (omitted). */
/* Step c. */
callFunction(callbackfn, T, O[k], k, O);
}
} else {
for (var k = 0; k < len; k++) {
/* Step b. */
/* Step b */
if (k in O) {
/* Step c. */
callFunction(callbackfn, T, O[k], k, O);
}
}
}
/* Step 8. */
return void 0;
@ -274,17 +248,8 @@ function ArrayMap(callbackfn/*, thisArg*/) {
/* Step 7-8. */
/* Step a (implicit), and d. */
if (IsPackedArray(O)) {
for (var k = 0; k < len; k++) {
/* Step b (omitted). */
/* 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);
}
} else {
for (var k = 0; k < len; k++) {
/* Step b. */
/* Step b */
if (k in O) {
/* Step c.i-iii. */
var mappedValue = callFunction(callbackfn, T, O[k], k, O);
@ -292,7 +257,6 @@ function ArrayMap(callbackfn/*, thisArg*/) {
UnsafePutElements(A, k, mappedValue);
}
}
}
/* Step 9. */
return A;
@ -333,8 +297,6 @@ function ArrayReduce(callbackfn/*, initialValue*/) {
/* Step 6. */
var k = 0;
var isPacked = IsPackedArray(O);
/* Steps 5, 7-8. */
var accumulator;
if (arguments.length > 1) {
@ -343,7 +305,7 @@ function ArrayReduce(callbackfn/*, initialValue*/) {
/* Step 5. */
if (len === 0)
ThrowError(JSMSG_EMPTY_ARRAY_REDUCE);
if (isPacked) {
if (IsPackedArray(O)) {
accumulator = O[k++];
} else {
var kPresent = false;
@ -362,21 +324,13 @@ function ArrayReduce(callbackfn/*, initialValue*/) {
/* Step 9. */
/* Steps a (implicit), and d. */
if (isPacked) {
for (; k < len; k++) {
/* Step b (omitted). */
/* Step c. */
accumulator = callbackfn(accumulator, O[k], k, O);
}
} else {
for (; k < len; k++) {
/* Step b. */
/* Step b */
if (k in O) {
/* Step c. */
accumulator = callbackfn(accumulator, O[k], k, O);
}
}
}
/* Step 10. */
return accumulator;
@ -410,8 +364,6 @@ function ArrayReduceRight(callbackfn/*, initialValue*/) {
/* Step 6. */
var k = len - 1;
var isPacked = IsPackedArray(O);
/* Steps 5, 7-8. */
var accumulator;
if (arguments.length > 1) {
@ -420,7 +372,7 @@ function ArrayReduceRight(callbackfn/*, initialValue*/) {
/* Step 5. */
if (len === 0)
ThrowError(JSMSG_EMPTY_ARRAY_REDUCE);
if (isPacked) {
if (IsPackedArray(O)) {
accumulator = O[k--];
} else {
var kPresent = false;
@ -439,21 +391,13 @@ function ArrayReduceRight(callbackfn/*, initialValue*/) {
/* Step 9. */
/* Steps a (implicit), and d. */
if (isPacked) {
for (; k >= 0; k--) {
/* Step b (omitted). */
/* Step c. */
accumulator = callbackfn(accumulator, O[k], k, O);
}
} else {
for (; k >= 0; k--) {
/* Step b. */
/* Step b */
if (k in O) {
/* Step c. */
accumulator = callbackfn(accumulator, O[k], k, O);
}
}
}
/* Step 10. */
return accumulator;
@ -494,18 +438,8 @@ function ArrayFind(predicate/*, thisArg*/) {
* var obj = { 18014398509481984: true, length: 18014398509481988 };
* Array.prototype.find.call(obj, () => true);
*/
var k;
if (IsPackedArray(O)) {
for (k = 0; k < len; k++) {
/* Steps b (omitted) and c (implicit). */
/* Step d. */
var kValue = O[k];
if (callFunction(predicate, T, kValue, k, O))
return kValue;
}
} else {
for (k = 0; k < len; k++) {
/* Steps b and c (implicit). */
for (var k = 0; k < len; k++) {
/* Steps b and c (implicit) */
if (k in O) {
/* Step d. */
var kValue = O[k];
@ -513,7 +447,6 @@ function ArrayFind(predicate/*, thisArg*/) {
return kValue;
}
}
}
/* Step 10. */
return undefined;
@ -543,24 +476,14 @@ function ArrayFindIndex(predicate/*, thisArg*/) {
* var obj = { 18014398509481984: true, length: 18014398509481988 };
* Array.prototype.find.call(obj, () => true);
*/
var k;
if (IsPackedArray(O)) {
for (k = 0; k < len; k++) {
/* Steps b (omitted) and c (implicit). */
/* Step d. */
if (callFunction(predicate, T, O[k], k, O))
return k;
}
} else {
for (k = 0; k < len; k++) {
/* Steps b and c (implicit). */
for (var 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. */
return -1;