Repository navigation
Commit 23ed469
authored
Automate JS-to-JS library dependencies using Acorn (#27995)
Replace `addImplicitDeps` and `checkDependencies` in `src/jsifier.mjs`
with `calculateDeps`, which uses `acorn.tokenizer` to automatically
detect references to JS library symbols (`$foo` and `_bar`).
Keep the `__deps` mechanism in place for dependencies that static JS
token scanning cannot detect (such as native Wasm/C symbols, function
callbacks in `__deps`, side-effect-only dependencies, and `__postset`
dependencies).
For system libraries we emit a warning when a `__deps` entry is
redundant with an auto-detected dependency. For user JS libraries we
only show this warning in `-sSTRICT` mode.
Performance cost (median of 15 runs on `test/hello_world.c`):
- `tools/compiler.mjs` (`INCLUDE_FULL_LIBRARY=0`): 178.8 ms -> 185.1 ms
(+6.3 ms, +3.5% slower)
- `tools/compiler.mjs` (`INCLUDE_FULL_LIBRARY=1`): 268.2 ms -> 343.1 ms
(+74.9 ms, +27.9% slower)
- `tools/compiler.mjs --symbols-only`: 181.4 ms -> 254.2 ms (+72.8 ms,
+40.1% slower)
- Full `emcc` link (`hello.o` -> `out.js`, cold JS cache):
- `INCLUDE_FULL_LIBRARY=0`: 661.7 ms -> 740.8 ms (+79.1 ms, +12.0%)
- `INCLUDE_FULL_LIBRARY=1`: 758.3 ms -> 906.0 ms (+147.7 ms, +19.5%)
- Full `emcc` link (`hello.o` -> `out.js`, warm JS cache):
- `INCLUDE_FULL_LIBRARY=0`: 271.8 ms (+0.0 ms, 0% slower)
- `INCLUDE_FULL_LIBRARY=1`: 282.4 ms (+0.0 ms, 0% slower)
Because I'm landing a few cleanup first (#27999, #28059, #28060) there
are zero codesize changes acossiated with this PR.
Fixes: #190981 parent c7391e8 commit 23ed469
84 files changed
Lines changed: 456 additions & 1859 deletions
File tree
- site/source/docs/porting/connecting_cpp_and_javascript
- src
- lib
- test
- benchmark
- core
- embind
- jslib
- minimal_webgl
- other
- pthread
- tools
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
597 | 596 | | |
598 | 597 | | |
599 | 598 | | |
| |||
0 commit comments