Repository navigation
Commit 089b4c0
authored
refactor(javascript): make the minifier's nodes plain ESTree objects (#22418)
* refactor(javascript): make the minifier's nodes plain objects from factories
terser's node classes are gone from the minifier: each kind of node, what
terser's class was, has a factory making a plain object with every field
of its ESTree type in one order, so the nodes of a type share one shape.
The `is<Kind>Node` predicates answer on a node's type and the values
telling kinds apart (an Identifier's role, a VariableDeclaration's kind,
a block's or function's role), `kindOf` names a node's kind, and the
kind bits, comparisons and copies read it. A private member's key is
typed PrivateIdentifier.
* refactor(javascript): adopt ESTree without terser's node classes data
The generator no longer reads terser's ast.js: the node kinds the factories
are built from live in the printer, so the generated node-class table and
the code deriving it are gone. The parser's ESTree is adopted by
`ast.adoptEstree`, which a `parse.spidermonkey` input goes through too.
* refactor(javascript): type the minifier nodes' common fields
A node's type, name, kind, role, computed flag, label and property read as
typed fields, and the test helpers type terser's factories and the ast
they read kinds through, so type coverage stays above main's.
Claude-Session: https://claude.ai/code/session_01Tgxgyb4N35ndP6cC4KcrXC
* docs(javascript): describe the minifier's plain nodes and type-keyed functions
Claude-Session: https://claude.ai/code/session_01Tgxgyb4N35ndP6cC4KcrXC
* refactor(javascript): read a node's kind bits by its type and role
Kind bits asked `kindOf` of every visited node once nodes became plain
objects, which doubled compress time; a table by type, then role, answers
almost every node without it, and a kind's factory is named once.
Also drops a stale comment and proves the nested size test's patch runs.
Claude-Session: https://claude.ai/code/session_01Tgxgyb4N35ndP6cC4KcrXC
* refactor(javascript): give scope nodes every field scope analysis writes
Program, functions and classes now carry `screwy_argnames_scope`, and a
static block the whole scope set, from the factory on, so figuring out
scopes no longer moves these nodes to another hidden class.
Claude-Session: https://claude.ai/code/session_01Tgxgyb4N35ndP6cC4KcrXC1 parent e930051 commit 089b4c0
8 files changed
Lines changed: 3467 additions & 4463 deletions
File tree
- docs
- lib/javascript
- test
- helpers
- unitCases
- tooling
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
24 | 33 | | |
25 | 34 | | |
26 | 35 | | |
27 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
28 | 39 | | |
29 | 40 | | |
30 | 41 | | |
| |||
98 | 109 | | |
99 | 110 | | |
100 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
101 | 137 | | |
102 | 138 | | |
103 | 139 | | |
104 | 140 | | |
105 | 141 | | |
106 | 142 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 143 | + | |
| 144 | + | |
111 | 145 | | |
112 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
113 | 163 | | |
114 | 164 | | |
115 | | - | |
| 165 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | | - | |
| 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 | + | |
20 | 59 | | |
21 | | - | |
22 | | - | |
| 60 | + | |
| 61 | + | |
23 | 62 | | |
24 | 63 | | |
25 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
26 | 73 | | |
27 | 74 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
31 | 89 | | |
32 | 90 | | |
33 | 91 | | |
| |||
67 | 125 | | |
68 | 126 | | |
69 | 127 | | |
70 | | - | |
| 128 | + | |
71 | 129 | | |
72 | 130 | | |
73 | 131 | | |
| |||
96 | 154 | | |
97 | 155 | | |
98 | 156 | | |
99 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
100 | 160 | | |
101 | | - | |
| 161 | + | |
102 | 162 | | |
103 | | - | |
| 163 | + | |
104 | 164 | | |
105 | 165 | | |
106 | 166 | | |
| |||
116 | 176 | | |
117 | 177 | | |
118 | 178 | | |
119 | | - | |
| 179 | + | |
120 | 180 | | |
121 | 181 | | |
122 | 182 | | |
123 | | - | |
| 183 | + | |
124 | 184 | | |
125 | 185 | | |
126 | 186 | | |
127 | 187 | | |
128 | 188 | | |
129 | 189 | | |
130 | | - | |
| 190 | + | |
131 | 191 | | |
132 | 192 | | |
133 | 193 | | |
134 | | - | |
| 194 | + | |
135 | 195 | | |
136 | 196 | | |
137 | 197 | | |
| |||
151 | 211 | | |
152 | 212 | | |
153 | 213 | | |
154 | | - | |
| 214 | + | |
155 | 215 | | |
156 | 216 | | |
157 | 217 | | |
| |||
179 | 239 | | |
180 | 240 | | |
181 | 241 | | |
182 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
183 | 246 | | |
184 | 247 | | |
185 | 248 | | |
| |||
429 | 492 | | |
430 | 493 | | |
431 | 494 | | |
432 | | - | |
| 495 | + | |
433 | 496 | | |
434 | 497 | | |
435 | 498 | | |
| |||
0 commit comments