|
| 1 | +// Copyright 2020 the V8 project authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +load('test/mjsunit/wasm/wasm-module-builder.js'); |
| 6 | + |
| 7 | +const builder = new WasmModuleBuilder(); |
| 8 | +builder.addGlobal(kWasmI32, 1); |
| 9 | +builder.addType(makeSig([], [kWasmF64])); |
| 10 | +// Generate function 1 (out of 1). |
| 11 | +builder.addFunction(undefined, 0 /* sig */) |
| 12 | + .addLocals(kWasmI32, 8).addLocals(kWasmI64, 3) |
| 13 | + .addBodyWithEnd([ |
| 14 | +// signature: d_v |
| 15 | +// body: |
| 16 | +kExprGlobalGet, 0x00, // global.get |
| 17 | +kExprLocalSet, 0x00, // local.set |
| 18 | +kExprI32Const, 0x00, // i32.const |
| 19 | +kExprI32Eqz, // i32.eqz |
| 20 | +kExprLocalSet, 0x01, // local.set |
| 21 | +kExprGlobalGet, 0x00, // global.get |
| 22 | +kExprLocalSet, 0x02, // local.set |
| 23 | +kExprI32Const, 0x01, // i32.const |
| 24 | +kExprI32Const, 0x01, // i32.const |
| 25 | +kExprI32Sub, // i32.sub |
| 26 | +kExprLocalSet, 0x03, // local.set |
| 27 | +kExprGlobalGet, 0x00, // global.get |
| 28 | +kExprLocalSet, 0x04, // local.set |
| 29 | +kExprI32Const, 0x00, // i32.const |
| 30 | +kExprI32Eqz, // i32.eqz |
| 31 | +kExprLocalSet, 0x05, // local.set |
| 32 | +kExprGlobalGet, 0x00, // global.get |
| 33 | +kExprLocalSet, 0x06, // local.set |
| 34 | +kExprI32Const, 0x00, // i32.const |
| 35 | +kExprI32Const, 0x01, // i32.const |
| 36 | +kExprI32Sub, // i32.sub |
| 37 | +kExprLocalSet, 0x07, // local.set |
| 38 | +kExprBlock, kWasmStmt, // block @45 |
| 39 | + kExprI32Const, 0x00, // i32.const |
| 40 | + kExprIf, kWasmStmt, // if @49 |
| 41 | + kExprLocalGet, 0x0a, // local.get |
| 42 | + kExprLocalSet, 0x08, // local.set |
| 43 | + kExprElse, // else @55 |
| 44 | + kExprNop, // nop |
| 45 | + kExprEnd, // end @57 |
| 46 | + kExprLocalGet, 0x08, // local.get |
| 47 | + kExprLocalSet, 0x09, // local.set |
| 48 | + kExprLocalGet, 0x09, // local.get |
| 49 | + kExprI64Const, 0xff, 0x01, // i64.const |
| 50 | + kExprI64Add, // i64.add |
| 51 | + kExprDrop, // drop |
| 52 | + kExprEnd, // end @69 |
| 53 | +kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, // f64.const |
| 54 | +kExprEnd, // end @79 |
| 55 | +]); |
| 56 | +builder.instantiate(); |
0 commit comments