js/src/vm/Probes.h

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.

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 #ifndef vm_Probes_h
michael@0 8 #define vm_Probes_h
michael@0 9
michael@0 10 #ifdef INCLUDE_MOZILLA_DTRACE
michael@0 11 #include "javascript-trace.h"
michael@0 12 #endif
michael@0 13
michael@0 14 #include "vm/Stack.h"
michael@0 15
michael@0 16 namespace js {
michael@0 17
michael@0 18 namespace probes {
michael@0 19
michael@0 20 /*
michael@0 21 * Static probes
michael@0 22 *
michael@0 23 * The probe points defined in this file are scattered around the SpiderMonkey
michael@0 24 * source tree. The presence of probes::SomeEvent() means that someEvent is
michael@0 25 * about to happen or has happened. To the extent possible, probes should be
michael@0 26 * inserted in all paths associated with a given event, regardless of the
michael@0 27 * active runmode (interpreter/traceJIT/methodJIT/ionJIT).
michael@0 28 *
michael@0 29 * When a probe fires, it is handled by any probe handling backends that have
michael@0 30 * been compiled in. By default, most probes do nothing or at least do nothing
michael@0 31 * expensive, so the presence of the probe should have negligible effect on
michael@0 32 * running time. (Probes in slow paths may do something by default, as long as
michael@0 33 * there is no noticeable slowdown.)
michael@0 34 *
michael@0 35 * For some probes, the mere existence of the probe is too expensive even if it
michael@0 36 * does nothing when called. For example, just having consistent information
michael@0 37 * available for a function call entry/exit probe causes the JITs to
michael@0 38 * de-optimize function calls. In those cases, the JITs may query at compile
michael@0 39 * time whether a probe is desired, and omit the probe invocation if not. If a
michael@0 40 * probe is runtime-disabled at compilation time, it is not guaranteed to fire
michael@0 41 * within a compiled function if it is later enabled.
michael@0 42 *
michael@0 43 * Not all backends handle all of the probes listed here.
michael@0 44 */
michael@0 45
michael@0 46 /*
michael@0 47 * Internal use only: remember whether "profiling", whatever that means, is
michael@0 48 * currently active. Used for state management.
michael@0 49 */
michael@0 50 extern bool ProfilingActive;
michael@0 51
michael@0 52 extern const char nullName[];
michael@0 53 extern const char anonymousName[];
michael@0 54
michael@0 55 /*
michael@0 56 * Test whether we are tracking JS function call enter/exit. The JITs use this
michael@0 57 * to decide whether they can optimize in a way that would prevent probes from
michael@0 58 * firing.
michael@0 59 */
michael@0 60 bool CallTrackingActive(JSContext *);
michael@0 61
michael@0 62 /*
michael@0 63 * Test whether anything is looking for JIT native code registration events.
michael@0 64 * This information will not be collected otherwise.
michael@0 65 */
michael@0 66 bool WantNativeAddressInfo(JSContext *);
michael@0 67
michael@0 68 /* Entering a JS function */
michael@0 69 bool EnterScript(JSContext *, JSScript *, JSFunction *, InterpreterFrame *);
michael@0 70
michael@0 71 /* About to leave a JS function */
michael@0 72 void ExitScript(JSContext *, JSScript *, JSFunction *, bool popSPSFrame);
michael@0 73
michael@0 74 /* Executing a script */
michael@0 75 bool StartExecution(JSScript *script);
michael@0 76
michael@0 77 /* Script has completed execution */
michael@0 78 bool StopExecution(JSScript *script);
michael@0 79
michael@0 80 /*
michael@0 81 * Object has been created. |obj| must exist (its class and size are read)
michael@0 82 */
michael@0 83 bool CreateObject(ExclusiveContext *cx, JSObject *obj);
michael@0 84
michael@0 85 /*
michael@0 86 * Object is about to be finalized. |obj| must still exist (its class is
michael@0 87 * read)
michael@0 88 */
michael@0 89 bool FinalizeObject(JSObject *obj);
michael@0 90
michael@0 91 /* JIT code observation */
michael@0 92
michael@0 93 enum JITReportGranularity {
michael@0 94 JITREPORT_GRANULARITY_NONE = 0,
michael@0 95 JITREPORT_GRANULARITY_FUNCTION = 1,
michael@0 96 JITREPORT_GRANULARITY_LINE = 2,
michael@0 97 JITREPORT_GRANULARITY_OP = 3
michael@0 98 };
michael@0 99
michael@0 100 /*
michael@0 101 * Finest granularity of JIT information desired by all watchers.
michael@0 102 */
michael@0 103 JITReportGranularity
michael@0 104 JITGranularityRequested(JSContext *cx);
michael@0 105
michael@0 106 /*
michael@0 107 * A whole region of code has been deallocated, containing any number of ICs.
michael@0 108 * (ICs are unregistered in a batch, so individual ICs are not registered.)
michael@0 109 */
michael@0 110 void
michael@0 111 DiscardExecutableRegion(void *start, size_t size);
michael@0 112
michael@0 113 /*
michael@0 114 * Internal: DTrace-specific functions to be called during probes::EnterScript
michael@0 115 * and probes::ExitScript. These will not be inlined, but the argument
michael@0 116 * marshalling required for these probe points is expensive enough that it
michael@0 117 * shouldn't really matter.
michael@0 118 */
michael@0 119 void DTraceEnterJSFun(JSContext *cx, JSFunction *fun, JSScript *script);
michael@0 120 void DTraceExitJSFun(JSContext *cx, JSFunction *fun, JSScript *script);
michael@0 121
michael@0 122 } /* namespace Probes */
michael@0 123
michael@0 124 #ifdef INCLUDE_MOZILLA_DTRACE
michael@0 125 static const char *ObjectClassname(JSObject *obj) {
michael@0 126 if (!obj)
michael@0 127 return "(null object)";
michael@0 128 const Class *clasp = obj->getClass();
michael@0 129 if (!clasp)
michael@0 130 return "(null)";
michael@0 131 const char *class_name = clasp->name;
michael@0 132 if (!class_name)
michael@0 133 return "(null class name)";
michael@0 134 return class_name;
michael@0 135 }
michael@0 136 #endif
michael@0 137
michael@0 138 inline bool
michael@0 139 probes::CreateObject(ExclusiveContext *cx, JSObject *obj)
michael@0 140 {
michael@0 141 bool ok = true;
michael@0 142
michael@0 143 #ifdef INCLUDE_MOZILLA_DTRACE
michael@0 144 if (JAVASCRIPT_OBJECT_CREATE_ENABLED())
michael@0 145 JAVASCRIPT_OBJECT_CREATE(ObjectClassname(obj), (uintptr_t)obj);
michael@0 146 #endif
michael@0 147
michael@0 148 return ok;
michael@0 149 }
michael@0 150
michael@0 151 inline bool
michael@0 152 probes::FinalizeObject(JSObject *obj)
michael@0 153 {
michael@0 154 bool ok = true;
michael@0 155
michael@0 156 #ifdef INCLUDE_MOZILLA_DTRACE
michael@0 157 if (JAVASCRIPT_OBJECT_FINALIZE_ENABLED()) {
michael@0 158 const Class *clasp = obj->getClass();
michael@0 159
michael@0 160 /* the first arg is nullptr - reserved for future use (filename?) */
michael@0 161 JAVASCRIPT_OBJECT_FINALIZE(nullptr, (char *)clasp->name, (uintptr_t)obj);
michael@0 162 }
michael@0 163 #endif
michael@0 164
michael@0 165 return ok;
michael@0 166 }
michael@0 167
michael@0 168 } /* namespace js */
michael@0 169
michael@0 170 #endif /* vm_Probes_h */

mercurial