/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
deps/v8/test/mjsunit/compiler/recursive-loop-phis.js
43 строки
1 KB
Michaël Zasso
deps: update V8 to 11.9.169.7
04 янв 2024, 11:30
Не верифицирован
04 янв 2024, 11:30
d8c97e4
Код
Авторство
О чём код?
// 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 2 tests contain small loops with mutually recursive loop phis (in each // case, the second input of `i` and `j` are `j` and `i`). These tests could // help find bugs in optimization phases that are processing phis "in sequence" // instead of processing them "in parallel". // Using "3" as the number of iterations so that the loop could in theory be // fully unrolled. function g(a, b) { let s = 0; for (let c = 0, i = a, j = b; c < 3; [i, j] = [j, i]) { s += i + j; c++; } return s; } %PrepareFunctionForOptimization(g); assertEquals(g(8, 3), 33); %OptimizeFunctionOnNextCall(g); assertEquals(g(8, 3), 33); // Using a variable as the number of iterations ("a") so that the loop cannot be // fully unrolled. function f(a, b) { let s = 0; for (let c = 0, i = a, j = b; c < a; [i, j] = [j, i]) { s += i + j; c++; } return s; } %PrepareFunctionForOptimization(f); assertEquals(f(8, 3), 88); %OptimizeFunctionOnNextCall(f); assertEquals(f(8, 3), 88);