[BridgeJS] Pass String parameters unretained by default
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 28/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, swift, wasm
- Ambito
- api, performance, web-dev
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)
- Lingua principale
- Swift
- Stelle
- 986
- Fork
- 76
- Merge medio
- 21h 11m
- PR unite (30g)
- 4
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di swiftwasm/JavaScriptKit
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
swiftwasm/JavaScriptKit#793 ·
-
swiftwasm/JavaScriptKit#785 · 1 assegnatario ·
-
[SwiftBuild] Preserve duplicate archive members when SwiftBuild expands static archives for linking Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
swiftwasm/JavaScriptKit#781 · 3 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
swiftwasm/JavaScriptKit#773 ·
-
swiftwasm/JavaScriptKit#767 · 1 assegnatario ·
Tutte le issue di swiftwasm/JavaScriptKit
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
maxgoedjen/secretive#840 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
manaflow-ai/cmux#13763 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
openwallet-foundation/multipaz#2028 ·