79a1468831
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}
62 lines
1.9 KiB
JavaScript
62 lines
1.9 KiB
JavaScript
// Copyright 2018 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');
|
|
|
|
const builder = new WasmModuleBuilder();
|
|
// Generate function 1 (out of 2).
|
|
sig0 = makeSig([], [kWasmI32]);
|
|
builder.addFunction(undefined, sig0)
|
|
.addBody([
|
|
kExprI64Const, 0xc8, 0xda, 0x9c, 0xbc, 0xf8, 0xf0, 0xe1, 0xc3, 0x87, 0x7f,
|
|
kExprLoop, kWasmF64,
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
kExprCallFunction, 0x01,
|
|
...wasmF64Const(0),
|
|
kExprEnd,
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
...wasmF64Const(0),
|
|
kExprCallFunction, 0x01,
|
|
kExprI64Const, 0xb9, 0xf2, 0xe4, 0x01,
|
|
kExprI64LtS]);
|
|
// Generate function 2 (out of 2).
|
|
sig1 = makeSig(new Array(12).fill(kWasmF64), []);
|
|
builder.addFunction(undefined, sig1).addBody([]);
|
|
builder.addExport('main', 0);
|
|
const instance = builder.instantiate();
|
|
assertEquals(1, instance.exports.main());
|
|
|
|
const builder2 = new WasmModuleBuilder();
|
|
sig0 = makeSig([], [kWasmI32]);
|
|
builder2.addFunction(undefined, sig0).addLocals(kWasmI64, 1).addBody([
|
|
kExprLoop, kWasmI32, // loop i32
|
|
kExprLocalGet, 0, // get_local 3
|
|
kExprF32SConvertI64, // f32.sconvert/i64
|
|
kExprI32ReinterpretF32, // i32.reinterpret/f32
|
|
kExprEnd // end
|
|
]);
|
|
builder2.addExport('main', 0);
|
|
const instance2 = builder2.instantiate();
|
|
assertEquals(0, instance2.exports.main());
|