Skip to content

Commit 5d70652

Browse files
ripsawridgetargos
authored andcommitted
deps: fix Array.prototype.forEach on v8 6.8
This applies a variant of v8/v8@e1163c14f7e4fef2c549 to V8 6.8. Original commit message: [Builtins] Array.prototype.forEach perf regression on dictionaries An unnecessary call to ToString() on the array index caused trips to the runtime. The fix also includes performance micro-benchmarks so we'll have a harder time regressing this case in future. [email protected] Bug: v8:8112 Change-Id: I781e8b1bbe2eb56db961cf33b0dca8523868b83d Reviewed-on: https://chromium-review.googlesource.com/1213207 Commit-Queue: Michael Stanton <[email protected]> Reviewed-by: Michael Stanton <[email protected]> Reviewed-by: Tobias Tebbi <[email protected]> Cr-Commit-Position: refs/heads/master@{#55733} Refs: v8/v8@e1163c1 Fixes: #22859 PR-URL: #22899 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 16f7f52 commit 5d70652

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
# Reset this number to 0 on major V8 upgrades.
3131
# Increment by one for each non-official patch applied to deps/v8.
32-
'v8_embedder_string': '-node.30',
32+
'v8_embedder_string': '-node.31',
3333

3434
# Enable disassembler for `--print-code` v8 options
3535
'v8_enable_disassembler': 1,

deps/v8/src/builtins/array.tq

+8-7
Original file line numberDiff line numberDiff line change
@@ -300,20 +300,21 @@ module array {
300300

301301
macro ArrayForEachTorqueContinuation(
302302
context: Context, o: Object, len: Number, callbackfn: Callable,
303-
thisArg: Object, initial_k: Smi): Object {
303+
thisArg: Object, initial_k: Number): Object {
304304
// 5. Let k be 0.
305305
// 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) {
307307
// 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.
309310

310311
// 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);
312313

313314
// 6c. If kPresent is true, then
314315
if (kPresent == True) {
315316
// 6c. i. Let kValue be ? Get(O, Pk).
316-
let kValue: Object = GetProperty(context, o, pK);
317+
let kValue: Object = GetProperty(context, o, k);
317318

318319
// 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>).
319320
Call(context, callbackfn, thisArg, kValue, k, o);
@@ -346,7 +347,7 @@ module array {
346347
to: Object): Object {
347348
try {
348349
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;
350351
let number_length: Number = cast<Number>(length) otherwise Unexpected;
351352

352353
return ArrayForEachTorqueContinuation(
@@ -446,7 +447,7 @@ module array {
446447
let thisArg: Object = arguments.length > 1 ? arguments[1] : Undefined;
447448

448449
// Special cases.
449-
let k: Smi = 0;
450+
let k: Number = 0;
450451
try {
451452
return FastArrayForEach(context, o, len, callbackfn, thisArg)
452453
otherwise Bailout;

0 commit comments

Comments
 (0)