2020-05-27 07:45:13 +00:00
|
|
|
// Copyright 2020 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: --trace-wasm --no-wasm-tier-up --liftoff --no-stress-opt
|
|
|
|
|
|
|
|
load('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
|
|
|
|
let builder = new WasmModuleBuilder();
|
|
|
|
let kRet23Function = builder.addFunction('ret_23', kSig_i_v)
|
2020-06-03 13:38:42 +00:00
|
|
|
.addBody([kExprI32Const, 23])
|
|
|
|
.exportFunc()
|
|
|
|
.index;
|
2020-06-05 10:18:29 +00:00
|
|
|
let kCall23Function = builder.addFunction('call_23', kSig_i_v)
|
|
|
|
.addBody([kExprCallFunction, kRet23Function])
|
|
|
|
.exportFunc()
|
|
|
|
.index;
|
2020-06-03 13:38:42 +00:00
|
|
|
let kRet57Function = builder.addFunction('ret_57', kSig_l_v)
|
|
|
|
.addBody([kExprI64Const, 57])
|
|
|
|
.exportFunc()
|
|
|
|
.index;
|
2020-06-05 10:18:29 +00:00
|
|
|
let kUnnamedFunction = builder.addFunction(undefined, kSig_l_v)
|
|
|
|
.addBody([kExprCallFunction, kRet57Function])
|
|
|
|
.index;
|
2020-06-03 13:38:42 +00:00
|
|
|
let kRet0Function = builder.addFunction('ret_0', kSig_f_v)
|
|
|
|
.addBody(wasmF32Const(0))
|
|
|
|
.exportFunc()
|
|
|
|
.index;
|
|
|
|
let kRet1Function = builder.addFunction('ret_1', kSig_d_v)
|
|
|
|
.addBody(wasmF64Const(1))
|
2020-05-27 07:45:13 +00:00
|
|
|
.exportFunc()
|
|
|
|
.index;
|
2020-06-15 10:11:58 +00:00
|
|
|
let kIdentityFunction = builder.addFunction('identity', kSig_i_i)
|
|
|
|
.addBody([kExprLocalGet, 0])
|
|
|
|
.exportFunc()
|
|
|
|
.index;
|
|
|
|
let kCallIdentityFunction = builder.addFunction('call_identity', kSig_i_v)
|
|
|
|
.addBody([
|
|
|
|
kExprI32Const, 42, // -
|
|
|
|
kExprCallFunction, kIdentityFunction // -
|
|
|
|
])
|
|
|
|
.exportFunc()
|
|
|
|
.index;
|
2020-05-27 07:45:13 +00:00
|
|
|
builder.addFunction('main', kSig_v_v)
|
2020-06-03 13:38:42 +00:00
|
|
|
.addBody([
|
2020-06-15 10:11:58 +00:00
|
|
|
kExprCallFunction, kCall23Function, kExprDrop, // -
|
|
|
|
kExprCallFunction, kUnnamedFunction, kExprDrop, // -
|
|
|
|
kExprCallFunction, kRet0Function, kExprDrop, // -
|
|
|
|
kExprCallFunction, kRet1Function, kExprDrop, // -
|
|
|
|
kExprCallFunction, kCallIdentityFunction, kExprDrop // -
|
2020-06-03 13:38:42 +00:00
|
|
|
])
|
2020-05-27 07:45:13 +00:00
|
|
|
.exportAs('main');
|
|
|
|
|
|
|
|
let instance = builder.instantiate();
|
|
|
|
instance.exports.main();
|