Ask for Feedback: Make `JSObject` / `JSFunction` calls be `throws`
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- javascript, swift, wasm
- Domaine
- api
Piste de recherche
L’issue nomme JSObject et JSFunction comme les API concernées, mais ne fournit aucun fichier ni point d’entrée de test. Examinez leurs implémentations d’appel et le comportement existant de .throws/.throwing, puis mesurez le compromis de performance et définissez des tests pour les appels avec et sans exception avant de décider de la modification rétroincompatible de l’API.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Swift
- Étoiles
- 986
- Forks
- 76
- Merge moyen
- 21 h 11 min
- PR mergées (30 j)
- 4
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de swiftwasm/JavaScriptKit
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
swiftwasm/JavaScriptKit#793 ·
-
swiftwasm/JavaScriptKit#785 · 1 personne assignée ·
-
[SwiftBuild] Preserve duplicate archive members when SwiftBuild expands static archives for linking Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
swiftwasm/JavaScriptKit#781 · 3 commentaires ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
swiftwasm/JavaScriptKit#773 ·
-
swiftwasm/JavaScriptKit#767 · 1 personne assignée ·
Toutes les issues de swiftwasm/JavaScriptKit
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
manaflow-ai/cmux#13763 ·
-
type: feature request
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
googleapis/google-cloud-swift#1036 · 1 commentaire ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
wultra/mtoken-sdk-ios#253 ·
-
The correction-threshold rationale says 17 restraint cases collide; the current corpus has 16 Ouvertearea:dictation documentation P2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
uttrflow/uttrflow-swift#1180 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100