Commit ef08c50
lib: refactor internal webidl converters
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 <panva.ip@gmail.com>
PR-URL: #62979
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>1 parent 6386914 commit ef08c50Copy full SHA for ef08c50
18 files changed
+2,813-1,063Lines changed: 2813 additions & 1063 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- benchmark/misc
- lib/internal
- crypto
- perf
- worker
- test
- fixtures/webcrypto
- parallel
Expand file treeCollapse file tree
Open diff view settings
Collapse file
benchmark/misc/webcrypto-webidl.js
Copy file name to clipboard+109Lines changed: 109 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
Collapse file
benchmark/misc/webidl-convert-to-int.js
Copy file name to clipboard+82Lines changed: 82 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
Collapse file
+8-5Lines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
54 | 54 | |
55 | 55 | |
56 | 56 | |
57 | | - |
58 | 57 | |
59 | 58 | |
60 | 59 | |
| ||
245 | 244 | |
246 | 245 | |
247 | 246 | |
248 | | - |
249 | | - |
250 | | - |
251 | | - |
| 247 | + |
| 248 | + |
| 249 | + |
| 250 | + |
| 251 | + |
| 252 | + |
| 253 | + |
| 254 | + |
252 | 255 | |
253 | 256 | |
254 | 257 | |
|
0 commit comments