-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Implement WeakSet
object
#2009
Implement WeakSet
object
#2009
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2009 +/- ##
==========================================
+ Coverage 45.89% 45.98% +0.09%
==========================================
Files 206 207 +1
Lines 17150 17213 +63
==========================================
+ Hits 7871 7916 +45
- Misses 9279 9297 +18
Continue to review full report at Codecov.
|
Hi @lupd, Thanks for the contribution! Objects that are added to a Because it is tricky (impossible?) to demonstrate this with let ref;
{
let obj = {};
ref = new WeakRef(obj);
// This will always be `{}`
ref.deref()
}
// `obj` is now out of scope.
// This means that the object that was assigned to `obj` is now only weakly referenced by `ref`.
// The gc can now collect the object.
// This may be `{}` if the object was not yet collected.
// But at some point it will be `undefined` because the weak reference has been collected.
ref.deref() If you want to try that code in I think this behavior is not possible with our current gc in boa. We are using rust-gc as our garbage collector and that crate does not implement weak gc references as far as I know. We definitely weed weak gc references in boa for |
I think this is blocked on having weak references in the garbage collector. |
True :) There seems to be a draft PR for this: Manishearth/rust-gc#148 |
It's a bit of a work in progress...on a couple fronts 😅 |
This Pull Request implements the
WeakSet
object.It changes the following:
WeakSet
as a newObjectKind
.WeakSet
.WeakSet
object (constructor, properties, instance methods, etc.).WeakSet
object.With these changes, the entire test suite for
WeakSet
passes. As well, additional tests usingWeakSet
(e.g. 14 tests in theSet
test suite) also pass.