node/deps/v8/test/mjsunit/wasm/wrapper-compilation.js
Michaël Zasso 09a8440b45
deps: update V8 to 12.2.281.27
PR-URL: https://github.com/nodejs/node/pull/51362
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-03-31 15:36:07 +02:00

34 lines
1.0 KiB
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: --allow-natives-syntax --dump-counters --no-wasm-generic-wrapper
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
function compileAdd(val) {
var builder = new WasmModuleBuilder();
let struct = builder.addStruct([makeField(kWasmI32, true)]);
let sig = makeSig([kWasmI32], [wasmRefType(struct)])
builder.addFunction(`fct`, sig)
.addBody([
kExprLocalGet, 0,
kExprI32Const, val,
kExprI32Add,
kGCPrefix, kExprStructNew, struct,
])
.exportFunc();
return builder.instantiate();
}
assertEquals(0, %WasmCompiledExportWrappersCount());
let a = compileAdd(1);
a.exports.fct(1);
assertEquals(1, %WasmCompiledExportWrappersCount());
let b = compileAdd(2);
b.exports.fct(1);
assertEquals(1, %WasmCompiledExportWrappersCount());
let c = compileAdd(2);
c.exports.fct(1);
assertEquals(1, %WasmCompiledExportWrappersCount());