mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 17:51:35 +00:00

PR-URL: https://github.com/nodejs/node/pull/49639 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
32 lines
1012 B
JavaScript
32 lines
1012 B
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: --no-turbo-escape --no-turbo-allocation-folding
|
|
|
|
function f() {
|
|
// Allocating an array that will be initialized with holes.
|
|
let arr = new Array(5);
|
|
// Doing a bunch more allocations in the hope of triggering a GC.
|
|
[arr, 5, 6, 7, [8], [9]];
|
|
[2, 5, 6, 7, [8], [9]];
|
|
[2, 5, 6, 7, [8], [9]];
|
|
[2, 5, 6, 7, [8], [9]];
|
|
[2, 5, 6, 7, [8], [9]];
|
|
[2, 5, 6, 7, [8], [9]];
|
|
[2, 5, 6, 7, [8], [9]];
|
|
[2, 5, 6, 7, [8], [9]];
|
|
[2, 5, 6, 7, [8], [9]];
|
|
// Setting arr[3]. Because previous allocations could trigger GCs, store-store
|
|
// elimination should not remove the initial hole-initialization of arr[3],
|
|
// otherwise the GC could see an undefined field.
|
|
arr[3] = 42;
|
|
return arr;
|
|
}
|
|
|
|
// Running `f` a few times, in the hope that a GC will eventually be scheduled
|
|
// inside it.
|
|
for (let i = 0; i < 5000; i++) {
|
|
f();
|
|
}
|