nodejs/deps/v8/test/mjsunit/regress/wasm/regress-375343420.js
Michaël Zasso 918fe04351
deps: update V8 to 13.6.233.8
PR-URL: https://github.com/nodejs/node/pull/58070
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2025-05-02 15:06:53 +02:00

36 lines
1.1 KiB
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: --expose-gc --stress-wasm-code-gc
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
let builder = new WasmModuleBuilder();
let $sig0 = builder.addType(kSig_v_v);
let $func0 = builder.addImport("m", "func", $sig0);
let $table0 = builder.addImportedTable("m", "table", 0, 3, kWasmFuncRef);
builder.addActiveElementSegment($table0, wasmI32Const(0), [$func0]);
builder.addFunction("main", $sig0).exportFunc().addBody([
kExprI32Const, 0, // table slot
kExprCallIndirect, $sig0, $table0,
]);
var table = new WebAssembly.Table({initial: 2, element: 'anyfunc', maximum: 3});
function f1() {}
let f2 = (() => {}).bind(null);
(function() {
// Instance 1, immediately eligible for GC.
// Use a function that's not a plain JSFunction to force wrapper compilation.
builder.instantiate({m: {table, func: f2}});
})();
let instance = builder.instantiate({m: {table, func: f1}});
instance.exports.main();
gc();
// Make sure the wrapper is still there after GC.
instance.exports.main();