Line data Source code
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 : #include "gc/Zone.h"
15 :
16 : namespace js {
17 :
18 : /*
19 : * Many probe handlers are implemented inline for minimal performance impact,
20 : * especially important when no backends are enabled.
21 : */
22 :
23 : inline bool
24 : probes::CallTrackingActive(JSContext* cx)
25 : {
26 : #ifdef INCLUDE_MOZILLA_DTRACE
27 : if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED() || JAVASCRIPT_FUNCTION_RETURN_ENABLED())
28 : return true;
29 : #endif
30 : return false;
31 : }
32 :
33 : inline bool
34 12100 : probes::EnterScript(JSContext* cx, JSScript* script, JSFunction* maybeFun,
35 : InterpreterFrame* fp)
36 : {
37 : #ifdef INCLUDE_MOZILLA_DTRACE
38 : if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED())
39 : DTraceEnterJSFun(cx, maybeFun, script);
40 : #endif
41 :
42 12100 : JSRuntime* rt = cx->runtime();
43 12100 : if (rt->geckoProfiler().enabled()) {
44 0 : if (!rt->geckoProfiler().enter(cx, script, maybeFun))
45 0 : return false;
46 0 : MOZ_ASSERT_IF(!fp->script()->isStarGenerator() &&
47 : !fp->script()->isLegacyGenerator() &&
48 : !fp->script()->isAsync(),
49 : !fp->hasPushedGeckoProfilerFrame());
50 0 : fp->setPushedGeckoProfilerFrame();
51 : }
52 :
53 12100 : return true;
54 : }
55 :
56 : inline void
57 12225 : probes::ExitScript(JSContext* cx, JSScript* script, JSFunction* maybeFun, bool popProfilerFrame)
58 : {
59 : #ifdef INCLUDE_MOZILLA_DTRACE
60 : if (JAVASCRIPT_FUNCTION_RETURN_ENABLED())
61 : DTraceExitJSFun(cx, maybeFun, script);
62 : #endif
63 :
64 12225 : if (popProfilerFrame)
65 0 : cx->runtime()->geckoProfiler().exit(script, maybeFun);
66 12225 : }
67 :
68 : inline bool
69 498 : probes::StartExecution(JSScript* script)
70 : {
71 498 : bool ok = true;
72 :
73 : #ifdef INCLUDE_MOZILLA_DTRACE
74 : if (JAVASCRIPT_EXECUTE_START_ENABLED())
75 : JAVASCRIPT_EXECUTE_START((script->filename() ? (char*)script->filename() : nullName),
76 : script->lineno());
77 : #endif
78 :
79 498 : return ok;
80 : }
81 :
82 : inline bool
83 494 : probes::StopExecution(JSScript* script)
84 : {
85 494 : bool ok = true;
86 :
87 : #ifdef INCLUDE_MOZILLA_DTRACE
88 : if (JAVASCRIPT_EXECUTE_DONE_ENABLED())
89 : JAVASCRIPT_EXECUTE_DONE((script->filename() ? (char*)script->filename() : nullName),
90 : script->lineno());
91 : #endif
92 :
93 494 : return ok;
94 : }
95 :
96 : } /* namespace js */
97 :
98 : #endif /* vm_Probes_inl_h */
|