Ask for Feedback: Make `JSObject` / `JSFunction` calls be `throws`
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 25/100
- Issue 類型
- 功能
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- javascript, swift, wasm
- 領域
- api
研究方向
該 issue 將 JSObject 和 JSFunction 列為受影響的 API,但沒有提供檔案或測試進入點。檢查它們的呼叫實作以及現有的 .throws/.throwing 行為,接著衡量效能取捨,並定義針對拋出例外與不拋出例外呼叫的測試,再決定是否進行破壞性 API 變更。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Swift
- 星號
- 986
- 分支
- 76
- 平均合併
- 21 小時 11 分鐘
- 30 天內合併 PR
- 4
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
swiftwasm/JavaScriptKit 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 55/100
swiftwasm/JavaScriptKit#793 ·
-
swiftwasm/JavaScriptKit#785 · 已指派 1 人 ·
-
[SwiftBuild] Preserve duplicate archive members when SwiftBuild expands static archives for linking 未關閉
難度 4/5 3-5 天 新手友好度 48/100
swiftwasm/JavaScriptKit#781 · 3 則留言 ·
-
難度 4/5 3-5 天 新手友好度 25/100
swiftwasm/JavaScriptKit#773 ·
-
swiftwasm/JavaScriptKit#767 · 已指派 1 人 ·
查看 swiftwasm/JavaScriptKit 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
manaflow-ai/cmux#13763 ·
-
type: feature request
難度 2/5 1-3 小時 新手友好度 82/100
googleapis/google-cloud-swift#1036 · 1 則留言 ·
-
難度 1/5 1 小時以內 新手友好度 78/100
wultra/mtoken-sdk-ios#253 ·
-
area:dictation documentation P2
難度 2/5 1-3 小時 新手友好度 78/100
uttrflow/uttrflow-swift#1180 ·
-
難度 2/5 1-3 小時 新手友好度 78/100