v8/test/mjsunit/regress/wasm/regress-1027410.js
Manos Koukoutos 79a1468831 [wasm][wasm-gc][test] Improve and extend Javascript testing API
Changes:
- Add possibility to define and emit all reference types.
- Simplify function locals definition.
- Change 'type' to 'type_index' where appropiate.

Bug: v8:7748
Change-Id: Ie35a6204369e678298ee2ff2ec7c7793c5315c3e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2390144
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69814}
2020-09-10 14:32:00 +00:00

57 lines
1.7 KiB
JavaScript

// Copyright 2019 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.
load('test/mjsunit/wasm/wasm-module-builder.js');
(function() {
const builder = new WasmModuleBuilder();
builder.addType(makeSig([kWasmF64, kWasmF64, kWasmI32, kWasmI32], [kWasmI32]));
builder.addType(makeSig([], [kWasmF64]));
// Generate function 1 (out of 2).
builder.addFunction(undefined, 0 /* sig */)
.addBodyWithEnd([
// signature: i_ddii
// body:
kExprI32Const, 0x01,
kExprEnd, // @3
]);
// Generate function 2 (out of 2).
builder.addFunction(undefined, 1 /* sig */)
.addLocals(kWasmF64, 8)
.addBodyWithEnd([
// signature: d_v
// body:
kExprBlock, kWasmF64, // @3 f64
kExprBlock, kWasmStmt, // @5
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f,
kExprLocalTee, 0x00,
kExprLocalTee, 0x01,
kExprLocalTee, 0x02,
kExprLocalTee, 0x03,
kExprLocalTee, 0x04,
kExprLocalTee, 0x05,
kExprLocalTee, 0x06,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f,
kExprLocalTee, 0x07,
kExprI32Const, 0x00,
kExprIf, kWasmI32, // @52 i32
kExprI32Const, 0x00,
kExprElse, // @56
kExprI32Const, 0x00,
kExprEnd, // @59
kExprBrIf, 0x01, // depth=1
kExprI32UConvertF64,
kExprI32Const, 0x00,
kExprCallFunction, 0x00, // function #0: i_ddii
kExprDrop,
kExprUnreachable,
kExprEnd, // @70
kExprUnreachable,
kExprEnd, // @72
kExprEnd, // @73
]);
assertDoesNotThrow(function() { builder.instantiate(); });
})();