swiftwasm / swiftwasm/JavaScriptKit
Ask for Feedback: Make `JSObject` / `JSFunction` calls be `throws`
まだ誰も着手していません。
- 主要言語
- Swift
- スター
- 986
- フォーク
- 76
- 平均マージ
- 21時間 11分
- マージ済み PR(30日)
- 4
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue では JSObject と JSFunction を影響を受ける API として挙げていますが、ファイルやテストのエントリーポイントは示されていません。それらの呼び出し実装と既存の .throws/.throwing の動作を確認し、その後パフォーマンス上のトレードオフを測定して、例外を投げる呼び出しと投げない呼び出しのテストを定義してから、破壊的な API 変更を決定してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, swift, wasm
- 領域
- api
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100