lib: refactor internal webidl converters#62979
Open
panva wants to merge 1 commit intonodejs:mainfrom
Open
Conversation
Collaborator
|
Review requested:
|
ChALkeR
reviewed
Apr 26, 2026
ChALkeR
reviewed
Apr 26, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62979 +/- ##
==========================================
+ Coverage 89.66% 89.69% +0.03%
==========================================
Files 706 707 +1
Lines 219391 219950 +559
Branches 42068 42111 +43
==========================================
+ Hits 196712 197280 +568
+ Misses 14578 14567 -11
- Partials 8101 8103 +2
🚀 New features to boost your workflow:
|
ExE-Boss
reviewed
Apr 27, 2026
ChALkeR
reviewed
Apr 27, 2026
ChALkeR
reviewed
Apr 27, 2026
ExE-Boss
reviewed
Apr 27, 2026
Member
Author
|
i'm nearing the end of what i can optimize on the hot paths, just one more fixup then i'll do a final benchmark |
ChALkeR
reviewed
Apr 27, 2026
ChALkeR
reviewed
Apr 27, 2026
ChALkeR
reviewed
Apr 27, 2026
This comment was marked as outdated.
This comment was marked as outdated.
ChALkeR
reviewed
Apr 27, 2026
Member
Author
|
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1842 |
Rework lib/internal/webidl.js into a documented shared converter module that follows the Web IDL conversion algorithms more closely. Improvements: - Add documented converters and helper factories for primitive values, dictionaries, enums, sequences, interfaces, required arguments, integers, `Uint8Array`, and `BufferSource`. - Move WebCrypto onto the shared converters, while keeping compatibility wrappers for its existing `BufferSource` and `BigInteger` behavior. - Use shared converters from Blob, Performance, Web Locks, and structured clone option handling. - Add benchmarks for `ConvertToInt` and WebCrypto Web IDL converter hot paths. - Add focused tests for core converters, WebCrypto converters, integer conversion, and buffer source behavior. Fixes: - Make the shared `BufferSource` and `Uint8Array` converters reject resizable `ArrayBuffer` and growable `SharedArrayBuffer` backing stores unless explicitly allowed. WebCrypto preserves its legacy resizable backing-store behavior through compatibility wrappers until a semver-major follow-up can opt in to the stricter behavior. - Use Web IDL `ToNumber` and `ToString` behavior for BigInt, Symbol, and object primitive conversion. - Use exact BigInt modulo for 64-bit `ConvertToInt` wrapping and document the final Number approximation behavior. - Normalize mathematical modulo results to `+0` where Web IDL requires it. - Process inherited dictionaries in least-derived to most-derived order, sorting members only within each dictionary level. - Use `IteratorComplete` truthiness for sequence conversion. - Cover detached buffers, resizable-backed views, growable-backed views, cross-realm buffer sources, mutation-after-call behavior, inherited dictionary member order, and sequence iterator completion behavior. Signed-off-by: Filip Skokan <[email protected]>
Member
Author
|
(just a rebase, no changes) |
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.
Rework lib/internal/webidl.js into a documented shared converter module that follows the Web IDL conversion algorithms more closely.
Improvements:
Uint8Array, andBufferSource.BufferSourceandBigIntegerbehavior.ConvertToIntand WebCrypto Web IDL converter hot paths.Fixes:
BufferSourceandUint8Arrayconverters reject resizableArrayBufferand growableSharedArrayBufferbacking stores unless explicitly allowed. WebCrypto preserves its legacy resizable backing-store behavior through compatibility wrappers until a semver-major follow-up can opt in to the stricter behavior.ToNumberandToStringbehavior for BigInt, Symbol, and object primitive conversion.ConvertToIntwrapping and document the final Number approximation behavior.+0where Web IDL requires it.IteratorCompletetruthiness for sequence conversion.Benchmark(s)
lib: refactor internal webidl converters #62979 (comment)