feat(builtins): support Symbol unregister tokens in FinalizationRegistry#5259
Closed
tkshsbcue wants to merge 1 commit intoboa-dev:mainfrom
Closed
feat(builtins): support Symbol unregister tokens in FinalizationRegistry#5259tkshsbcue wants to merge 1 commit intoboa-dev:mainfrom
tkshsbcue wants to merge 1 commit intoboa-dev:mainfrom
Conversation
Implement CanBeHeldWeakly checks per ECMAScript spec (sec-canbeheldweakly) for FinalizationRegistry.prototype.register and .unregister methods. Non-registered symbols (created via Symbol()) are now accepted as unregister tokens, while registered symbols (Symbol.for()) correctly throw TypeError. Changes: - Add UnregisterToken enum to hold either Object or Symbol tokens - Add is_registered_symbol() helper in symbol module - Update register() to accept symbol unregister tokens - Update unregister() to match against symbol tokens - Add tests for symbol token registration/unregistration and registered symbol rejection Note: Symbol targets (as the first argument to register()) are not yet supported as they require Ephemeron support for non-GC types. Closes boa-dev#5253
Test262 conformance changes
Tested main commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5259 +/- ##
===========================================
+ Coverage 47.24% 59.73% +12.48%
===========================================
Files 476 589 +113
Lines 46892 63424 +16532
===========================================
+ Hits 22154 37886 +15732
- Misses 24738 25538 +800 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
This is doing things backwards. We should first add support for JsSymbol in our Gc and only then add this feature. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement
CanBeHeldWeaklychecks per ECMAScript spec forFinalizationRegistry.prototype.registerand.unregistermethods.Non-registered symbols (created via
Symbol()) are now accepted as unregister tokens, while registered symbols (Symbol.for()) correctly throwTypeError.Changes
UnregisterTokenenum to hold either Object or Symbol tokensis_registered_symbol()helper in symbol moduleregister()to accept symbol unregister tokensunregister()to match against symbol tokensHow it works
The CanBeHeldWeakly abstract operation returns
truewhen:KeyForSymbol(v)isundefined(i.e., not created viaSymbol.for())Previously, only objects were accepted as unregister tokens. Now symbols work too:
Limitations
Symbol targets (first argument to
register()) are not yet supported as they requireEphemeronsupport for non-GC types. This is tracked separately and can be addressed in a follow-up PR.Test plan
Symbol("token")works correctlySymbol.for("x")throwsTypeErrorfor bothregisterandunregisterCloses #5253