js/src/vm/Probes.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial