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>
30 lines
884 B
JavaScript
30 lines
884 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: --experimental-wasm-type-reflection
|
|
// Flags: --expose-gc --wasm-wrapper-tiering-budget=1
|
|
|
|
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
const builder = new WasmModuleBuilder();
|
|
const type = builder.addType(kSig_i_i);
|
|
const global = builder.addImportedGlobal('m', 'val', kWasmAnyFunc);
|
|
|
|
builder.addFunction('main', type)
|
|
.addBody([
|
|
kExprLocalGet, 0, kExprGlobalGet, global, kGCPrefix, kExprRefCast, type,
|
|
kExprCallRef, type
|
|
])
|
|
.exportFunc();
|
|
|
|
function foo() {
|
|
gc();
|
|
}
|
|
const func =
|
|
new WebAssembly.Function({parameters: ['i32'], results: ['i32']}, foo);
|
|
|
|
let instance = builder.instantiate({m: {val: func}});
|
|
instance.exports.main(3);
|
|
instance.exports.main(3);
|