Skip to content

fix(runtime): process weak refs after manual gc#4297

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-weakref-finalization
Jun 4, 2026
Merged

fix(runtime): process weak refs after manual gc#4297
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-weakref-finalization

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

  • treat WeakRef and FinalizationRegistry target slots as weak GC edges
  • clear collected WeakRef targets and queue FinalizationRegistry cleanup jobs after explicit gc()
  • add a regression covering WeakRef clearing, unregister suppression, and cleanup delivery

Tests

  • cargo fmt --all --check
  • CARGO_TARGET_DIR=/root/perry-worktrees/.build-targets/perry-weakref-check cargo check -p perry-hir -p perry-codegen -p perry-runtime -p perry-stdlib
  • CARGO_TARGET_DIR=/root/perry-worktrees/.build-targets/perry-weakref-build cargo build -p perry --release
  • CARGO_TARGET_DIR=/root/perry-worktrees/.build-targets/perry-weakref-build cargo build -p perry-runtime -p perry-stdlib --release
  • TMPDIR=/root/perry-worktrees/.tmp PERRY_GEN_GC=0 PERRY_NO_AUTO_OPTIMIZE=1 PERRY_RUNTIME_DIR=/root/perry-worktrees/.build-targets/perry-weakref-build/release /root/perry-worktrees/.build-targets/perry-weakref-build/release/perry run test-files/test_issue_2656_weakref_finalization_gc.ts
  • TMPDIR=/root/perry-worktrees/.tmp PERRY_GEN_GC=0 PERRY_NO_AUTO_OPTIMIZE=1 PERRY_RUNTIME_DIR=/root/perry-worktrees/.build-targets/perry-weakref-build/release /root/perry-worktrees/.build-targets/perry-weakref-build/release/perry run test-files/test_gap_weakref_finalization.ts
  • TMPDIR=/root/perry-worktrees/.tmp PERRY_GEN_GC=0 PERRY_NO_AUTO_OPTIMIZE=1 PERRY_RUNTIME_DIR=/root/perry-worktrees/.build-targets/perry-weakref-build/release /root/perry-worktrees/.build-targets/perry-weakref-build/release/perry run test-files/test_issue_1766_weakref_internal_fields.ts
  • TMPDIR=/root/perry-worktrees/.tmp PERRY_GEN_GC=0 PERRY_NO_AUTO_OPTIMIZE=1 PERRY_RUNTIME_DIR=/root/perry-worktrees/.build-targets/perry-weakref-build/release /root/perry-worktrees/.build-targets/perry-weakref-build/release/perry run test-parity/node-suite/globals/weakref-finalization-validation.ts

@proggeramlug proggeramlug marked this pull request as ready for review June 4, 2026 10:04
@proggeramlug proggeramlug merged commit 495d469 into PerryTS:main Jun 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants