Skip to content

[JSC][WASM][Debugger] Capture source bytes for streaming-compiled WebAssembly modules#62317

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
hyjorc1:eng/JSC-WASM-Debugger-Capture-source-bytes-for-streaming-compiled-WebAssembly-modules
Apr 9, 2026
Merged

[JSC][WASM][Debugger] Capture source bytes for streaming-compiled WebAssembly modules#62317
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
hyjorc1:eng/JSC-WASM-Debugger-Capture-source-bytes-for-streaming-compiled-WebAssembly-modules

Conversation

@hyjorc1
Copy link
Copy Markdown
Contributor

@hyjorc1 hyjorc1 commented Apr 8, 2026

e435f7f

[JSC][WASM][Debugger] Capture source bytes for streaming-compiled WebAssembly modules
https://bugs.webkit.org/show_bug.cgi?id=311773
rdar://174362152

Reviewed by Keith Miller.

WebAssembly.instantiateStreaming (and its compile variant) feed module bytes
incrementally through StreamingCompiler::addBytes. Unlike the synchronous path,
there is no single source vector that gets moved into ModuleInformation at the
end — so debugInfo->source remained empty for every streaming-compiled module.

Fix by accumulating bytes into debugInfo->source inside StreamingCompiler::addBytes
(guarded by ENABLE(WEBASSEMBLY_DEBUGGER)).  Guard the existing takeSource call in
EntryPlan::takeModuleInformation so it no longer overwrites bytes that the streaming
path already populated.

Tests:
* JSTests/wasm/debugger/tests/tests.py: (StreamingModuleLoadTestCase)

Canonical link: https://commits.webkit.org/310852@main

7e8e635

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style 🛠 ios 🛠 mac 🛠 wpe 🛠 win ⏳ 🛠 ios-apple
🛠 ios-sim 🛠 mac-AS-debug 🧪 wpe-wk2 🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl 🧪 ios-wk2 🧪 api-mac 🧪 api-wpe ⏳ 🛠 vision-apple
🧪 ios-wk2-wpt 🧪 api-mac-debug 🛠 gtk3-libwebrtc
🛠 🧪 jsc 🧪 api-ios 🧪 mac-wk1 ❌ 🛠 gtk
🛠 🧪 jsc-debug-arm64 🛠 ios-safer-cpp 🧪 mac-wk2 ❌ 🧪 gtk-wk2
🛠 vision 🧪 mac-AS-debug-wk2 ❌ 🧪 api-gtk
🛠 vision-sim 🧪 mac-wk2-stress 🛠 playstation
✅ 🛠 🧪 unsafe-merge 🧪 vision-wk2 🧪 mac-intel-wk2 ✅ 🛠 jsc-armv7
🛠 tv 🛠 mac-safer-cpp 🧪 jsc-armv7-tests
🛠 tv-sim
🛠 watch
🛠 watch-sim

@hyjorc1 hyjorc1 self-assigned this Apr 8, 2026
@hyjorc1 hyjorc1 requested a review from a team as a code owner April 8, 2026 23:51
@hyjorc1 hyjorc1 added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Apr 8, 2026
@hyjorc1 hyjorc1 force-pushed the eng/JSC-WASM-Debugger-Capture-source-bytes-for-streaming-compiled-WebAssembly-modules branch from 5c63954 to 957a492 Compare April 9, 2026 17:17
Comment on lines +58 to +62
#if ENABLE(WEBASSEMBLY_DEBUGGER)
// Accumulate source bytes for the debugger — the streaming path has no single source vector.
if (Options::enableWasmDebugger()) [[unlikely]]
m_info->debugInfo->source.append(bytes);
#endif
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just transfer the bytes when the entry plan finishes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bytes are transient m_buffer borrowed views into the caller's buffer that are gone once addBytes returns. StreamingParser processes them into ModuleInformation structures but does not retain the raw binary, so by the time the plan finishes and takeModuleInformation is called there are no bytes left to transfer. We must capture them here, as each chunk arrives.

Copy link
Copy Markdown
Contributor

@kmiller68 kmiller68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with nit

Comment thread Source/JavaScriptCore/wasm/WasmStreamingCompiler.h Outdated
@hyjorc1 hyjorc1 force-pushed the eng/JSC-WASM-Debugger-Capture-source-bytes-for-streaming-compiled-WebAssembly-modules branch from 957a492 to 7e8e635 Compare April 9, 2026 18:03
@hyjorc1 hyjorc1 added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Apr 9, 2026
…Assembly modules

https://bugs.webkit.org/show_bug.cgi?id=311773
rdar://174362152

Reviewed by Keith Miller.

WebAssembly.instantiateStreaming (and its compile variant) feed module bytes
incrementally through StreamingCompiler::addBytes. Unlike the synchronous path,
there is no single source vector that gets moved into ModuleInformation at the
end — so debugInfo->source remained empty for every streaming-compiled module.

Fix by accumulating bytes into debugInfo->source inside StreamingCompiler::addBytes
(guarded by ENABLE(WEBASSEMBLY_DEBUGGER)).  Guard the existing takeSource call in
EntryPlan::takeModuleInformation so it no longer overwrites bytes that the streaming
path already populated.

Tests:
* JSTests/wasm/debugger/tests/tests.py: (StreamingModuleLoadTestCase)

Canonical link: https://commits.webkit.org/310852@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/JSC-WASM-Debugger-Capture-source-bytes-for-streaming-compiled-WebAssembly-modules branch from 7e8e635 to e435f7f Compare April 9, 2026 18:05
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 310852@main (e435f7f): https://commits.webkit.org/310852@main

Reviewed commits have been landed. Closing PR #62317 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit e435f7f into WebKit:main Apr 9, 2026
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Bugs Unclassified bugs are placed in this component until the correct component can be determined.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants