Commit 3e57b93
authored
src: compile code eagerly in snapshot builder
By default V8 only compiles the top-level function and
skips code generation for inner functions - that would
only be done when those inner functions are invoked.
Since builtins are compiled as wrapped functions, most
functions that look visually top-level are not actually
included in the built-in code cache. For most of the
builtins this is not too bad because usually only a subset of
all builtin functions are needed by a particular
application and including all their code in the binary
would incur an unnecessary size overhead. But there is also
a subset of more commonly used builtins and it would be
better to include the inner functions in the built-in
code cache because they are more universally used by
most applications.
This patch changes the compilation strategy to eager compilation
(including inner functions) for the following scripts:
1. Primordials (internal/per_context/*), in all situations.
2. Bootstrap scripts (internal/bootstrap/*) and main scripts
(internal/main/*), when being compiled for built-in code
cache.
3. Any scripts loaded during built-in snapshot generation.
We can't compile the code eagerly during snapshot generation
and include them into the V8 snapshot itself just now because
we need to start the inspector before context deserialization
for coverage collection to work. So leave that as a TODO.
With this patch the binary size increases by about 666KB
(~0.6% increase) in return the worker startup can be 18-19% faster.
PR-URL: #51672
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>1 parent 7851af0 commit 3e57b93
File tree
5 files changed
+75
-15
lines changed- src
- api
5 files changed
+75
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
802 | 802 | | |
803 | 803 | | |
804 | 804 | | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
805 | 808 | | |
806 | 809 | | |
807 | 810 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
827 | 827 | | |
828 | 828 | | |
829 | 829 | | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
830 | 839 | | |
831 | 840 | | |
832 | 841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
289 | 296 | | |
290 | 297 | | |
291 | 298 | | |
292 | 299 | | |
293 | 300 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
298 | 307 | | |
299 | 308 | | |
300 | 309 | | |
| |||
481 | 490 | | |
482 | 491 | | |
483 | 492 | | |
484 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
485 | 497 | | |
486 | 498 | | |
487 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
488 | 506 | | |
489 | 507 | | |
| 508 | + | |
490 | 509 | | |
491 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
492 | 520 | | |
493 | 521 | | |
494 | 522 | | |
| |||
503 | 531 | | |
504 | 532 | | |
505 | 533 | | |
506 | | - | |
507 | | - | |
508 | 534 | | |
509 | | - | |
510 | 535 | | |
511 | 536 | | |
512 | 537 | | |
513 | 538 | | |
| 539 | + | |
514 | 540 | | |
515 | 541 | | |
516 | 542 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
116 | 119 | | |
117 | | - | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
| |||
126 | 132 | | |
127 | 133 | | |
128 | 134 | | |
129 | | - | |
130 | | - | |
131 | 135 | | |
132 | 136 | | |
133 | 137 | | |
| |||
179 | 183 | | |
180 | 184 | | |
181 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
182 | 198 | | |
183 | 199 | | |
184 | 200 | | |
| |||
188 | 204 | | |
189 | 205 | | |
190 | 206 | | |
| 207 | + | |
191 | 208 | | |
192 | 209 | | |
193 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1041 | 1041 | | |
1042 | 1042 | | |
1043 | 1043 | | |
1044 | | - | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
1045 | 1048 | | |
1046 | 1049 | | |
1047 | | - | |
1048 | 1050 | | |
1049 | 1051 | | |
1050 | 1052 | | |
| |||
1070 | 1072 | | |
1071 | 1073 | | |
1072 | 1074 | | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
1073 | 1078 | | |
1074 | 1079 | | |
1075 | 1080 | | |
| |||
0 commit comments