@@ -300,20 +300,21 @@ module array {
300
300
301
301
macro ArrayForEachTorqueContinuation(
302
302
context: Context, o: Object, len: Number, callbackfn: Callable,
303
- thisArg: Object, initial_k: Smi ): Object {
303
+ thisArg: Object, initial_k: Number ): Object {
304
304
// 5. Let k be 0.
305
305
// 6. Repeat, while k < len
306
- for (let k: Smi = initial_k; k < len; k = k + 1) {
306
+ for (let k: Number = initial_k; k < len; k = k + 1) {
307
307
// 6a. Let Pk be ! ToString(k).
308
- let pK: String = ToString_Inline(context, k);
308
+ // k is guaranteed to be a positive integer, hence ToString is
309
+ // side-effect free and HasProperty/GetProperty do the conversion inline.
309
310
310
311
// 6b. Let kPresent be ? HasProperty(O, Pk).
311
- let kPresent: Oddball = HasPropertyObject(o, pK , context, kHasProperty);
312
+ let kPresent: Oddball = HasPropertyObject(o, k , context, kHasProperty);
312
313
313
314
// 6c. If kPresent is true, then
314
315
if (kPresent == True) {
315
316
// 6c. i. Let kValue be ? Get(O, Pk).
316
- let kValue: Object = GetProperty(context, o, pK );
317
+ let kValue: Object = GetProperty(context, o, k );
317
318
318
319
// 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>).
319
320
Call(context, callbackfn, thisArg, kValue, k, o);
@@ -346,7 +347,7 @@ module array {
346
347
to: Object): Object {
347
348
try {
348
349
let callbackfn: Callable = cast<Callable>(callback) otherwise Unexpected;
349
- let k: Smi = cast<Smi >(initialK) otherwise Unexpected;
350
+ let k: Number = cast<Number >(initialK) otherwise Unexpected;
350
351
let number_length: Number = cast<Number>(length) otherwise Unexpected;
351
352
352
353
return ArrayForEachTorqueContinuation(
@@ -446,7 +447,7 @@ module array {
446
447
let thisArg: Object = arguments.length > 1 ? arguments[1] : Undefined;
447
448
448
449
// Special cases.
449
- let k: Smi = 0;
450
+ let k: Number = 0;
450
451
try {
451
452
return FastArrayForEach(context, o, len, callbackfn, thisArg)
452
453
otherwise Bailout;
0 commit comments