[BridgeJS] Pass String parameters unretained by default
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 28/100
- Tipo de issue
- Refatoração
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- javascript, swift, wasm
- Domínio
- api, performance, web-dev
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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)
- Linguagem predominante
- Swift
- Estrelas
- 986
- Forks
- 76
- Merge médio
- 21h 11min
- PRs com merge (30d)
- 4
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de swiftwasm/JavaScriptKit
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
swiftwasm/JavaScriptKit#793 ·
-
swiftwasm/JavaScriptKit#785 · 1 responsável ·
-
[SwiftBuild] Preserve duplicate archive members when SwiftBuild expands static archives for linking Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
swiftwasm/JavaScriptKit#781 · 3 comentários ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
swiftwasm/JavaScriptKit#773 ·
-
swiftwasm/JavaScriptKit#767 · 1 responsável ·
Todas as issues de swiftwasm/JavaScriptKit
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
manaflow-ai/cmux#13763 ·
-
type: feature request
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
googleapis/google-cloud-swift#1036 · 1 comentário ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
wultra/mtoken-sdk-ios#253 ·
-
The correction-threshold rationale says 17 restraint cases collide; the current corpus has 16 Abertaarea:dictation documentation P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
uttrflow/uttrflow-swift#1180 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100