Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vm] Recognize WeakReference in the VM #48162

Closed
dcharkes opened this issue Jan 18, 2022 · 0 comments
Closed

[vm] Recognize WeakReference in the VM #48162

dcharkes opened this issue Jan 18, 2022 · 0 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@dcharkes
Copy link
Contributor

https://dart-review.googlesource.com/c/sdk/+/228206 implements WeakReference in terms of WeakProperty.

The advantage of this approach is that its a small CL and we don't have to modify the GC code deal with both WeakProperty and WeakReference.

The downside is that this causes one extra object per WeakReference (4 words) and one extra load per load of a weak reference.

We should consider implementing WeakReference in the VM.

Things to note for a VM implementation:

  • WeakReferences do not have a target, but do have type arguments (which should not be nulled out).
  • WeakReferences don't need to processed in each cycle to reach the tracing fixpoint but can processed once after the fixpoint.

For more details see internal design doc.

Context: #47777

@dcharkes dcharkes added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Jan 18, 2022
copybara-service bot pushed a commit that referenced this issue Jan 19, 2022
A simple implementation which use two objects per weak reference and
two loads for a load from a weak reference. This can be optimized later.

TEST=runtime/tests/vm/dart/finalizer/weak_reference_run_gc_test.dart

Design doc: go/dart-vm-weakreference

Bug: #47777

Optimization tracking bug: #48162

Change-Id: Id0b71caef940c610f85212fda4bdc267bf84edea
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,benchmark-linux-try,dart-sdk-linux-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-fuchsia-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228206
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

1 participant