node/deps/v8/test/mjsunit/compiler/regress-crbug-1502042.js
Michaël Zasso 09a8440b45
deps: update V8 to 12.2.281.27
PR-URL: https://github.com/nodejs/node/pull/51362
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-03-31 15:36:07 +02:00

35 lines
1.1 KiB
JavaScript

// Copyright 2023 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// This function is designed so that the inner loop needs revisiting, and the
// outer loop also (and the revisit of the outer loop should trigger a revisit
// of the inner loop). The block triggering the revisit of the outer loop is not
// among the successors of the inner loop.
function f() {
let arr = [1, 2, 3];
let s1 = 0, s2 = 0;
for (let i = 0; i < 10; i++) {
if (i >= 3) {
// The inner loop is in a if-else in the outer loop so that the block
// containing `arr[2]++` is not among its successors.
for (let j = 0; j < 10; j++) {
s1 += arr[1];
s2 += arr[2];
arr[1]++; // Trigger revisit of inner loop
}
} else {
arr[2]++; // Trigger revisit of outer loop
}
}
return s1 + s2;
}
%PrepareFunctionForOptimization(f);
assertEquals(f(), 2975);
%OptimizeFunctionOnNextCall(f);
assertEquals(f(), 2975);