node/deps/v8/test/mjsunit/shared-memory/shared-value-barrier-optimization.js
Michaël Zasso f226350fcb deps: update V8 to 11.3.244.4
PR-URL: https://github.com/nodejs/node/pull/47251
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2023-03-31 14:15:23 +00:00

30 lines
1.0 KiB
JavaScript

// Copyright 2022 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: --harmony-struct --allow-natives-syntax
const Box = new SharedStructType(['payload']);
let a, b;
function f() {
a = SharedArray(4000);
b = new Box();
// Assignment into shared objects have a barrier that ensure the RHS is in
// shared space.
//
// RHS needs to be large enough to be in a HeapNumber. TF then allocates it
// out of the non-shared old space during optimization. If TF incorrectly
// compiles away the barrier, TF optimized code will create shared->local
// edges.
a[0] = 2000000000;
b.payload = 2000000000;
}
%PrepareFunctionForOptimization(f);
for (let i = 0; i < 10; i++) f();
// Verify that TF optimized code does not incorrectly compile away the shared
// value barrier.
%OptimizeFunctionOnNextCall(f);
for (let i = 0; i < 10; i++) f();
// SharedGC will verify there are no shared->local edges.
%SharedGC();