简体   繁体   中英

Emscripten seems to not use asm.js

I've read in emscripten docs that emscripten compiles to asm.js optimisations by default, but if I open compiled code I can't find any "use asm;" how to get it? Should I add it manually or am I compiling wrong?

At the moment I am using "emcc main.c -o out.html" to compile, also tried with -02 flag.

This is by design. Sometimes it generates (see the source code ) "almost asm" instead of "use asm" , which disables all asm.js optimizations. This happens when compiled code uses some features (like this v8 issue ) that are not implemented in browsers. For the project I'm working on now, I have replaced "almost asm" with "use asm" for Firefox and left it as is for Chrome because "use asm" caused heavy slowdown at start.

So, it's not safe to just replace "almost asm" with "use asm" but sometimes this works ok. You should carefully test your app in all browser versions (but make sure you are testing with devtools turned off) you have to support - and if it works, this means that you have a lucky case that is already implemented: go ahead and replace.

Not the best solution, but I replaced the "almost asm" with "use asm" and it worked with Firefox (was correctly compiled and measurable faster).

I also searched long for a solution to get Emscripten to do that itself, but didn't found a solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM