js/src/vm/Probes-inl.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:e0487a89b94f
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/. */
6
7 #ifndef vm_Probes_inl_h
8 #define vm_Probes_inl_h
9
10 #include "vm/Probes.h"
11
12 #include "jscntxt.h"
13
14 namespace js {
15
16 /*
17 * Many probe handlers are implemented inline for minimal performance impact,
18 * especially important when no backends are enabled.
19 */
20
21 inline bool
22 probes::CallTrackingActive(JSContext *cx)
23 {
24 #ifdef INCLUDE_MOZILLA_DTRACE
25 if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED() || JAVASCRIPT_FUNCTION_RETURN_ENABLED())
26 return true;
27 #endif
28 #ifdef MOZ_TRACE_JSCALLS
29 if (cx->functionCallback)
30 return true;
31 #endif
32 return false;
33 }
34
35 inline bool
36 probes::WantNativeAddressInfo(JSContext *cx)
37 {
38 return (cx->reportGranularity >= JITREPORT_GRANULARITY_FUNCTION &&
39 JITGranularityRequested(cx) >= JITREPORT_GRANULARITY_FUNCTION);
40 }
41
42 inline bool
43 probes::EnterScript(JSContext *cx, JSScript *script, JSFunction *maybeFun,
44 InterpreterFrame *fp)
45 {
46 #ifdef INCLUDE_MOZILLA_DTRACE
47 if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED())
48 DTraceEnterJSFun(cx, maybeFun, script);
49 #endif
50 #ifdef MOZ_TRACE_JSCALLS
51 cx->doFunctionCallback(maybeFun, script, 1);
52 #endif
53
54 JSRuntime *rt = cx->runtime();
55 if (rt->spsProfiler.enabled()) {
56 if (!rt->spsProfiler.enter(script, maybeFun))
57 return false;
58 JS_ASSERT_IF(!fp->isGeneratorFrame(), !fp->hasPushedSPSFrame());
59 fp->setPushedSPSFrame();
60 }
61
62 return true;
63 }
64
65 inline void
66 probes::ExitScript(JSContext *cx, JSScript *script, JSFunction *maybeFun, bool popSPSFrame)
67 {
68 #ifdef INCLUDE_MOZILLA_DTRACE
69 if (JAVASCRIPT_FUNCTION_RETURN_ENABLED())
70 DTraceExitJSFun(cx, maybeFun, script);
71 #endif
72 #ifdef MOZ_TRACE_JSCALLS
73 cx->doFunctionCallback(maybeFun, script, 0);
74 #endif
75
76 if (popSPSFrame)
77 cx->runtime()->spsProfiler.exit(script, maybeFun);
78 }
79
80 inline bool
81 probes::StartExecution(JSScript *script)
82 {
83 bool ok = true;
84
85 #ifdef INCLUDE_MOZILLA_DTRACE
86 if (JAVASCRIPT_EXECUTE_START_ENABLED())
87 JAVASCRIPT_EXECUTE_START((script->filename() ? (char *)script->filename() : nullName),
88 script->lineno());
89 #endif
90
91 return ok;
92 }
93
94 inline bool
95 probes::StopExecution(JSScript *script)
96 {
97 bool ok = true;
98
99 #ifdef INCLUDE_MOZILLA_DTRACE
100 if (JAVASCRIPT_EXECUTE_DONE_ENABLED())
101 JAVASCRIPT_EXECUTE_DONE((script->filename() ? (char *)script->filename() : nullName),
102 script->lineno());
103 #endif
104
105 return ok;
106 }
107
108 } /* namespace js */
109
110 #endif /* vm_Probes_inl_h */

mercurial