srijs / rusha

High-performance pure-javascript SHA1 implementation suitable for large binary data, reaching up to half the native speed.
https://npmjs.org/rusha
MIT License
277 stars 32 forks source link

uglify-js compressor breaks asm.js validity #27

Closed feross closed 8 years ago

feross commented 9 years ago

I'm getting this warning in the console when using Rusha in Firefox:

"TypeError: asm.js type error: expecting argument type declaration for 'e' of the form 'arg = arg|0' or 'arg = +arg' or 'arg = fround(arg)'"

You can see it in action here: https://instant.io/

srijs commented 9 years ago

The problem is the way your uglify/browserify pipeline works, it rewrites e=e|0 to e|=0, and only the former is valid asm.js. There is probably an option to turn this kind of rewriting off.

Actually, since I'm also using uglify-js for rusha.min.js, I just checked and the same problem surfaced. So I'm now actively looking for a solution.

feross commented 9 years ago

Ah, thanks for looking into this.

srijs commented 9 years ago

There is an old issue in UglifyJS which describes exactly this problem, and apparently it was not solved. The workaround for now is to turn compression off when invoking uglify-js (see https://github.com/srijs/rusha/commit/4255836fca74e95018c8cc1d2b9bede499dd6c35).

Note that the "warning" you are seeing is just a warning (does not break functionality), but degrades performance b/c FF is not able to optimise the code.