Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.
/ wasm-dce Public archive

Eliminate unused functions in your WASM binary

Notifications You must be signed in to change notification settings

xtuc/wasm-dce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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