js/src/vm/Probes.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "vm/Probes-inl.h"
     9 #include "jscntxt.h"
    11 #ifdef INCLUDE_MOZILLA_DTRACE
    12 #include "jsscriptinlines.h"
    13 #endif
    15 #define TYPEOF(cx,v)    (JSVAL_IS_NULL(v) ? JSTYPE_NULL : JS_TypeOfValue(cx,v))
    17 using namespace js;
    19 const char probes::nullName[] = "(null)";
    20 const char probes::anonymousName[] = "(anonymous)";
    22 bool probes::ProfilingActive = true;
    24 probes::JITReportGranularity
    25 probes::JITGranularityRequested(JSContext *cx)
    26 {
    27     if (cx->runtime()->spsProfiler.enabled())
    28         return JITREPORT_GRANULARITY_LINE;
    29     return JITREPORT_GRANULARITY_NONE;
    30 }
    32 /* ICs are unregistered in a batch */
    33 void
    34 probes::DiscardExecutableRegion(void *start, size_t size)
    35 {
    36     /*
    37      * Not needed for SPS because ICs are disposed of when the normal JITChunk
    38      * is disposed of
    39      */
    40 }
    42 #ifdef INCLUDE_MOZILLA_DTRACE
    43 static const char *
    44 ScriptFilename(const JSScript *script)
    45 {
    46     if (!script)
    47         return probes::nullName;
    48     if (!script->filename())
    49         return probes::anonymousName;
    50     return script->filename();
    51 }
    53 static const char *
    54 FunctionName(JSContext *cx, JSFunction *fun, JSAutoByteString* bytes)
    55 {
    56     if (!fun)
    57         return probes::nullName;
    58     if (!fun->displayAtom())
    59         return probes::anonymousName;
    60     return bytes->encodeLatin1(cx, fun->displayAtom()) ? bytes->ptr() : probes::nullName;
    61 }
    63 /*
    64  * These functions call the DTrace macros for the JavaScript USDT probes.
    65  * Originally this code was inlined in the JavaScript code; however since
    66  * a number of operations are called, these have been placed into functions
    67  * to reduce any negative compiler optimization effect that the addition of
    68  * a number of usually unused lines of code would cause.
    69  */
    70 void
    71 probes::DTraceEnterJSFun(JSContext *cx, JSFunction *fun, JSScript *script)
    72 {
    73     JSAutoByteString funNameBytes;
    74     JAVASCRIPT_FUNCTION_ENTRY(ScriptFilename(script), probes::nullName,
    75                               FunctionName(cx, fun, &funNameBytes));
    76 }
    78 void
    79 probes::DTraceExitJSFun(JSContext *cx, JSFunction *fun, JSScript *script)
    80 {
    81     JSAutoByteString funNameBytes;
    82     JAVASCRIPT_FUNCTION_RETURN(ScriptFilename(script), probes::nullName,
    83                                FunctionName(cx, fun, &funNameBytes));
    84 }
    85 #endif

mercurial