有没有一种方法可以验证asm.js代码

Is there a way to validate asm.js code

本文关键字:验证 asm js 代码 方法 一种 有没有      更新时间:2024-05-22

我希望在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的实际错误。