[BridgeJS] Pass String parameters unretained by default
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, swift, wasm
- Lĩnh vực
- api, performance, web-dev
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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)
- Ngôn ngữ chính
- Swift
- Star
- 986
- Fork
- 76
- Merge trung bình
- 21 giờ 11 phút
- Pull request đã merge (30 ngày)
- 4
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của swiftwasm/JavaScriptKit
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
swiftwasm/JavaScriptKit#793 ·
-
swiftwasm/JavaScriptKit#785 · 1 người được giao ·
-
[SwiftBuild] Preserve duplicate archive members when SwiftBuild expands static archives for linking Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
swiftwasm/JavaScriptKit#781 · 3 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
swiftwasm/JavaScriptKit#773 ·
-
swiftwasm/JavaScriptKit#767 · 1 người được giao ·
Tất cả issue của swiftwasm/JavaScriptKit
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
maxgoedjen/secretive#840 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
manaflow-ai/cmux#13763 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
openwallet-foundation/multipaz#2028 ·