Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --remove-uncalled-funcs #127

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

BobVarioa
Copy link
Contributor

@BobVarioa BobVarioa commented Jul 11, 2024

Fixes most of #85. Not enabled by default but is a relatively safe optimization. It might break some indirects? (if they don't use funcRef somehow)

Example:

$ ./porf -e "console.log(1)" -b --no-run
wasm size: 39234 bytes
$ ./porf -e "console.log(1)" -b --no-run --remove-uncalled-funcs
wasm size: 27428 bytes
$ ./porf -e "console.log(1)" -b --no-run --remove-uncalled-funcs --uncalled-funcs-runs=5
wasm size: 22441 bytes

Some other examples for comparision:

$ ./porf -e "Porffor.miniLog(1)" -b --no-run 
wasm size: 23326 bytes
$ ./porf -e "Porffor.miniLog(1)" -b --no-run --remove-uncalled-funcs
wasm size: 15604 bytes
$ ./porf -e "Porffor.miniLog(1)" -b --no-run --remove-uncalled-funcs --uncalled-funcs-runs=5
wasm size: 11970 bytes
$ # and our obvious winner:
$ ./porf -e "Porffor.numberLog(1)" -b --no-run
wasm size: 115 bytes

A 30% wasm size reduction for console.log 🎉 (and potentially up to 42% 👀)

Copy link
Owner

@CanadaHonk CanadaHonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP/partial review as doing some internal changes which will affect this soon(tm)

compiler/codegen.js Outdated Show resolved Hide resolved
compiler/codegen.js Outdated Show resolved Hide resolved
compiler/codegen.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants