nodejs/deps/v8/test/mjsunit/regress/wasm/condition-change-during-branch-elimination.js
Michaël Zasso 50930a0fa0
deps: update V8 to 9.3.345.16
PR-URL: https://github.com/nodejs/node/pull/39469
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-08-30 21:02:51 +02:00

50 lines
1.5 KiB
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.
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
// 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([
kExprLoop, kWasmVoid,
kExprLocalGet, 0x02,
kExprLocalTee, 0x01,
kExprIf, kWasmVoid,
kExprElse,
kExprLoop, kWasmVoid,
kExprLoop, kWasmVoid,
kExprLocalGet, 0x01,
kExprIf, kWasmVoid,
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);
})();