Cool. I recently wrote a low-level sha1 implementation in pure javascript, trying to leverage asm.js (http://github.com/srijs/rusha).
Can you tell me, how did you confirm you wrote valid asm.js and there was no fallback-mechanism kicking in?
I benchmarked my implementation, of course, and noticed a 2x speedup. However, this seems quite less for the this type of low-level algorithm...
Re:Compiling LLJS to asm.js
by abecedarius on Monday March 25, 2013 @04:54PM
(#5439620)
Open the error console (via the Web Developer menu item) and you'll see messages there. Success shows up as "Error: successfully compiled asm.js code." :-)
P.S. Looking at your code, I can tell it's not asm.js conformant yet, though it should just be a bunch of small tweaks (e.g. an expression like (a+b) will need to be (a+b)|0, etc.).
Thank you. I just updated my code and it's really within half of native speed now... (benchmarks in the README, if any of you are interested)
asm.js is very exciting technology!
Re:Compiling LLJS to asm.js
by abecedarius on Monday March 25, 2013 @08:33PM
(#5440648)
You're welcome!
Re:Compiling LLJS to asm.js
by simcop2387 on Monday March 25, 2013 @03:01PM
(#5438929)
Doesn't appear to be doing anything for me,
noasm 285
asm 13
asm 13
noasm 269
That's all that appears in the console. Network and everything looks fine, no 404 or other errors.
Re:Compiling LLJS to asm.js
by abecedarius on Monday March 25, 2013 @03:20PM
(#5439064)
Yes, I disabled display so that wouldn't get into the benchmark. The numbers are times in milliseconds.
I wonder if most / all of that speedup is just using typed arrays (edit: nvm, they both do). I get similar speeds in Chrome, which afaik doesn't have any special handling for `"use asm";` functions.
Typed arrays do deliver a lot of speedup, and in fact, the above example is slightly faster in Chrome than in Firefox Nightly for me. However, if your algorithm does crunch a lot of data in a low-level way, there is definitely even more performance you can get by using asm.js.
See my link in the comment below for benchmarks of a sha1 algorithm that shows a good speedup in Chrome by using TypedArrays, but an even greater one in OdinMonkey.
awesome - thanks for doing the legwork! I'll definitely take a look.
Code at http://wry.me/hacking/canvas_asm.html