node/deps/v8/test/mjsunit/wasm/br-table-no-stack-rewrite.js
Michaël Zasso cfbf9e0d14 deps: update V8 to 12.4.254.14
PR-URL: https://github.com/nodejs/node/pull/52465
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2024-04-22 21:25:15 +00:00

33 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.
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
// Test that we don't rewrite the stack types when iterating over the targets
// for a br_table instrunction.
(function BrTable() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let funcT = builder.addType(makeSig([], []));
let table = builder.addTable(
wasmRefNullType(funcT), 1, 1, [kExprRefNull, funcT]);
let returnsFuncT = builder.addType(makeSig([], [wasmRefNullType(funcT)]));
let returnsFuncRef = builder.addType(makeSig([], [kWasmFuncRef]));
builder.addFunction("br_table", makeSig([kWasmI32], [kWasmFuncRef]))
.addBody([
kExprBlock, returnsFuncRef,
kExprBlock, returnsFuncT,
kExprI32Const, 0,
kExprTableGet, table.index,
kExprLocalGet, 0,
kExprBrTable, 2, 1, 1, 0,
kExprEnd,
kExprEnd,
])
.exportFunc();
let wasm = builder.instantiate().exports;
assertEquals(null, wasm.br_table(0));
})();