[test][wasm] Migrate to new "addArray(type, {options})" syntax [v8/v8 : main]

0 views
Skip to first unread message

Jakob Kummerow (Gerrit)

unread,
1:07 PM (6 hours ago) 1:07 PM
to Jakob Kummerow, Matthias Liedtke, v8-re...@googlegroups.com
Attention needed from Matthias Liedtke

Jakob Kummerow voted and added 2 comments

Votes added by Jakob Kummerow

Auto-Submit+1
Commit-Queue+1

2 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Jakob Kummerow . resolved

Another test cleanup. PTAL. I recommend starting the review in wasm-module-builder.js.

FYI, this patch was mostly generated by AI.

File test/mjsunit/wasm/wasm-module-builder.js
Line 1383, Patchset 2 (Latest): constructor(fields_or_options) {
Jakob Kummerow . unresolved

At first, I added `type_or_options` to `WasmArray`, then I realized that callers are less verbose if they don't have to spell out `type:`, so I changed it to the `type, options` pair you see below. Of course that now raises the question: would you like to review a follow-up where I apply the same tweak to WasmStruct? Concretely, that would mean
```
builder.addStruct({fields: [makeField(kWasmI32, true)], shared: true});
```
changes to
```
builder.addStruct([makeField(kWasmI32, true)], {shared: true});
```
at the cost of taking away the freedom of freely ordering the entries (it's conceivable that someone might e.g. want to define two struct types `{descriptor: B, fields: [...]}` and `{describes: A, fields: [...]}` where emphasizing their coupling as the first thing improves readability).

Open in Gerrit

Related details

Attention is currently required from:
  • Matthias Liedtke
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: Id7eb4a0417634b322cb204fcbe3677aacfb3136a
Gerrit-Change-Number: 7670839
Gerrit-PatchSet: 2
Gerrit-Owner: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
Gerrit-Comment-Date: Mon, 16 Mar 2026 17:07:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Matthias Liedtke (Gerrit)

unread,
1:28 PM (6 hours ago) 1:28 PM
to Jakob Kummerow, V8 LUCI CQ, v8-re...@googlegroups.com
Attention needed from Jakob Kummerow

Matthias Liedtke added 2 comments

File test/mjsunit/wasm/wasm-module-builder.js
Line 1417, Patchset 2 (Latest): let mutability = true;
Matthias Liedtke . unresolved

Just to clarify, besides changing the signature this change also changes the default value?
How am I supposed to know whether there might be test cases that so far implicitly relied on the implicit `false` but didn't get updated in this change? 😊

Line 1417, Patchset 2 (Latest): let mutability = true;
let is_final = false;
let is_shared = false;
let supertype_idx = kNoSuperType;
if (typeof options === 'object') {
mutability = options.mutable ?? options.mutability ?? true;
is_final = options.is_final ?? options.final ?? false;
is_shared = options.is_shared ?? options.shared ?? false;
supertype_idx = MustBeNumber(
options.supertype_idx ?? options.supertype ?? kNoSuperType,
"supertype");
}
Matthias Liedtke . unresolved
This defines the default value multiple times which has some risk of surprising behavior.
Can't we simply do:
```suggestion
let mutability = options?.mutable ?? options?.mutability ?? true;
let is_final = options?.is_final ?? options?.final ?? false;
let is_shared = options?.is_shared ?? options?.shared ?? false;
let supertype_idx = MustBeNumber(
options?.supertype_idx ?? options?.supertype ?? kNoSuperType,
"supertype");
```
If you dislike it, we should refactor it in a different way that doesn't have separately defined defaults for an empty options object, e.g. use a default parameter `options = {}`.
Open in Gerrit

Related details

Attention is currently required from:
  • Jakob Kummerow
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: Id7eb4a0417634b322cb204fcbe3677aacfb3136a
Gerrit-Change-Number: 7670839
Gerrit-PatchSet: 2
Gerrit-Owner: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
Gerrit-Attention: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Comment-Date: Mon, 16 Mar 2026 17:28:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Jakob Kummerow (Gerrit)

unread,
3:06 PM (4 hours ago) 3:06 PM
to Jakob Kummerow, V8 LUCI CQ, Matthias Liedtke, v8-re...@googlegroups.com
Attention needed from Matthias Liedtke

Jakob Kummerow voted and added 3 comments

Votes added by Jakob Kummerow

Auto-Submit+1

3 comments

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Jakob Kummerow . resolved

Comments addressed, PTAL.

I had also forgotten to update the testcase generator.

File test/mjsunit/wasm/wasm-module-builder.js
Line 1417, Patchset 2: let mutability = true;
Matthias Liedtke . resolved

Just to clarify, besides changing the signature this change also changes the default value?
How am I supposed to know whether there might be test cases that so far implicitly relied on the implicit `false` but didn't get updated in this change? 😊

Jakob Kummerow

Yes, this changes the default for verbosity reasons: mutable arrays are much more useful, so we define them much more often.

If a test "relied" on the implicit default, didn't get updated, and still passes, then it didn't exactly "rely" on it, did it? 😊

But, fine, you're right, we should be careful. In a checkout before this patch, I added `if (typeof mutability === "undefined") throw "..."` to the module builder and ran the test suite, got 8 failures, and added explicit `{mutable: false}` to all of them (even though it technically doesn't matter).

Line 1417, Patchset 2: let mutability = true;

let is_final = false;
let is_shared = false;
let supertype_idx = kNoSuperType;
if (typeof options === 'object') {
mutability = options.mutable ?? options.mutability ?? true;
is_final = options.is_final ?? options.final ?? false;
is_shared = options.is_shared ?? options.shared ?? false;
supertype_idx = MustBeNumber(
options.supertype_idx ?? options.supertype ?? kNoSuperType,
"supertype");
}
Matthias Liedtke . resolved
This defines the default value multiple times which has some risk of surprising behavior.
Can't we simply do:
```suggestion
let mutability = options?.mutable ?? options?.mutability ?? true;
let is_final = options?.is_final ?? options?.final ?? false;
let is_shared = options?.is_shared ?? options?.shared ?? false;
let supertype_idx = MustBeNumber(
options?.supertype_idx ?? options?.supertype ?? kNoSuperType,
"supertype");
```
If you dislike it, we should refactor it in a different way that doesn't have separately defined defaults for an empty options object, e.g. use a default parameter `options = {}`.
Jakob Kummerow

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Matthias Liedtke
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: Id7eb4a0417634b322cb204fcbe3677aacfb3136a
Gerrit-Change-Number: 7670839
Gerrit-PatchSet: 3
Gerrit-Owner: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Reviewer: Jakob Kummerow <jkum...@chromium.org>
Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
Gerrit-Comment-Date: Mon, 16 Mar 2026 19:06:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Matthias Liedtke <mlie...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages