node/deps/v8/test/mjsunit/compiler/regress-347724915.js
Michaël Zasso 9d7cd9b864
deps: update V8 to 12.8.374.13
PR-URL: https://github.com/nodejs/node/pull/54077
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2024-08-16 16:03:01 +02:00

27 lines
1018 B
JavaScript

// 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.
// Flags: --allow-natives-syntax
function f(...args) {
let arr1 = [ undefined, undefined, undefined ];
%SimulateNewspaceFull();
arr1[0] = args[0];
// The following allocation will trigger a full GC, which will move the
// argument passed to the function (because it was a young object).
let arr2 = [ arr1 ];
// Here we're accessing `args[0]` again. This might be load-eliminated with
// the `args[0]` load from a few lines above, which has been moved by the GC
// since then. This should be fine though, as the loaded value should be
// marked as Tagged, which means that it shouldn't point to the stale value
// but instead have been updated during GC.
arr1[1] = args[0]
return arr2;
}
%PrepareFunctionForOptimization(f);
let expected = f({ x : 42 });
%OptimizeFunctionOnNextCall(f);
assertEquals(expected, f({x : 42}));