PageRenderTime 27ms CodeModel.GetById 16ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/js/src/methodjit/Logging.h

http://github.com/zpao/v8monkey
C Header | 132 lines | 69 code | 24 blank | 39 comment | 2 complexity | b0cdc6a162c4b52da37cbd9a82f5d9b4 MD5 | raw file
  1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2 * vim: set ts=4 sw=4 et tw=99:
  3 *
  4 * ***** BEGIN LICENSE BLOCK *****
  5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6 *
  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/
 11 *
 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
 15 * License.
 16 *
 17 * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
 18 * May 28, 2008.
 19 *
 20 * The Initial Developer of the Original Code is
 21 *   Brendan Eich <brendan@mozilla.org>
 22 *
 23 * Contributor(s):
 24 *   David Anderson <danderson@mozilla.com>
 25 *   Julian Seward <jseward@acm.org>
 26 *
 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.
 38 *
 39 * ***** END LICENSE BLOCK ***** */
 40
 41#if !defined jsjaeger_logging_h__
 42#define jsjaeger_logging_h__
 43
 44#include "assembler/wtf/Platform.h"
 45#include "prmjtime.h"
 46
 47#if defined(JS_METHODJIT) || ENABLE_YARR_JIT
 48
 49namespace js {
 50
 51#define JSPEW_CHAN_MAP(_)   \
 52    _(Abort)                \
 53    _(Scripts)              \
 54    _(Prof)                 \
 55    _(JSOps)                \
 56    _(Insns)                \
 57    _(VMFrame)              \
 58    _(PICs)                 \
 59    _(SlowCalls)            \
 60    _(Analysis)             \
 61    _(Regalloc)             \
 62    _(Inlining)             \
 63    _(Recompile)
 64
 65enum JaegerSpewChannel {
 66#define _(name) JSpew_##name,
 67    JSPEW_CHAN_MAP(_)
 68#undef  _
 69    JSpew_Terminator
 70};
 71
 72#if defined(DEBUG) && !defined(JS_METHODJIT_SPEW)
 73# define JS_METHODJIT_SPEW
 74#endif
 75
 76#if defined(JS_METHODJIT_SPEW)
 77
 78void JMCheckLogging();
 79
 80struct ConditionalLog {
 81    uint32_t oldBits;
 82    bool logging;
 83    ConditionalLog(bool logging);
 84    ~ConditionalLog();
 85};
 86
 87bool IsJaegerSpewChannelActive(JaegerSpewChannel channel);
 88#ifdef __GNUC__
 89void JaegerSpew(JaegerSpewChannel channel, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
 90#else
 91void JaegerSpew(JaegerSpewChannel channel, const char *fmt, ...);
 92#endif
 93
 94struct Profiler {
 95    int64_t t_start;
 96    int64_t t_stop;
 97
 98    static inline int64_t now() {
 99        return PRMJ_Now();
100    }
101
102    inline void start() {
103        t_start = now();
104    }
105
106    inline void stop() {
107        t_stop = now();
108    }
109
110    inline uint32_t time_ms() {
111        return uint32_t((t_stop - t_start) / PRMJ_USEC_PER_MSEC);
112    }
113
114    inline uint32_t time_us() {
115        return uint32_t(t_stop - t_start);
116    }
117};
118
119#else
120
121static inline void JaegerSpew(JaegerSpewChannel channel, const char *fmt, ...)
122{
123}
124
125#endif
126
127}
128
129#endif
130
131#endif
132