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

Remove unused type checks #120

Merged
merged 14 commits into from
Jul 10, 2024
Merged

Conversation

BobVarioa
Copy link
Contributor

@BobVarioa BobVarioa commented Jul 9, 2024

Fixes #86.

Before:

$ ./porf -e "console.log(1)" -b --no-run
wasm size: 46019 bytes

After:

$ ./porf -e "console.log(1)" -b --no-run
wasm size: 37735 bytes

For comparison:

$ ./porf -e "Porffor.miniLog(1)" -b --no-run
wasm size: 23539 bytes
$ ./porf -e "Porffor.numberLog(1)" -b --no-run
wasm size: 115 bytes

So by no means magic, but a roughly 20% size reduction for a very common method. Likely could be optimized further via #64 and #119.

This PR also adds __Porffor_printArray to reduce some of the code duplication in console.log

compiler/opt.js Show resolved Hide resolved
compiler/codegen.js Outdated Show resolved Hide resolved
compiler/codegen.js Outdated Show resolved Hide resolved
compiler/codegen.js Show resolved Hide resolved
compiler/builtins/console.ts Show resolved Hide resolved
compiler/builtins/console.ts Outdated Show resolved Hide resolved
compiler/builtins/console.ts Show resolved Hide resolved
compiler/opt.js Outdated Show resolved Hide resolved
compiler/codegen.js Show resolved Hide resolved
@BobVarioa BobVarioa requested a review from CanadaHonk July 9, 2024 23:10
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.

Looks good, thanks!

@CanadaHonk
Copy link
Owner

Could you fix the merge conflicts? Sorry 😓

@BobVarioa
Copy link
Contributor Author

Could you fix the merge conflicts? Sorry 😓

image
I might be wrong but it doesn't have any?

@CanadaHonk
Copy link
Owner

Oh nvm I can merge but not rebase 🫡

@CanadaHonk CanadaHonk merged commit 14b249a into CanadaHonk:main Jul 10, 2024
@BobVarioa BobVarioa deleted the opt-unused-types branch July 10, 2024 01:05
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.

Optimize away unused types for console.log/etc
2 participants