v8/test/mjsunit/regress/wasm/regress-12945.js
Manos Koukoutos d0c9775f73 Reland "[wasm-gc][test] Support recursive groups in wasm-module-builder.js"
This is a reland of commit 49b1e977ac

Change compared to original: Fix failing test.

Original change's description:
> [wasm-gc][test] Support recursive groups in wasm-module-builder.js
>
> Bug: v8:7748
> Change-Id: Iff6668891ce785ad2f45ff898d92c6ea9b5f4e7d
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4061691
> Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
> Auto-Submit: Manos Koukoutos <manoskouk@chromium.org>
> Reviewed-by: Matthias Liedtke <mliedtke@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#84534}

Bug: v8:7748
Change-Id: I43b9e480aabe4daaa556d04d4e5d548d2144f93e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4063694
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Auto-Submit: Manos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
Reviewed-by: Matthias Liedtke <mliedtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84551}
2022-11-29 16:47:08 +00:00

46 lines
1.5 KiB
JavaScript

// Copyright 2022 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: --no-liftoff --experimental-wasm-gc --allow-natives-syntax
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
let builder = new WasmModuleBuilder();
let i32_field = makeField(kWasmI32, true);
builder.startRecGroup();
let supertype = builder.addStruct([i32_field]);
let sub1 = builder.addStruct([i32_field, i32_field], supertype);
let sub2 = builder.addStruct([i32_field, makeField(kWasmF64, true)], supertype);
builder.endRecGroup();
let sig = makeSig([wasmRefNullType(supertype)], [kWasmI32]);
let callee = builder.addFunction("callee", sig).addBody([
kExprLocalGet, 0,
kGCPrefix, kExprRefTestDeprecated, sub1,
kExprIf, kWasmVoid,
kExprLocalGet, 0,
kGCPrefix, kExprRefCast, sub1,
kGCPrefix, kExprStructGet, sub1, 0,
kExprReturn,
kExprElse,
kExprLocalGet, 0,
kGCPrefix, kExprRefCast, sub2,
// This {ref.as_non_null} initially believes that it operates on a
// (ref null sub2), and when getting inlined into {crash} realizes
// that its actual type is {bottom} because this branch is unreachable.
kExprRefAsNonNull,
kGCPrefix, kExprStructGet, sub2, 0,
kExprReturn,
kExprEnd,
kExprI32Const, 42,
]);
builder.addFunction("crash", kSig_i_v).addBody([
kGCPrefix, kExprStructNewDefault, sub1,
kExprCallFunction, callee.index,
]).exportFunc();
let instance = builder.instantiate();
instance.exports.crash();