![](/img/trans.png)
[英]Is there a clever way to check from code whether asm.js is active or not?
[英]Is there a way to validate asm.js code
我希望在Firefox Nightly中發現編譯消息,但不會發生。 為此有特殊的開關嗎?
沒有測試過,但似乎有一個驗證器在這里 。
快速瀏覽測試提示它可以按以下方式使用:
var asm = require('asm.js');
try {
report = asm.validate(String(function f(stdlib, foreign, heap) {
"use asm";
// this is what we're validating
function f() {
var x = 0, y = 0;
x = ((x|0)%(y|0))|0;
}
return {};
}));
console.log('Validated!');
} catch(e) {
console.error(e);
}
您可以在Web控制台中檢查它是否可以編譯:給定一個模塊中帶有“ use asm”的頁面,它應該提供:
Error: successfully compiled asm.js code (total compilation time 0ms)
或者是有關為何無法編譯為asm的實際錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.