2024-08-14 20:41:00 +02:00
|
|
|
// Copyright 2024 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.
|
|
|
|
|
2025-04-29 08:03:15 +02:00
|
|
|
// Flags: --allow-natives-syntax --turbolev --turbofan
|
2024-08-14 20:41:00 +02:00
|
|
|
|
|
|
|
function array_push_grow_once(arr, x, y) {
|
|
|
|
// The 1st push will have to grow the array.
|
|
|
|
arr.push(x);
|
|
|
|
arr.push(y);
|
|
|
|
return arr.at(-1) + arr.at(-2) + arr.at(-3);
|
|
|
|
}
|
|
|
|
|
|
|
|
arr = [0, 1, 2, 3, 4, 5];
|
|
|
|
|
|
|
|
%PrepareFunctionForOptimization(array_push_grow_once);
|
|
|
|
assertEquals(29, array_push_grow_once(arr, 11, 13));
|
|
|
|
|
|
|
|
arr = [0, 1, 2, 3, 4, 5];
|
|
|
|
%OptimizeFunctionOnNextCall(array_push_grow_once);
|
|
|
|
assertEquals(29, array_push_grow_once(arr, 11, 13));
|
|
|
|
assertOptimized(array_push_grow_once);
|