[BridgeJS] Pass String parameters unretained by default
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 28/100
- Type d'issue
- Refactorisation
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- javascript, swift, wasm
- Domaine
- api, performance, web-dev
Piste de recherche
Start by tracing _swift_js_make_js_string, bridgeJSLowerParameter, and the generated bjs_hello thunk shown in the issue, then inspect how JSString references are represented. Done means ordinary String parameters cross the bridge without a JS memory-store retain/release cycle while JSString still supports caller-controlled by-reference reuse; verify the impact against the ElementaryUI performance benchmarks.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
When calling a JS function through BridgeJS with String parameters, every String is
- lowered by calling
_swift_js_make_js_string - which decodes and retains in JS object store (new entry, new ref = 1)
- the object store ref is passed as wasm parameter
- the JS thunk immediately get the object and releases (count--, remove from store)
this is very wasteful, and makes retain the number one bottleneck in current ElementaryUI performance benchmarks.
Example:
@JSFunction func hello(_ v: String) throws
// generates
func _$hello(_ v: String) throws(JSException) -> Void {
let vValue = v.bridgeJSLowerParameter()
bjs_hello(vValue)
if let error = _swift_js_take_exception() {
throw error
}
}
function bjs_hello(v) {
try {
const vObject = swift.memory.getObject(v);
swift.memory.release(v);
imports.hello(vObject);
} catch (error) {
setException(error);
}
}
I suggest:
- passing
Stringalways "in-line" (ie: as address + length) without retaining in the JSmemorystore - still support
JSStringby-ref to control Swift caller caching (ie: retain once and use same ref multiple times)
- 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