swiftwasm / swiftwasm/JavaScriptKit

Improve reference behavior

オープン
#60 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement
主要言語
Swift
スター
986
フォーク
76
平均マージ
21時間 11分
マージ済み PR(30日)
4

説明

I made a small change to report whenever an object ref is deleted:

---
 Runtime/src/index.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Runtime/src/index.ts b/Runtime/src/index.ts
index 0e641ff..ddfba4e 100644
--- a/Runtime/src/index.ts
+++ b/Runtime/src/index.ts
@@ -93,6 +93,7 @@ class SwiftRuntimeHeap {
     release(ref: ref) {
         const value = this._heapValueById.get(ref);
         const isObject = typeof value == "object"
+        console.log('dereferencing', value);
         if (isObject) {
             const entry = this._heapEntryByValue.get(value)!;
             entry.rc--;

(copy the content of the code block and run pbpaste | git apply in your terminal to make this change)

It reports many deallocations. The thing that caught my attention was the repeated deallocation of functions (like toString and hasOwnProperty). I wonder if there’s a way to recognize functions that are part of the JavaScript language and either dynamically call them when needed or mark them so they don’t get released.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Runtime/src/index.ts、特に SwiftRuntimeHeap.release(ref) から始め、issue に示されているロギングの変更を使って報告を再現してください。関数の繰り返しの解放を、JavaScript 言語関数に対する望ましい処理と比較してください。これらの関数が誤って解放されないよう、合意された動作が実装されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, swift, wasm
領域
web-dev
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。