[wasm] Add stack trace API test for Wasm-in-JS inlining [v8/v8 : main]

0 views
Skip to first unread message

Daniel Lehmann (Gerrit)

unread,
Apr 2, 2026, 6:43:48 AM (4 days ago) Apr 2
to Matthias Liedtke, V8 LUCI CQ, v8-re...@googlegroups.com
Attention needed from Matthias Liedtke

Daniel Lehmann voted and added 1 comment

Votes added by Daniel Lehmann

Auto-Submit+1

1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Daniel Lehmann . resolved

Finally getting around to a more in-depth test of Wasm-in-JS body inlining with V8's non-standard stack trace API. Could you please take a look?

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 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: I6ff6ba55b00cd25ad95bddf459bae8de61d00647
Gerrit-Change-Number: 7722341
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Lehmann <dleh...@chromium.org>
Gerrit-Reviewer: Daniel Lehmann <dleh...@chromium.org>
Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
Gerrit-Comment-Date: Thu, 02 Apr 2026 10:43:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Matthias Liedtke (Gerrit)

unread,
Apr 2, 2026, 6:47:22 AM (4 days ago) Apr 2
to Daniel Lehmann, V8 LUCI CQ, v8-re...@googlegroups.com
Attention needed from Daniel Lehmann

Matthias Liedtke added 1 comment

File test/filecheck/wasm-in-js-inlining-turboshaft-stacktrace-api.js
Line 5, Patchset 1 (Latest):// Flags: --turbolev --turbolev-inline-js-wasm-wrappers
// Flags: --turboshaft-wasm-in-js-inlining
// Flags: --allow-natives-syntax
// Flags: --trace-turbo-inlining
Matthias Liedtke . unresolved

Is this consistent with `wasm-gc-inlining-stacktrace-api.js` and the only meaningful change are the flags and the filecheck assertions that we are indeed inlining?

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Lehmann
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: I6ff6ba55b00cd25ad95bddf459bae8de61d00647
    Gerrit-Change-Number: 7722341
    Gerrit-PatchSet: 1
    Gerrit-Owner: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Attention: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Comment-Date: Thu, 02 Apr 2026 10:47:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Lehmann (Gerrit)

    unread,
    Apr 2, 2026, 6:58:43 AM (4 days ago) Apr 2
    to Matthias Liedtke, V8 LUCI CQ, v8-re...@googlegroups.com
    Attention needed from Matthias Liedtke

    Daniel Lehmann added 1 comment

    File test/filecheck/wasm-in-js-inlining-turboshaft-stacktrace-api.js
    Line 5, Patchset 1 (Latest):// Flags: --turbolev --turbolev-inline-js-wasm-wrappers
    // Flags: --turboshaft-wasm-in-js-inlining
    // Flags: --allow-natives-syntax
    // Flags: --trace-turbo-inlining
    Matthias Liedtke . unresolved

    Is this consistent with `wasm-gc-inlining-stacktrace-api.js` and the only meaningful change are the flags and the filecheck assertions that we are indeed inlining?

    Daniel Lehmann

    Oh, I hadn't looked at that (but apparently Gemini has). I let Gemini generate something and then iterated on it a couple of times to a) simplify and b) increase coverage of the stack trace API. Indeed, they are very similar, but the differences are:

    • The new body inlining doesn't support several of the instructions in the old test, hence using array.len instead of struct.new and extern.convert_any etc. to trigger the trap.
    • My test covers more of the API, e.g., getLineNumber, getPosition, the error type and `message` property, the number of frames and some frames above the Wasm and JS caller.
    • My test is a filecheck test that ensures we actually inline.
    • Your test also covers when the wasm call is inside a try-catch (which we don't inline atm).

    Not sure, keep both or shall I instead extend yours + simply include it in my test?

    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: I6ff6ba55b00cd25ad95bddf459bae8de61d00647
    Gerrit-Change-Number: 7722341
    Gerrit-PatchSet: 1
    Gerrit-Owner: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Comment-Date: Thu, 02 Apr 2026 10:58:36 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Matthias Liedtke <mlie...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Lehmann (Gerrit)

    unread,
    Apr 2, 2026, 8:57:27 AM (4 days ago) Apr 2
    to Matthias Liedtke, V8 LUCI CQ, v8-re...@googlegroups.com
    Attention needed from Matthias Liedtke

    Daniel Lehmann voted and added 5 comments

    Votes added by Daniel Lehmann

    Auto-Submit+0

    5 comments

    File test/filecheck/wasm-in-js-inlining-turboshaft-stacktrace-api.js
    Line 5, Patchset 1:// Flags: --turbolev --turbolev-inline-js-wasm-wrappers

    // Flags: --turboshaft-wasm-in-js-inlining
    // Flags: --allow-natives-syntax
    // Flags: --trace-turbo-inlining
    Matthias Liedtke . unresolved

    Is this consistent with `wasm-gc-inlining-stacktrace-api.js` and the only meaningful change are the flags and the filecheck assertions that we are indeed inlining?

    Daniel Lehmann

    Oh, I hadn't looked at that (but apparently Gemini has). I let Gemini generate something and then iterated on it a couple of times to a) simplify and b) increase coverage of the stack trace API. Indeed, they are very similar, but the differences are:

    • The new body inlining doesn't support several of the instructions in the old test, hence using array.len instead of struct.new and extern.convert_any etc. to trigger the trap.
    • My test covers more of the API, e.g., getLineNumber, getPosition, the error type and `message` property, the number of frames and some frames above the Wasm and JS caller.
    • My test is a filecheck test that ensures we actually inline.
    • Your test also covers when the wasm call is inside a try-catch (which we don't inline atm).

    Not sure, keep both or shall I instead extend yours + simply include it in my test?

    Daniel Lehmann

    I decided to improve the old test, and reuse it in the new one (the `// Flags:` comments if imported files are not carried over by the test runner, which is good in this case). Also fixed the test failures.

    File test/mjsunit/wasm/wasm-gc-inlining-stacktrace-api.js
    Line 6, Patchset 2 (Parent):// Flags: --no-always-sparkplug --expose-gc
    Daniel Lehmann . unresolved

    Drive-by: We never explicitly `gc()` here, so I removed that flag.

    Line 13, Patchset 2 (Parent): for (let i = 0; i < 10; ++i) {
    Daniel Lehmann . unresolved

    What's the reason for running 10 times before `OptimizeFunctionOnNextCall`? Doesn't the latter enforce that we tier-up and running once unoptimized is sufficient?

    Line 15, Patchset 2 (Latest): Error.prepareStackTrace = (error, frames) => {
    Daniel Lehmann . unresolved

    This function was duplicated, so I decided to pull it into the `testOptimized` helper instead of repeating the comments and assertions.

    Line 96, Patchset 2 (Latest): const globalNullArray = builder.addGlobal(wasmRefNullType(array), true, false);
    Daniel Lehmann . unresolved

    I changed the trapping Wasm function to `array.len` on a null array, since that's also supported by the new inlining, whereas `struct.new` was not.

    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: I6ff6ba55b00cd25ad95bddf459bae8de61d00647
    Gerrit-Change-Number: 7722341
    Gerrit-PatchSet: 2
    Gerrit-Owner: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Comment-Date: Thu, 02 Apr 2026 12:57:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Daniel Lehmann <dleh...@chromium.org>
    Comment-In-Reply-To: Matthias Liedtke <mlie...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Matthias Liedtke (Gerrit)

    unread,
    Apr 2, 2026, 9:44:08 AM (4 days ago) Apr 2
    to Daniel Lehmann, V8 LUCI CQ, v8-re...@googlegroups.com
    Attention needed from Daniel Lehmann

    Matthias Liedtke added 6 comments

    File test/filecheck/wasm-in-js-inlining-turboshaft-stacktrace-api.js
    Line 5, Patchset 1:// Flags: --turbolev --turbolev-inline-js-wasm-wrappers
    // Flags: --turboshaft-wasm-in-js-inlining
    // Flags: --allow-natives-syntax
    // Flags: --trace-turbo-inlining
    Matthias Liedtke . resolved

    Is this consistent with `wasm-gc-inlining-stacktrace-api.js` and the only meaningful change are the flags and the filecheck assertions that we are indeed inlining?

    Daniel Lehmann

    Oh, I hadn't looked at that (but apparently Gemini has). I let Gemini generate something and then iterated on it a couple of times to a) simplify and b) increase coverage of the stack trace API. Indeed, they are very similar, but the differences are:

    • The new body inlining doesn't support several of the instructions in the old test, hence using array.len instead of struct.new and extern.convert_any etc. to trigger the trap.
    • My test covers more of the API, e.g., getLineNumber, getPosition, the error type and `message` property, the number of frames and some frames above the Wasm and JS caller.
    • My test is a filecheck test that ensures we actually inline.
    • Your test also covers when the wasm call is inside a try-catch (which we don't inline atm).

    Not sure, keep both or shall I instead extend yours + simply include it in my test?

    Daniel Lehmann

    I decided to improve the old test, and reuse it in the new one (the `// Flags:` comments if imported files are not carried over by the test runner, which is good in this case). Also fixed the test failures.

    Matthias Liedtke

    Acknowledged

    File test/mjsunit/wasm/wasm-gc-inlining-stacktrace-api.js
    Line 6, Patchset 2 (Parent):// Flags: --no-always-sparkplug --expose-gc
    Daniel Lehmann . resolved

    Drive-by: We never explicitly `gc()` here, so I removed that flag.

    Matthias Liedtke

    Acknowledged

    Line 13, Patchset 2 (Parent): for (let i = 0; i < 10; ++i) {
    Daniel Lehmann . resolved

    What's the reason for running 10 times before `OptimizeFunctionOnNextCall`? Doesn't the latter enforce that we tier-up and running once unoptimized is sufficient?

    Matthias Liedtke

    There was an issue with lazy feedback allocation IIRC, so it was necessary to run more than once.

    Line 15, Patchset 2 (Latest): Error.prepareStackTrace = (error, frames) => {
    Daniel Lehmann . resolved

    This function was duplicated, so I decided to pull it into the `testOptimized` helper instead of repeating the comments and assertions.

    Matthias Liedtke

    Acknowledged

    Line 33, Patchset 2 (Latest): // - the line number is always 1
    assertEquals(1, frame.getLineNumber());
    // - the bytecode offset (1-based)
    const wasmFunctionBytecodeOffset = 0x3A;
    Matthias Liedtke . resolved

    Oh, I forgot all the awesomeness about this like we have one line and the column is not the same as the byte offset as it starts with 1. None of these values are useful for Wasm. 😊

    Line 96, Patchset 2 (Latest): const globalNullArray = builder.addGlobal(wasmRefNullType(array), true, false);
    Daniel Lehmann . unresolved

    I changed the trapping Wasm function to `array.len` on a null array, since that's also supported by the new inlining, whereas `struct.new` was not.

    Matthias Liedtke

    This doesn't work though, the old inlining doesn't support `global.get`, you'd need to pass it as an argument and do `any.convert_extern` to do that which I think the new inlining doesn't support, yet?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Lehmann
    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: I6ff6ba55b00cd25ad95bddf459bae8de61d00647
    Gerrit-Change-Number: 7722341
    Gerrit-PatchSet: 2
    Gerrit-Owner: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Attention: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Comment-Date: Thu, 02 Apr 2026 13:44:03 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Lehmann (Gerrit)

    unread,
    Apr 2, 2026, 10:12:26 AM (4 days ago) Apr 2
    to Matthias Liedtke, V8 LUCI CQ, v8-re...@googlegroups.com
    Attention needed from Matthias Liedtke

    Daniel Lehmann added 1 comment

    File test/mjsunit/wasm/wasm-gc-inlining-stacktrace-api.js
    Line 96, Patchset 2: const globalNullArray = builder.addGlobal(wasmRefNullType(array), true, false);
    Daniel Lehmann . unresolved

    I changed the trapping Wasm function to `array.len` on a null array, since that's also supported by the new inlining, whereas `struct.new` was not.

    Matthias Liedtke

    This doesn't work though, the old inlining doesn't support `global.get`, you'd need to pass it as an argument and do `any.convert_extern` to do that which I think the new inlining doesn't support, yet?

    Daniel Lehmann

    Uhoh, indeed. The only reference we can pass in is `externref`, but then I cannot convert that for `array.len`. Yet another reason to support `any.convert_extern` and `ref.cast` in the new inlining... I'll pause this CL until I've done that and leave this unresolved as a reminder to change the Wasm body.

    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: I6ff6ba55b00cd25ad95bddf459bae8de61d00647
    Gerrit-Change-Number: 7722341
    Gerrit-PatchSet: 3
    Gerrit-Owner: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Daniel Lehmann <dleh...@chromium.org>
    Gerrit-Reviewer: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Attention: Matthias Liedtke <mlie...@chromium.org>
    Gerrit-Comment-Date: Thu, 02 Apr 2026 14:12:22 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages