1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=4 sw=4 et tw=99:
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
20 * The Initial Developer of the Original Code is
21 * Brendan Eich <brendan@mozilla.org>
24 * David Anderson <danderson@mozilla.com>
25 * Julian Seward <jseward@acm.org>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
46 #include "MethodJIT.h"
49 #if defined(JS_METHODJIT_SPEW)
51 static bool LoggingChecked = false;
52 static uint32 LoggingBits = 0;
54 static const char *ChannelNames[] =
56 #define _(name) #name,
64 /* Not MT safe; races on Logging{Checked,Bits}. */
67 LoggingChecked = true;
68 const char *env = getenv("JMFLAGS");
71 if (strstr(env, "help")) {
75 "usage: JMFLAGS=option,option,option,... where options can be:\n"
77 " help show this message\n"
84 " insns JS opcodes and generated insns\n"
85 " vmframe VMFrame contents\n"
86 " pics PIC patching activity\n"
87 " slowcalls Calls to slow path functions\n"
89 " notrace disable trace hints\n"
95 if (strstr(env, "abort") || strstr(env, "aborts"))
96 LoggingBits |= (1 << uint32(JSpew_Abort));
97 if (strstr(env, "scripts"))
98 LoggingBits |= (1 << uint32(JSpew_Scripts));
99 if (strstr(env, "profile"))
100 LoggingBits |= (1 << uint32(JSpew_Prof));
102 if (strstr(env, "jsops"))
103 LoggingBits |= (1 << uint32(JSpew_JSOps));
105 if (strstr(env, "insns"))
106 LoggingBits |= (1 << uint32(JSpew_Insns) | (1 << uint32(JSpew_JSOps)));
107 if (strstr(env, "vmframe"))
108 LoggingBits |= (1 << uint32(JSpew_VMFrame));
109 if (strstr(env, "pics"))
110 LoggingBits |= (1 << uint32(JSpew_PICs));
111 if (strstr(env, "slowcalls"))
112 LoggingBits |= (1 << uint32(JSpew_SlowCalls));
113 if (strstr(env, "full"))
114 LoggingBits |= 0xFFFFFFFF;
118 js::IsJaegerSpewChannelActive(JaegerSpewChannel channel)
120 JS_ASSERT(LoggingChecked);
121 return !!(LoggingBits & (1 << uint32(channel)));
125 js::JaegerSpew(JaegerSpewChannel channel, const char *fmt, ...)
127 JS_ASSERT(LoggingChecked);
129 if (!(LoggingBits & (1 << uint32(channel))))
132 fprintf(stderr, "[jaeger] %-7s ", ChannelNames[channel]);
136 vfprintf(stderr, fmt, ap);
139 /* fprintf(stdout, "\n"); */