Skip to content

Minor optimizer simplification opportunity #4367

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

Closed
aidanhs opened this issue May 28, 2016 · 5 comments
Closed

Minor optimizer simplification opportunity #4367

aidanhs opened this issue May 28, 2016 · 5 comments

Comments

@aidanhs
Copy link
Contributor

aidanhs commented May 28, 2016

kripken/cashew@f729e38#diff-3

The 'true' appears to be inherited from the uglifyjs 1 parser where it could be replaced by one of ['+', '-', '/', '*', ...] to represent the corresponding assignment operators. I don't see any of these complex operators in the asm.js spec - http://asmjs.org/spec/latest/

Two questions:

  1. Am I correct in saying that those assignment operators aren't used in asm.js?
  2. Is it desirable to remain compatible with the uglifyjs parser? (fair enough if so)
@kripken
Copy link
Member

kripken commented May 30, 2016

Yes, the true is for that. And yes, asm.js doesn't have those assign+operation things, and asm.js is almost certainly not going to be updated. So in theory we could optimize this away.

However, there is still some chance we'll want that functionality, and it's probably not a big difference in overhead, so I think it's not worth doing.

If you are looking for optimizer optimization opportunities, I suggest focusing on the binaryen optimizer. It should be much faster than the asm.js optimizer since it has a much nicer IR to operate on - in particular, it doesn't have any quirks like this uglify issue here. If we can get it fast enough, and we can write an efficient wasm2asm pass, then we could deprecate the asm.js optimizer, in fact - although both of those ifs are still open questions.

Right now I am still adding optimizations to it, but there is already a lot of data-structure type optimization that could be done (set vs unordered_set vs vector, etc.) on what already exists.

@aidanhs
Copy link
Contributor Author

aidanhs commented May 30, 2016

Cool, thanks for the confirmation.

I stumbled across it mainly because I'm reimplementing the emscripten optimizer in rust. Parsing code porting is complete and the in-memory representation seems to be 1/3 of the size.

After that's done, I'll probably also implement the binaryen optimizer in rust and keep track pace with the changes you make.

@aidanhs aidanhs closed this as completed May 30, 2016
@kripken
Copy link
Member

kripken commented May 30, 2016

Oh, very interesting about the rust reimplementations! Is there a repo I can follow?

@aidanhs
Copy link
Contributor Author

aidanhs commented Jun 1, 2016

https://github.com/aidanhs/ayzim - the general code organisation should be pretty familiar ;)

You won't be able to build it without servo/string-cache#136 and it only parses JS/JSON+emits JSON so far, but in terms of LOC % it's probably about halfway there.

@kripken
Copy link
Member

kripken commented Jun 1, 2016

Cool, thanks.

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

No branches or pull requests

2 participants