swiftwasm / swiftwasm/JavaScriptKit

BridgeJS: Remove JSException storage boxing once swiftlang/swift#89715 lands

未关闭
#767 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@krodak 已经在做这个了。

开始于 2026年6月11日。

主要语言
Swift
星标
986
派生
76
平均合并
21 小时 11 分钟
30 天内合并 PR
4

描述

Tracks removal of the JSException storage boxing introduced in #766.

Context

swiftlang/swift#89320 miscompiles Wasm calls to captureless async throws(JSException) closure values when the typed error exceeds the direct error convention: the thrown error is corrupted across the async unwind, so the rejected Promise receives garbage. JSException (~36 bytes) always took the affected indirect-error path.

#766 works around this at the library level by boxing JSException's stored properties (thrownValue, description, stack) into a private final class, shrinking the struct to a single stored reference so it travels in the direct error convention and the broken path is never taken. The public API is unchanged; the cost is one heap allocation per thrown exception. The original exploration is in https://github.com/PassiveLogic/JavaScriptKit/pull/13.

The codegen-level counterpart for zero-parameter async throwing exports is tracked separately in #761.

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:

  • Move thrownValue, description, and stack back to stored properties on JSException and delete the Storage class. This is a library-internal layout change only, not a breaking API change.
  • Keep the async closure reject end-to-end tests as the regression guard that the reject path still works without the boxing.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。