swiftwasm / swiftwasm/JavaScriptKit

Improve reference behavior

Aberta
#60 3 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

enhancement
Linguagem predominante
Swift
Estrelas
986
Forks
76
Merge médio
21h 11min
PRs com merge (30d)
4

Descrição

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.

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece por Runtime/src/index.ts, especialmente SwiftRuntimeHeap.release(ref), e reproduza o relatório usando a alteração de logging mostrada na issue. Compare as desalocações repetidas de funções com o tratamento desejado das funções da linguagem JavaScript; considera-se concluído quando um comportamento acordado for implementado para que essas funções não sejam liberadas incorretamente.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
javascript, swift, wasm
Domínio
web-dev
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.