├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ └── main.yml ├── .gitignore ├── .rustfmt.toml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── _travis.yml ├── analyze ├── Cargo.toml ├── analyses │ ├── diff.rs │ ├── dominators │ │ ├── emit.rs │ │ └── mod.rs │ ├── garbage.rs │ ├── mod.rs │ ├── monos │ │ ├── emit.rs │ │ ├── entry.rs │ │ └── mod.rs │ ├── paths │ │ ├── mod.rs │ │ ├── paths_emit.rs │ │ └── paths_entry.rs │ └── top.rs ├── analyze.rs └── formats │ ├── json.rs │ ├── mod.rs │ └── table.rs ├── guide ├── book.toml └── src │ ├── SUMMARY.md │ ├── chapter_1.md │ ├── concepts │ ├── call-graph.dot │ ├── call-graph.md │ ├── call-graph.svg │ ├── dominator-tree.dot │ ├── dominator-tree.svg │ ├── dominators-and-retained-size.md │ ├── generic-functions-and-monomorphization.md │ ├── index.md │ └── paths.md │ ├── contributing.md │ ├── contributing │ ├── building.md │ ├── code-formatting.md │ ├── code-of-conduct.md │ ├── index.md │ ├── pull-requests.md │ ├── team.md │ └── testing.md │ ├── index.md │ ├── install.md │ ├── supported-binary-formats.md │ ├── theme │ ├── book.js │ ├── css │ │ ├── chrome.css │ │ ├── general.css │ │ ├── print.css │ │ └── variables.css │ ├── favicon.png │ ├── highlight.css │ ├── highlight.js │ └── index.hbs │ ├── twiggy.png │ ├── twiggy.svg │ └── usage │ ├── as-a-crate.md │ ├── command-line-interface │ ├── diff.md │ ├── dominators.md │ ├── garbage.md │ ├── index.md │ ├── monos.md │ ├── paths.md │ └── top.md │ ├── index.md │ └── on-the-web-with-webassembly.md ├── ir ├── Cargo.toml ├── graph_impl.rs └── ir.rs ├── job_runner ├── Cargo.toml └── src │ └── main.rs ├── opt ├── Cargo.toml ├── build.rs ├── definitions.rs └── opt.rs ├── parser ├── Cargo.toml ├── object_parse │ └── mod.rs ├── parser.rs └── wasm_parse │ └── mod.rs ├── publish.sh ├── releases ├── friends.sh └── release-announcement-template.md ├── traits ├── Cargo.toml └── traits.rs ├── twiggy ├── Cargo.toml ├── tests │ └── all │ │ ├── diff_tests.rs │ │ ├── dominators_tests.rs │ │ ├── elf_format_tests.rs │ │ ├── expectations │ │ ├── cpp_monos │ │ ├── diff_test_exact_wee_alloc │ │ ├── diff_test_regex_wee_alloc │ │ ├── diff_wee_alloc │ │ ├── diff_wee_alloc_all │ │ ├── diff_wee_alloc_all_json │ │ ├── diff_wee_alloc_csv │ │ ├── diff_wee_alloc_csv_top_5 │ │ ├── diff_wee_alloc_json │ │ ├── diff_wee_alloc_json_top_5 │ │ ├── diff_wee_alloc_top_5 │ │ ├── dominators_csv_does_not_summarize_garbage_if_all_items_are_reachable │ │ ├── dominators_json_prints_multiple_root_items │ │ ├── dominators_regex_any_func │ │ ├── dominators_summarizes_unreachable_items │ │ ├── dominators_wee_alloc │ │ ├── dominators_wee_alloc_csv │ │ ├── dominators_wee_alloc_json │ │ ├── dominators_wee_alloc_subtree │ │ ├── dominators_wee_alloc_subtree_json │ │ ├── dominators_wee_alloc_with_depth_and_row │ │ ├── elf_dominators │ │ ├── elf_dominators2 │ │ ├── elf_dominators3 │ │ ├── elf_paths │ │ ├── elf_paths2 │ │ ├── elf_top_25_hello_world_rs │ │ ├── elf_top_hello_world_rs │ │ ├── garbage │ │ ├── garbage_json │ │ ├── garbage_top_2 │ │ ├── garbage_top_2_json │ │ ├── garbage_wee_alloc_all │ │ ├── garbage_wee_alloc_all_json │ │ ├── garbage_wee_alloc_show_data_segments │ │ ├── garbage_wee_alloc_show_data_segments_json │ │ ├── garbage_wee_alloc_top_10 │ │ ├── garbage_wee_alloc_top_10_json │ │ ├── garbage_wee_alloc_top_2_show_data_segments │ │ ├── garbage_wee_alloc_top_2_show_data_segments_json │ │ ├── issue_16 │ │ ├── monos │ │ ├── monos_all │ │ ├── monos_all_generics │ │ ├── monos_all_monos │ │ ├── monos_functions │ │ ├── monos_json │ │ ├── monos_maxes │ │ ├── monos_only_all_generics │ │ ├── monos_only_generics │ │ ├── monos_regex │ │ ├── monos_wasm_csv │ │ ├── output_to_file │ │ ├── paths_error_test_no_max_paths │ │ ├── paths_error_test_no_max_paths_csv │ │ ├── paths_error_test_no_max_paths_json │ │ ├── paths_error_test_one_path │ │ ├── paths_error_test_one_path_csv │ │ ├── paths_error_test_one_path_json │ │ ├── paths_test_called_once │ │ ├── paths_test_called_once_csv │ │ ├── paths_test_called_once_json │ │ ├── paths_test_called_twice │ │ ├── paths_test_called_twice_csv │ │ ├── paths_test_called_twice_json │ │ ├── paths_test_default_output │ │ ├── paths_test_default_output_csv │ │ ├── paths_test_default_output_desc │ │ ├── paths_test_default_output_desc_with_depth │ │ ├── paths_test_default_output_json │ │ ├── paths_test_regex_called_any │ │ ├── paths_test_regex_exports │ │ ├── paths_test_regex_exports_desc │ │ ├── paths_wee_alloc │ │ ├── paths_wee_alloc_csv │ │ ├── paths_wee_alloc_json │ │ ├── paths_wee_alloc_with_depth_and_paths │ │ ├── paths_wee_alloc_with_depth_and_paths_csv │ │ ├── paths_wee_alloc_with_depth_and_paths_json │ │ ├── top_2_csv │ │ ├── top_2_csv_retained │ │ ├── top_2_json │ │ ├── top_2_json_retained │ │ ├── top_mappings │ │ ├── top_memory_module │ │ ├── top_mono │ │ ├── top_retained_mappings │ │ ├── top_retained_wee_alloc │ │ └── top_wee_alloc │ │ ├── fixtures │ │ ├── cpp-monos.cpp │ │ ├── cpp-monos.wasm │ │ ├── garbage.wasm │ │ ├── garbage.wat │ │ ├── hello_elf │ │ ├── hello_world.rs │ │ ├── mappings.wasm │ │ ├── memory.wasm │ │ ├── memory.wat │ │ ├── mono.wasm │ │ ├── monos.rs │ │ ├── monos.wasm │ │ ├── paths_test.wasm │ │ ├── paths_test.wat │ │ ├── wee_alloc.2.wasm │ │ └── wee_alloc.wasm │ │ ├── garbage_tests.rs │ │ ├── main.rs │ │ ├── monos_tests.rs │ │ ├── paths_tests.rs │ │ └── top_tests.rs └── twiggy.rs └── wasm-api ├── Cargo.toml └── wasm-api.rs /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 🐛 3 | about: Something not working as expected? 4 | --- 5 | 6 | ## 🐛 Bug Description 7 | 8 | Describe your issue in detail. 9 | 10 | twiggy version: (replace this with the output of `twiggy --version`) 11 | 12 | #### 🌍 Test Case 13 | 14 | Upload the test case and link to it here. For example, a `.wasm` file that 15 | Twiggy fails to parse. 16 | 17 | #### 👟 Steps to Reproduce 18 | 19 | Precise steps describing how to reproduce the issue, including commands and 20 | flags run. For example: 21 | 22 | * Run `twiggy top -n 25 test_case.wasm` 23 | * ... 24 | 25 | #### 😲 Actual Behavior 26 | 27 | What happens after you follow the steps to reproduce? Include console output, 28 | error messages, stack traces, etc. 29 | 30 | #### 🤔 Expected Behavior 31 | 32 | What should have happened instead? 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 💡 3 | about: Suggest a new feature for Twiggy 4 | --- 5 | 6 | ## 💡 Feature Description 7 | 8 | Explanation of the requested feature. What use case does it solve? 9 | 10 | #### 💻 Example Usage 11 | 12 | Include a strawman example of how a user might use this new feature, and what 13 | the output would look like. 14 | 15 | #### 🙌 Are you interested in implementing this feature? 16 | 17 | Add an "X" to one of the following: 18 | 19 | * [ ] Yes 20 | * [ ] Yes if I had a mentor to help me 21 | * [ ] No 22 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: cargo 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "08:00" 8 | open-pull-requests-limit: 10 9 | ignore: 10 | - dependency-name: wasmparser 11 | versions: 12 | - 0.73.0 13 | - 0.73.1 14 | - 0.74.0 15 | - 0.75.0 16 | - 0.76.0 17 | - 0.77.0 18 | - dependency-name: wasm-bindgen 19 | versions: 20 | - 0.2.70 21 | - 0.2.71 22 | - 0.2.72 23 | - dependency-name: regex 24 | versions: 25 | - 1.4.3 26 | - 1.4.4 27 | - 1.4.5 28 | - dependency-name: serde_derive 29 | versions: 30 | - 1.0.123 31 | - 1.0.124 32 | - dependency-name: serde 33 | versions: 34 | - 1.0.123 35 | - 1.0.124 36 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | lints: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v2 17 | - uses: actions-rs/toolchain@v1 18 | with: 19 | toolchain: stable 20 | components: rustfmt, clippy 21 | - uses: actions-rs/cargo@v1 22 | with: 23 | command: fmt 24 | args: --all -- --check 25 | - uses: actions-rs/cargo@v1 26 | with: 27 | command: clippy 28 | test: 29 | strategy: 30 | matrix: 31 | os: ['ubuntu-latest', 'windows-latest', 'macos-latest'] 32 | runs-on: ${{ matrix.os }} 33 | steps: 34 | - uses: actions/checkout@v2 35 | - uses: actions-rs/toolchain@v1 36 | with: 37 | toolchain: stable 38 | - name: Test 39 | run: cargo test --all --exclude twiggy-wasm-api 40 | wasm: 41 | runs-on: ubuntu-latest 42 | steps: 43 | - uses: actions/checkout@v2 44 | - uses: actions-rs/toolchain@v1 45 | with: 46 | toolchain: stable 47 | - name: Run test script with WASM job 48 | run: cargo run --bin job_runner -- --wasm 49 | # docs_deploy: 50 | # runs-on: ubuntu-latest 51 | # needs: test 52 | # steps: 53 | # - name: Checkout 54 | # uses: actions/checkout@v2.3.1 55 | # - name: Build the book 56 | # run: cd guide && mdbook build 57 | # - name: Deploy 58 | # if: github.event_name == 'push' && github.ref == 'refs/heads/main' 59 | # uses: JamesIves/github-pages-deploy-action@4.1.4 60 | # with: 61 | # branch: master 62 | # folder: guide/book 63 | # token: ${{ secrets.GITHUB_TOKEN }} 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | **/*.rs.bk 3 | Cargo.lock 4 | twiggy/tests/all/whatever-output.txt 5 | wasm-api/.crates.toml 6 | wasm-api/bin 7 | twiggy_wasm_api.d.ts 8 | twiggy_wasm_api.js 9 | twiggy_wasm_api.wasm 10 | twiggy_wasm_api_bg.wasm 11 | twiggy_wasm_api_bg.d.ts 12 | guide/book 13 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | # We do not merge derives because of `twiggy-opt` and its build script. 2 | # Merging derives in `opt/definitions` will break the wasm api. 3 | merge_derives = false 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to `twiggy` 2 | 3 | [Read the "Contributing to Twiggy" section of the Twiggy guide!](https://rustwasm.github.io/twiggy/contributing/index.html) 4 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "./analyze", 4 | "./ir", 5 | "./opt", 6 | "./parser", 7 | "./twiggy", 8 | "./traits", 9 | "./wasm-api", 10 | "./job_runner" 11 | ] 12 | 13 | [profile.release] 14 | codegen-units = 1 15 | debug = true 16 | incremental = false 17 | lto = true 18 | opt-level = "s" 19 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 The Rust Project Developers 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |