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"
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"
30 using namespace js::wasm
;
32 void wasm::Log(JSContext
* cx
, const char* fmt
, ...) {
33 MOZ_ASSERT(!cx
->isExceptionPending());
35 if (!cx
->options().wasmVerbose()) {
42 if (UniqueChars chars
= JS_vsmprintf(fmt
, args
)) {
43 WarnNumberASCII(cx
, JSMSG_WASM_VERBOSE
, chars
.get());
44 if (cx
->isExceptionPending()) {
45 cx
->clearPendingException();
52 void wasm::LogOffThread(const char* fmt
, ...) {
55 vfprintf(stderr
, fmt
, ap
);
59 #ifdef WASM_CODEGEN_DEBUG
60 bool wasm::IsCodegenDebugEnabled(DebugChannel channel
) {
62 case DebugChannel::Function
:
63 return jit::JitOptions
.enableWasmFuncCallSpew
;
64 case DebugChannel::Import
:
65 return jit::JitOptions
.enableWasmImportCallSpew
;
71 void wasm::DebugCodegen(DebugChannel channel
, const char* fmt
, ...) {
72 #ifdef WASM_CODEGEN_DEBUG
73 if (!IsCodegenDebugEnabled(channel
)) {
78 vfprintf(stderr
, fmt
, ap
);