swiftwasm / swiftwasm/JavaScriptKit

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

Offen
#767 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@krodak arbeitet bereits daran.

Seit 11.6.2026.

Vorherrschende Sprache
Swift
Sterne
986
Forks
76
Ø Merge
21 Std. 11 Min.
Gemergte PRs (30 T.)
4

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.