no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / js / src / wasm / WasmLog.cpp
blob34ef219ce1550d370a395b5e3567c513d39742fa
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
4 * Copyright 2021 Mozilla Foundation
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #include "wasm/WasmLog.h"
21 #include <stdio.h>
23 #include "jit/JitOptions.h"
24 #include "js/Printf.h"
25 #include "js/Utility.h"
26 #include "vm/JSContext.h"
27 #include "vm/Warnings.h"
29 using namespace js;
30 using namespace js::wasm;
32 void wasm::Log(JSContext* cx, const char* fmt, ...) {
33 MOZ_ASSERT(!cx->isExceptionPending());
35 if (!cx->options().wasmVerbose()) {
36 return;
39 va_list args;
40 va_start(args, fmt);
42 if (UniqueChars chars = JS_vsmprintf(fmt, args)) {
43 WarnNumberASCII(cx, JSMSG_WASM_VERBOSE, chars.get());
44 if (cx->isExceptionPending()) {
45 cx->clearPendingException();
49 va_end(args);
52 void wasm::LogOffThread(const char* fmt, ...) {
53 va_list ap;
54 va_start(ap, fmt);
55 vfprintf(stderr, fmt, ap);
56 va_end(ap);
59 #ifdef WASM_CODEGEN_DEBUG
60 bool wasm::IsCodegenDebugEnabled(DebugChannel channel) {
61 switch (channel) {
62 case DebugChannel::Function:
63 return jit::JitOptions.enableWasmFuncCallSpew;
64 case DebugChannel::Import:
65 return jit::JitOptions.enableWasmImportCallSpew;
67 return false;
69 #endif
71 void wasm::DebugCodegen(DebugChannel channel, const char* fmt, ...) {
72 #ifdef WASM_CODEGEN_DEBUG
73 if (!IsCodegenDebugEnabled(channel)) {
74 return;
76 va_list ap;
77 va_start(ap, fmt);
78 vfprintf(stderr, fmt, ap);
79 va_end(ap);
80 #endif