Debian Codegraph @

js/src/vm/Probes-inl.h

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
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 "vm/JSContext.h"
13 #include "vm/JSScript.h"
14
15 namespace js {
16
17 /*
18 * Many probe handlers are implemented inline for minimal performance impact,
19 * especially important when no backends are enabled.
20 */
21
22 inline bool probes::CallTrackingActive(JSContext* cx) {
23 #ifdef INCLUDE_MOZILLA_DTRACE
24 if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED() ||
25 JAVASCRIPT_FUNCTION_RETURN_ENABLED()) {
26 return true;
27 }
28 #endif
29 return false;
30 }
31
32 inline bool probes::EnterScript(JSContext* cx, JSScript* script,
33 JSFunction* maybeFun, InterpreterFrame* fp) {
34 #ifdef INCLUDE_MOZILLA_DTRACE
35 if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED()) {
36 DTraceEnterJSFun(cx, maybeFun, script);
37 }
38 #endif
39
40 JSRuntime* rt = cx->runtime();
41 if (rt->geckoProfiler().enabled()) {
42 if (!cx->geckoProfiler().enter(cx, script)) {
43 return false;
44 }
45 MOZ_ASSERT(!fp->hasPushedGeckoProfilerFrame());
46 fp->setPushedGeckoProfilerFrame();
47 }
48
49 return true;
50 }
51
52 inline void probes::ExitScript(JSContext* cx, JSScript* script,
53 JSFunction* maybeFun, bool popProfilerFrame) {
54 #ifdef INCLUDE_MOZILLA_DTRACE
55 if (JAVASCRIPT_FUNCTION_RETURN_ENABLED()) {
56 DTraceExitJSFun(cx, maybeFun, script);
57 }
58 #endif
59
60 if (popProfilerFrame) {
61 cx->geckoProfiler().exit(cx, script);
62 }
63 }
64
65 inline bool probes::StartExecution(JSScript* script) {
66 bool ok = true;
67
68 #ifdef INCLUDE_MOZILLA_DTRACE
69 if (JAVASCRIPT_EXECUTE_START_ENABLED()) {
70 JAVASCRIPT_EXECUTE_START(
71 (script->filename() ? (char*)script->filename() : nullName),
72 script->lineno());
73 }
74 #endif
75
76 return ok;
77 }
78
79 inline bool probes::StopExecution(JSScript* script) {
80 bool ok = true;
81
82 #ifdef INCLUDE_MOZILLA_DTRACE
83 if (JAVASCRIPT_EXECUTE_DONE_ENABLED()) {
84 JAVASCRIPT_EXECUTE_DONE(
85 (script->filename() ? (char*)script->filename() : nullName),
86 script->lineno());
87 }
88 #endif
89
90 return ok;
91 }
92
93 } /* namespace js */
94
95 #endif /* vm_Probes_inl_h */