![](/img/trans.png)
[英]Is there a clever way to check from code whether asm.js is active or not?
[英]How can I check if Firefox uses asm.js code?
那么如何通過例如Google的V8引擎檢查它是否像普通的Javascript一樣執行,或者使用程序集以近原生性能執行?
如果您只是查看控制台,Firefox會告訴您asm.js是否已經過驗證。 在上面粘貼的腳本的情況下,我得到:
TypeError: asm.js type error: non-expression-statement call must be coerced test.html:23
這表明沒有。 在這種情況下,第23行是:
return +sqrt(square(x) + square(y));
如果我用這個代替那行:
return +sqrt(+square(x) + +square(y));
然后錯誤控制台說:
Error: successfully compiled asm.js code (total compilation time 0ms)
這意味着它一切正常(而且“錯誤”只是在這種情況下JS引擎如何報告成功的一個虛假怪癖;我提交了https://bugzilla.mozilla.org/show_bug.cgi?id=950527以獲取固定的)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.