This repository has been archived by the owner. It is now read-only.
Eliminate unused functions in your WASM binary
Clone or download
Sven SAULEAU
Sven SAULEAU Update README.md
Latest commit fa1651b Feb 26, 2018
Permalink
Failed to load latest commit information.
src fix: remove console logs Feb 19, 2018
test chore: bump webassembly-interpreter Feb 15, 2018
.gitignore feat: initial commit Feb 10, 2018
.travis.yml feat: ref counting Feb 11, 2018
ALGORITHMS.md docs: fix ALGORITHMS Feb 15, 2018
README.md Update README.md Feb 26, 2018
package-lock.json 1.0.2 Feb 20, 2018
package.json 1.0.2 Feb 20, 2018

README.md

This repo has been moved

See https://github.com/xtuc/js-webassembly-interpreter/tree/master/packages/dce.

wasm-dce

Eliminate unused functions in your WASM binary.

Features

  • Removes the export instruction
  • Replaces the func with an empty one (to preserve the index)

Example

(module
-   (func $func_1 (param i32) (param i32) (result i32)
-     (get_local 0)
-     (get_local 1)
-     (i32.add)
-   )
-   (export "add" (func $func_1))
+   (func)
)

FAQ

Why not use binaryen?

First you can see the JavaScript API is specified here https://github.com/WebAssembly/binaryen/wiki/binaryen.js-API.

I encounter some issues (like removing the func wasn't working) and added an additional parse of the WASM file.

Third party licenses

TODO

  • Support DCE for exported global, memory, table.
  • Remove elements only used by this function (other imports, data, etc).
  • Add CLI for node projects or libs