Commit 18593b7
src: refactor embedded entrypoint loading
This patch:
1. Refactor the routines used to compile and run an embedder
entrypoint. In JS land special handling for SEA is done
directly in main/embedding.js instead of clobbering the CJS
loader. Add warnings to remind users that currently the
require() in SEA bundled scripts only supports loading builtins.
2. Don't use the bundled SEA code cache when compiling CJS
loaded from disk, since in that case we are certainly not
compiling the code bundled into the SEA. Use a is_sea_main
flag in CompileFunctionForCJSLoader() (which replaces an unused
argument) to pass this into the C++ land - the code cache is
still read directly from C++ to avoid the overhead of
ArrayBuffer creation.
3. Move SEA loading code into
MaybeLoadSingleExecutableApplication() which calls
LoadEnvironment() with its own StartExecutionCallback().
This avoids more hidden switches in StartExecution() and
make them explicit. Also add some TODOs about how to support
ESM in embedded applications.
4. Add more comments
PR-URL: #53573
Backport-PR-URL: #56927
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Refs: #526971 parent 533afe8 commit 18593b7Copy full SHA for 18593b7
File tree
Expand file treeCollapse file tree
11 files changed
+208
-128
lines changedOpen diff view settings
Filter options
- lib/internal
- main
- modules
- cjs
- esm
- util
- src
- test/fixtures
Expand file treeCollapse file tree
11 files changed
+208
-128
lines changedOpen diff view settings
Collapse file
lib/internal/main/check_syntax.js
Copy file name to clipboardExpand all lines: lib/internal/main/check_syntax.js+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
75 | 75 | |
76 | 76 | |
77 | 77 | |
78 | | - |
| 78 | + |
79 | 79 | |
Collapse file
lib/internal/main/embedding.js
Copy file name to clipboard+103-2Lines changed: 103 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
2 | 12 | |
3 | 13 | |
4 | 14 | |
5 | | - |
| 15 | + |
6 | 16 | |
7 | | - |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
8 | 26 | |
| 27 | + |
| 28 | + |
| 29 | + |
9 | 30 | |
10 | 31 | |
| 32 | + |
11 | 33 | |
12 | 34 | |
13 | 35 | |
14 | 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 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
15 | 116 | |
Collapse file
lib/internal/modules/cjs/loader.js
Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js+4-13Lines changed: 4 additions & 13 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1350 | 1350 | |
1351 | 1351 | |
1352 | 1352 | |
1353 | | - |
1354 | | - |
| 1353 | + |
1355 | 1354 | |
1356 | 1355 | |
1357 | | - |
| 1356 | + |
1358 | 1357 | |
1359 | 1358 | |
1360 | 1359 | |
| ||
1385 | 1384 | |
1386 | 1385 | |
1387 | 1386 | |
1388 | | - |
1389 | 1387 | |
1390 | | - |
1391 | | - |
1392 | | - |
1393 | | - |
1394 | | - |
1395 | | - |
1396 | | - |
1397 | | - |
| 1388 | + |
1398 | 1389 | |
1399 | 1390 | |
1400 | 1391 | |
| ||
1423 | 1414 | |
1424 | 1415 | |
1425 | 1416 | |
1426 | | - |
| 1417 | + |
1427 | 1418 | |
1428 | 1419 | |
1429 | 1420 | |
|
Collapse file
lib/internal/modules/esm/translators.js
Copy file name to clipboardExpand all lines: lib/internal/modules/esm/translators.js+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
176 | 176 | |
177 | 177 | |
178 | 178 | |
179 | | - |
| 179 | + |
180 | 180 | |
181 | 181 | |
182 | 182 | |
|
Collapse file
lib/internal/util/embedding.js
Copy file name to clipboardExpand all lines: lib/internal/util/embedding.js-51Lines changed: 0 additions & 51 deletions
This file was deleted.
Collapse file
+8Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
308 | 308 | |
309 | 309 | |
310 | 310 | |
| 311 | + |
| 312 | + |
| 313 | + |
| 314 | + |
| 315 | + |
| 316 | + |
| 317 | + |
| 318 | + |
311 | 319 | |
312 | 320 | |
313 | 321 | |
|
Collapse file
+34-21Lines changed: 34 additions & 21 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1441 | 1441 | |
1442 | 1442 | |
1443 | 1443 | |
1444 | | - |
1445 | | - |
1446 | | - |
1447 | | - |
1448 | | - |
1449 | | - |
| 1444 | + |
| 1445 | + |
| 1446 | + |
| 1447 | + |
| 1448 | + |
| 1449 | + |
| 1450 | + |
| 1451 | + |
| 1452 | + |
| 1453 | + |
| 1454 | + |
1450 | 1455 | |
1451 | 1456 | |
1452 | 1457 | |
| ||
1464 | 1469 | |
1465 | 1470 | |
1466 | 1471 | |
1467 | | - |
1468 | 1472 | |
1469 | | - |
1470 | | - |
1471 | | - |
1472 | | - |
1473 | | - |
1474 | | - |
1475 | | - |
1476 | | - |
1477 | | - |
1478 | | - |
1479 | | - |
1480 | | - |
1481 | 1473 | |
1482 | 1474 | |
1483 | 1475 | |
| ||
1532 | 1524 | |
1533 | 1525 | |
1534 | 1526 | |
| 1527 | + |
1535 | 1528 | |
1536 | 1529 | |
1537 | 1530 | |
| ||
1544 | 1537 | |
1545 | 1538 | |
1546 | 1539 | |
| 1540 | + |
| 1541 | + |
| 1542 | + |
| 1543 | + |
| 1544 | + |
| 1545 | + |
| 1546 | + |
| 1547 | + |
| 1548 | + |
| 1549 | + |
| 1550 | + |
| 1551 | + |
| 1552 | + |
| 1553 | + |
| 1554 | + |
| 1555 | + |
| 1556 | + |
| 1557 | + |
| 1558 | + |
| 1559 | + |
1547 | 1560 | |
1548 | 1561 | |
1549 | 1562 | |
1550 | 1563 | |
1551 | | - |
| 1564 | + |
1552 | 1565 | |
1553 | 1566 | |
1554 | 1567 | |
| ||
1703 | 1716 | |
1704 | 1717 | |
1705 | 1718 | |
1706 | | - |
| 1719 | + |
1707 | 1720 | |
1708 | 1721 | |
1709 | 1722 | |
|
Collapse file
+1-14Lines changed: 1 addition & 14 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
103 | 103 | |
104 | 104 | |
105 | 105 | |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
| 106 | + |
120 | 107 | |
121 | 108 | |
122 | 109 | |
|
0 commit comments