Ask for Feedback: Make `JSObject` / `JSFunction` calls be `throws`
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Feature
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript, swift, wasm
- Bereich
- api
Rechercherichtung
Das Issue nennt JSObject und JSFunction als die betroffenen APIs, gibt aber keinen Datei- oder Test-Einstiegspunkt an. Überprüfe ihre Aufrufimplementierungen und das bestehende .throws/.throwing-Verhalten, miss anschließend die Performance-Kompromisse und definiere Tests für auslösende und nicht auslösende Aufrufe, bevor du die nicht rückwärtskompatible API-Änderung entscheidest.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Every dynamic JS function calls can throw an exception, but the current JSObject and JSFunction are non-throws by default.
They can be throws by .throws or .throwing but it's still opt-in.
For example, if an exception is thrown during a JS function call but the call site in Swift side is not throws, the control unwinding wasm call frames without executing function epilogues even if there is do { } catch {} clause in Swift. And also in that case, defer blocks won't be called.
This behavior is quite tricky and unwinding wasm call frames without executing function epilogues can lead to memory and resource leak.
I'm going to introduce an API breaking change to make JSObject / JSFunction calls be throws in the next next release to improve the situation.
This change has a performance tradeoff as throws variants are typically a little bit slower than non-throwing variants. We should measure the amount of the penalty but it shouldn't be a big deal. We can make non throwing calls as an opt-in feature so that those who want best performance can satisfy their needs.
// Before
let foo = JSObject.global.document.getElementById!("foo")
let foo = try JSObject.global.document.throwing.getElementById!("foo")
// After
let foo = try JSObject.global.document.getElementById!("foo")
let foo = JSObject.global.document.nonthrowing.getElementById!("foo")
Let me know here if you have a strong objection 🙏 Thanks.
- Vorherrschende Sprache
- Swift
- Sterne
- 986
- Forks
- 76
- Ø Merge
- 21 Std. 11 Min.
- Gemergte PRs (30 T.)
- 4
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus swiftwasm/JavaScriptKit
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
swiftwasm/JavaScriptKit#793 ·
-
swiftwasm/JavaScriptKit#785 · 1 zugewiesene Person ·
-
[SwiftBuild] Preserve duplicate archive members when SwiftBuild expands static archives for linking Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
swiftwasm/JavaScriptKit#781 · 3 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
swiftwasm/JavaScriptKit#773 ·
-
swiftwasm/JavaScriptKit#767 · 1 zugewiesene Person ·
Alle Issues in swiftwasm/JavaScriptKit
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
maxgoedjen/secretive#840 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
manaflow-ai/cmux#13763 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
openwallet-foundation/multipaz#2028 ·