Repository navigation
Commit d76a67c
committed
Automate JS-to-JS library dependencies using Acorn
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). Also log auto-detected dependencies in debug/verbose
mode (`-sVERBOSE`).
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)
See: #190981 parent 8fed59e commit d76a67c
17 files changed
Lines changed: 306 additions & 200 deletions
File tree
- site/source/docs/porting/connecting_cpp_and_javascript
- src
- lib
- test
- codesize
- jslib
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
| |||
| 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