Bug 1965518 - wasm: Rename wasm_verbose to wasm_trace_api and support MOZ_LOG. r=bvisness
Add a MOZ_LOG=wasmApi logging module that re-uses our existing wasm::Log infrastructure. This lets us see wasm JS-API usage in the profiler through markers, and also in the normal browser log stream. Rename wasm_verbose to wasmTraceApi to match the log module. Use the JS::Pref system instead of context options. Differential Revision: https://phabricator.services.mozilla.com/D248641
This commit is contained in:
committed by
rhunt@eqrion.net
parent
80081e16cf
commit
8d39059edb
@@ -24,7 +24,6 @@ class JS_PUBLIC_API ContextOptions {
|
||||
ContextOptions()
|
||||
: wasm_(true),
|
||||
wasmForTrustedPrinciples_(true),
|
||||
wasmVerbose_(false),
|
||||
wasmBaseline_(true),
|
||||
wasmIon_(true),
|
||||
testWasmAwaitTier2_(false),
|
||||
@@ -67,12 +66,6 @@ class JS_PUBLIC_API ContextOptions {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool wasmVerbose() const { return wasmVerbose_; }
|
||||
ContextOptions& setWasmVerbose(bool flag) {
|
||||
wasmVerbose_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool wasmBaseline() const { return wasmBaseline_; }
|
||||
ContextOptions& setWasmBaseline(bool flag) {
|
||||
wasmBaseline_ = flag;
|
||||
@@ -179,7 +172,6 @@ class JS_PUBLIC_API ContextOptions {
|
||||
// WASM options.
|
||||
bool wasm_ : 1;
|
||||
bool wasmForTrustedPrinciples_ : 1;
|
||||
bool wasmVerbose_ : 1;
|
||||
bool wasmBaseline_ : 1;
|
||||
bool wasmIon_ : 1;
|
||||
bool testWasmAwaitTier2_ : 1;
|
||||
|
||||
@@ -839,7 +839,6 @@ bool shell::enableWasm = false;
|
||||
bool shell::enableSharedMemory = SHARED_MEMORY_DEFAULT;
|
||||
bool shell::enableWasmBaseline = false;
|
||||
bool shell::enableWasmOptimizing = false;
|
||||
bool shell::enableWasmVerbose = false;
|
||||
bool shell::enableTestWasmAwaitTier2 = false;
|
||||
bool shell::enableSourcePragmas = true;
|
||||
bool shell::enableAsyncStacks = false;
|
||||
@@ -11832,7 +11831,6 @@ static void SetWorkerContextOptions(JSContext* cx) {
|
||||
.setWasmBaseline(enableWasmBaseline)
|
||||
.setWasmIon(enableWasmOptimizing)
|
||||
|
||||
.setWasmVerbose(enableWasmVerbose)
|
||||
.setTestWasmAwaitTier2(enableTestWasmAwaitTier2)
|
||||
.setSourcePragmas(enableSourcePragmas);
|
||||
|
||||
@@ -13358,7 +13356,6 @@ bool SetContextWasmOptions(JSContext* cx, const OptionParser& op) {
|
||||
}
|
||||
}
|
||||
|
||||
enableWasmVerbose = op.getBoolOption("wasm-verbose");
|
||||
enableTestWasmAwaitTier2 = op.getBoolOption("test-wasm-await-tier2");
|
||||
|
||||
JS::ContextOptionsRef(cx)
|
||||
|
||||
@@ -113,7 +113,6 @@ extern bool enableWasm;
|
||||
extern bool enableSharedMemory;
|
||||
extern bool enableWasmBaseline;
|
||||
extern bool enableWasmOptimizing;
|
||||
extern bool enableWasmVerbose;
|
||||
extern bool enableTestWasmAwaitTier2;
|
||||
extern bool enableSourcePragmas;
|
||||
extern bool enableAsyncStacks;
|
||||
|
||||
@@ -87,6 +87,7 @@ class LogModule {
|
||||
#define FOR_EACH_JS_LOG_MODULE(_) \
|
||||
_(debug) /* A predefined log module for casual debugging */ \
|
||||
_(wasmPerf) /* Wasm performance statistics */ \
|
||||
_(wasmApi) /* Wasm JS-API tracing */ \
|
||||
_(fuseInvalidation) /* Invalidation triggered by a fuse */ \
|
||||
_(thenable) /* Thenable on standard proto*/ \
|
||||
_(startup) /* engine startup logging */ \
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "js/Printf.h"
|
||||
#include "js/Utility.h"
|
||||
#include "vm/JSContext.h"
|
||||
#include "vm/Logging.h"
|
||||
#include "vm/Warnings.h"
|
||||
|
||||
using namespace js;
|
||||
@@ -32,7 +33,10 @@ using namespace js::wasm;
|
||||
void wasm::Log(JSContext* cx, const char* fmt, ...) {
|
||||
MOZ_ASSERT(!cx->isExceptionPending() || cx->isThrowingOutOfMemory());
|
||||
|
||||
if (!cx->options().wasmVerbose() || cx->isThrowingOutOfMemory()) {
|
||||
bool shouldWarn = JS::Prefs::wasm_trace_api();
|
||||
bool shouldLog = wasmApiModule.shouldLog(LogLevel::Info);
|
||||
|
||||
if (cx->isThrowingOutOfMemory() || (!shouldWarn && !shouldLog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,9 +44,15 @@ void wasm::Log(JSContext* cx, const char* fmt, ...) {
|
||||
va_start(args, fmt);
|
||||
|
||||
if (UniqueChars chars = JS_vsmprintf(fmt, args)) {
|
||||
WarnNumberASCII(cx, JSMSG_WASM_VERBOSE, chars.get());
|
||||
if (cx->isExceptionPending()) {
|
||||
cx->clearPendingException();
|
||||
if (shouldWarn) {
|
||||
WarnNumberASCII(cx, JSMSG_WASM_VERBOSE, chars.get());
|
||||
if (cx->isExceptionPending()) {
|
||||
cx->clearPendingException();
|
||||
}
|
||||
}
|
||||
if (shouldLog) {
|
||||
wasmApiModule.interface.logPrint(wasmApiModule.logger, LogLevel::Info,
|
||||
"%s", chars.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +60,17 @@ void wasm::Log(JSContext* cx, const char* fmt, ...) {
|
||||
}
|
||||
|
||||
void wasm::LogOffThread(const char* fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
if (!wasmApiModule.shouldLog(LogLevel::Info)) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
if (UniqueChars chars = JS_vsmprintf(fmt, args)) {
|
||||
wasmApiModule.interface.logPrint(wasmApiModule.logger, LogLevel::Info,
|
||||
"%s", chars.get());
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#ifdef WASM_CODEGEN_DEBUG
|
||||
|
||||
@@ -810,7 +810,6 @@ void xpc::SetPrefableContextOptions(JS::ContextOptions& options) {
|
||||
.setWasmIon(Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_optimizingjit"))
|
||||
.setWasmBaseline(
|
||||
Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_baselinejit"))
|
||||
.setWasmVerbose(Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_verbose"))
|
||||
.setAsyncStack(Preferences::GetBool(JS_OPTIONS_DOT_STR "asyncstack"))
|
||||
.setAsyncStackCaptureDebuggeeOnly(Preferences::GetBool(
|
||||
JS_OPTIONS_DOT_STR "asyncstack_capture_debuggee_only"));
|
||||
|
||||
@@ -8805,6 +8805,12 @@
|
||||
#endif
|
||||
mirror: always
|
||||
|
||||
- name: javascript.options.wasm_trace_api
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
set_spidermonkey_pref: always
|
||||
|
||||
- name: javascript.options.wasm_disable_huge_memory
|
||||
type: bool
|
||||
value: false
|
||||
|
||||
Reference in New Issue
Block a user