swiftwasm / swiftwasm/JavaScriptKit
BridgeJS: Remove forced capture workaround in async thunk body closures once swiftlang/swift#89715 lands
@krodak 已經在處理了。
開始於 2026年6月10日。
- 主要語言
- Swift
- 星號
- 986
- 分支
- 76
- 平均合併
- 21 小時 11 分鐘
- 30 天內合併 PR
- 4
描述
Tracks removal of the workaround introduced in #760.
Context
A zero-parameter async throws(JSException) export generates a captureless _bjs_makePromise body closure, which lowers via thin_to_thick_function and miscompiles on Wasm (swiftlang/swift#89320): the thrown error is corrupted across the async unwind, trapping in Promise_reject or rejecting with a garbage value. #760 works around this at the codegen level by forcing a capture in the emitted body closure (the capture must also be read in the body, since an unread capture list entry is dropped by capture analysis and the closure stays thin):
let __bjs_capture = 0
return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { [__bjs_capture] () async throws(JSException) -> String in
_ = __bjs_capture
return try await ping()
}
What to do once the compiler fix ships
The proper fix is swiftlang/swift#89715 (IRGen: fix async typed throws miscompiles on Wasm). Once it is available in the oldest Swift toolchain JavaScriptKit supports:
- Remove
asyncThrowsBodyForcesCaptureand the forced-capture emission fromExportedThunkBuilderinPlugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift. - Regenerate snapshots and the AoT-committed bindings.
- Keep the
zeroArgAsyncThrowsend-to-end regression test as the guard that the reject path still works without the workaround.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
評估
這個 Issue 還沒有評估資料。