27 lines
849 B
JavaScript
27 lines
849 B
JavaScript
|
// Copyright 2021 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-inlining
|
||
|
|
||
|
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||
|
|
||
|
// TODO(12166): Consider running tests with --trace-wasm and inspecting their
|
||
|
// output.
|
||
|
|
||
|
(function SimpleInliningTest() {
|
||
|
let builder = new WasmModuleBuilder();
|
||
|
|
||
|
// f(x) = x - 1
|
||
|
let callee = builder.addFunction("callee", kSig_i_i)
|
||
|
.addBody([kExprLocalGet, 0, kExprI32Const, 1, kExprI32Sub]);
|
||
|
// g(x) = f(5) + x
|
||
|
builder.addFunction("main", kSig_i_i)
|
||
|
.addBody([kExprI32Const, 5, kExprCallFunction, callee.index,
|
||
|
kExprLocalGet, 0, kExprI32Add])
|
||
|
.exportAs("main");
|
||
|
|
||
|
let instance = builder.instantiate();
|
||
|
assertEquals(instance.exports.main(10), 14);
|
||
|
})();
|