简体   繁体   English

Emscripten似乎不使用asm.js

[英]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;" 我在emscripten文档中读到emscripten默认编译为asm.js优化,但如果我打开编译代码,我找不到任何“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. 目前我正在使用“emcc main.c -o out.html”进行编译,也尝试使用-02标志。

This is by design. 这是设计的。 Sometimes it generates (see the source code ) "almost asm" instead of "use asm" , which disables all asm.js optimizations. 有时它会生成(参见源代码"almost asm"而不是"use asm" ,这会禁用所有asm.js优化。 This happens when compiled code uses some features (like this v8 issue ) that are not implemented in browsers. 当编译的代码使用某些未在浏览器中实现的功能( 如此v8问题 )时会发生这种情况。 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. 对于我现在正在进行的项目,我已经将"almost asm"替换为Firefox的"use asm" ,并将其保留为Chrome,因为"use asm"在开始时导致严重减速。

So, it's not safe to just replace "almost asm" with "use asm" but sometimes this works ok. 因此,用"use asm"替换"almost asm"不安全的,但有时候这样做可行。 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. 您应该在所有浏览器版本中仔细测试您的应用程序(但确保您使用关闭的devtools进行测试)您必须支持 - 如果它有效,这意味着您有一个已经实现的幸运案例:继续并替换。

Not the best solution, but I replaced the "almost asm" with "use asm" and it worked with Firefox (was correctly compiled and measurable faster). 不是最好的解决方案,但我用“使用asm”取代了“几乎asm”,它与Firefox一起使用(正确编译并可以更快地测量)。

I also searched long for a solution to get Emscripten to do that itself, but didn't found a solution. 我还寻找一个解决办法,让Emscripten自己做,但没有找到解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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