如何抑制 asm.js 编译信息?

How to suppress asm.js compilation message?

使用 asm.js 代码时,一些浏览器会发出编译消息。这个:

Successfully compiled asm.js code (loaded from cache in 201ms)

有没有办法抑制这条消息?

消息本身在这里:https://hg.mozilla.org/mozilla-central/file/tip/js/src/js.msg#l357

MSG_DEF(JSMSG_USE_ASM_TYPE_OK, 1, JSEXN_WARN, "Successfully compiled asm.js code ({0})")

并在此处发出:https://hg.mozilla.org/mozilla-central/file/tip/js/src/wasm/AsmJS.cpp#l8718

static bool
SuccessfulValidation(AsmJSParser& parser, UniqueChars str)
{
    return parser.warningNoOffset(JSMSG_USE_ASM_TYPE_OK, str.get());
}

这里调用的是:https://hg.mozilla.org/mozilla-central/file/tip/js/src/wasm/AsmJS.cpp#l8877

    // Success! Write to the console with a "warning" message.
    *validated = true;
    SuccessfulValidation(parser, Move(message));
    return NoExceptionPending(cx);
}

在那一行中没有明显的 "optionality",甚至评论说它会转到控制台,期间。

否则 JSEXN_WARN 只有几次真实出现(在 jsexn.h, jsexn.cpp and in jsapi.h), the latter one descibes it as it is practically an exception type which does not break execution and does not have a scary part ("Error:..."): https://hg.mozilla.org/mozilla-central/file/tip/js/src/jsapi.h#l580

* JSEXN_WARN is used for warnings in js.msg files (for instance because we
* don't want to prepend 'Error:' to warning messages). This value can go away
* if we ever decide to use an entirely separate mechanism for warnings.

的确如此,大多数 JSEXN_WARN 的检查都是关于跳过实际异常的抛出,以 if ( ... || exnType == JSEXN_WARN || ... ) do nothing 的方式,比如 here(只有一个,临时的例如)。

我不确定你真正需要什么,但是

How to supress asm.js compilation message?

通过构建您自己的 Firefox 副本:https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Firefox_build