2021-03-19 11:16:25 +00:00
|
|
|
// 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.
|
|
|
|
|
2021-06-01 12:46:36 +00:00
|
|
|
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
2021-03-19 11:16:25 +00:00
|
|
|
|
|
|
|
// This test creates the situation where BranchElimination's VisitIf sees a
|
|
|
|
// different condition than the preceding VisitBranch (because an interleaved
|
|
|
|
// CommonOperatorReducer replaced the condition).
|
|
|
|
|
|
|
|
(function foo() {
|
|
|
|
let builder = new WasmModuleBuilder();
|
|
|
|
|
|
|
|
builder.addFunction("main", kSig_v_l)
|
|
|
|
.addLocals(kWasmI32, 2)
|
|
|
|
.addBody([
|
2021-03-22 06:56:01 +00:00
|
|
|
kExprLoop, kWasmVoid,
|
2021-03-19 11:16:25 +00:00
|
|
|
kExprLocalGet, 0x02,
|
|
|
|
kExprLocalTee, 0x01,
|
2021-03-22 06:56:01 +00:00
|
|
|
kExprIf, kWasmVoid,
|
2021-03-19 11:16:25 +00:00
|
|
|
kExprElse,
|
2021-03-22 06:56:01 +00:00
|
|
|
kExprLoop, kWasmVoid,
|
|
|
|
kExprLoop, kWasmVoid,
|
2021-03-19 11:16:25 +00:00
|
|
|
kExprLocalGet, 0x01,
|
2021-03-22 06:56:01 +00:00
|
|
|
kExprIf, kWasmVoid,
|
2021-03-19 11:16:25 +00:00
|
|
|
kExprElse,
|
|
|
|
kExprLocalGet, 0x02,
|
|
|
|
kExprBrIf, 0x04,
|
|
|
|
kExprBr, 0x01,
|
|
|
|
kExprEnd,
|
|
|
|
kExprLocalGet, 0x00,
|
|
|
|
kExprCallFunction, 0x01,
|
|
|
|
kExprLocalTee, 0x02,
|
|
|
|
kExprBrIf, 0x00,
|
|
|
|
kExprEnd,
|
|
|
|
kExprLocalGet, 0x01,
|
|
|
|
kExprBrIf, 0x00,
|
|
|
|
kExprEnd,
|
|
|
|
kExprEnd,
|
|
|
|
kExprBr, 0x00,
|
|
|
|
kExprEnd])
|
|
|
|
.exportAs("main");
|
|
|
|
|
|
|
|
builder.addFunction("callee", kSig_i_l)
|
|
|
|
.addBody([kExprLocalGet, 0, kExprI32ConvertI64]);
|
|
|
|
|
|
|
|
let module = new WebAssembly.Module(builder.toBuffer());
|
|
|
|
let instance = new WebAssembly.Instance(module);
|
|
|
|
})();
|