d0c9775f73
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}
54 lines
1.8 KiB
JavaScript
54 lines
1.8 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.
|
|
|
|
// Helpers to test interoperability of Wasm objects in JavaScript.
|
|
|
|
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
function CreateWasmObjects() {
|
|
let builder = new WasmModuleBuilder();
|
|
let struct_type = builder.addStruct([makeField(kWasmI32, true)]);
|
|
let array_type = builder.addArray(kWasmI32, true);
|
|
builder.addFunction('MakeStruct', makeSig([], [kWasmExternRef]))
|
|
.exportFunc()
|
|
.addBody([
|
|
kExprI32Const, 42, // --
|
|
kGCPrefix, kExprStructNew, struct_type, // --
|
|
kGCPrefix, kExprExternExternalize // --
|
|
]);
|
|
builder.addFunction('MakeArray', makeSig([], [kWasmExternRef]))
|
|
.exportFunc()
|
|
.addBody([
|
|
kExprI32Const, 2, // length
|
|
kGCPrefix, kExprArrayNewDefault, array_type, // --
|
|
kGCPrefix, kExprExternExternalize // --
|
|
]);
|
|
|
|
let instance = builder.instantiate();
|
|
return {
|
|
struct: instance.exports.MakeStruct(),
|
|
array: instance.exports.MakeArray(),
|
|
};
|
|
}
|
|
|
|
function testThrowsRepeated(fn, ErrorType) {
|
|
%PrepareFunctionForOptimization(fn);
|
|
for (let i = 0; i < 5; i++) assertThrows(fn, ErrorType);
|
|
%OptimizeFunctionOnNextCall(fn);
|
|
assertThrows(fn, ErrorType);
|
|
// TODO(7748): This assertion doesn't hold true, as some cases run into
|
|
// deopt loops.
|
|
// assertTrue(%ActiveTierIsTurbofan(fn));
|
|
}
|
|
|
|
function repeated(fn) {
|
|
%PrepareFunctionForOptimization(fn);
|
|
for (let i = 0; i < 5; i++) fn();
|
|
%OptimizeFunctionOnNextCall(fn);
|
|
fn();
|
|
// TODO(7748): This assertion doesn't hold true, as some cases run into
|
|
// deopt loops.
|
|
// assertTrue(%ActiveTierIsTurbofan(fn));
|
|
}
|