nodejs/deps/v8/test/mjsunit/regress/wasm/regress-1486237.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

64 lines
2.2 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: --wasm-staging
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
const builder = new WasmModuleBuilder();
builder.addStruct([]);
builder.addArray(kWasmF32, true);
builder.addType(makeSig([kWasmI32, kWasmI32, kWasmI32], [kWasmI32]));
builder.startRecGroup();
builder.addType(makeSig([
kWasmI32,
wasmRefNullType(kWasmStructRef),
wasmRefNullType(1),
wasmRefType(kWasmExternRef),
wasmRefNullType(kWasmArrayRef),
kWasmI32,
wasmRefNullType(kWasmStructRef),
], []));
builder.endRecGroup();
builder.addType(makeSig([], []));
builder.addMemory(16, 32);
builder.addPassiveDataSegment([72, 149, 203, 199, 152, 103, 153, 179]);
builder.addTable(kWasmFuncRef, 2, 2, undefined)
builder.addActiveElementSegment(0, wasmI32Const(0),
[[kExprRefFunc, 0, ], [kExprRefFunc, 1, ]], kWasmFuncRef);
builder.addTag(makeSig([], []));
// Generate function 1 (out of 2).
builder.addFunction(undefined, 2 /* sig */)
.addLocals(kWasmF64, 1).addLocals(wasmRefNullType(kWasmStructRef), 2)
.addBodyWithEnd([
// signature: i_iii
// body:
kExprF32Const, 0xdd, 0x44, 0x44, 0x06, // f32.const
kExprTry, 0x7f, // try @10 i32
kExprI32Const, 0xab, 0xfa, 0x8e, 0xaa, 0x78, // i32.const
kExprDelegate, 0x00, // delegate
kExprI32Const, 0x18, // i32.const
kExprLocalGet, 0x04, // local.get
kGCPrefix, kExprRefCastNull, 0x00, // ref.cast null
kExprLocalGet, 0x04, // local.get
kGCPrefix, kExprRefCastNull, 0x01, // ref.cast null
kExprRefNull, 0x6f, // ref.null
kExprRefAsNonNull, // ref.as_non_null
kExprRefNull, 0x6e, // ref.null
kGCPrefix, kExprRefCastNull, 0x6a, // ref.cast null
kExprI32Const, 0xc9, 0x87, 0xfc, 0xe7, 0x06, // i32.const
kExprRefNull, 0x6b, // ref.null
kExprCallFunction, 0x01, // call function #1:
kExprDrop, // drop
kExprDrop, // drop
kExprI32Const, 1,
kExprEnd, // end @147
]);
// Generate function 2 (out of 2).
builder.addFunction(undefined, 3 /* sig */)
.addBody([]);
builder.addExport('main', 0);
const instance = builder.instantiate();
assertThrows(() => instance.exports.main(1, 2, 3));