Probes.h (2626B)
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_h 8 #define vm_Probes_h 9 10 #include "vm/JSObject.h" 11 12 namespace js { 13 14 class InterpreterFrame; 15 16 namespace probes { 17 18 /* 19 * Static probes 20 * 21 * The probe points defined in this file are scattered around the SpiderMonkey 22 * source tree. The presence of probes::SomeEvent() means that someEvent is 23 * about to happen or has happened. To the extent possible, probes should be 24 * inserted in all paths associated with a given event, regardless of the 25 * active runmode (interpreter/traceJIT/methodJIT/ionJIT). 26 * 27 * When a probe fires, it is handled by any probe handling backends that have 28 * been compiled in. By default, most probes do nothing or at least do nothing 29 * expensive, so the presence of the probe should have negligible effect on 30 * running time. (Probes in slow paths may do something by default, as long as 31 * there is no noticeable slowdown.) 32 * 33 * For some probes, the mere existence of the probe is too expensive even if it 34 * does nothing when called. For example, just having consistent information 35 * available for a function call entry/exit probe causes the JITs to 36 * de-optimize function calls. In those cases, the JITs may query at compile 37 * time whether a probe is desired, and omit the probe invocation if not. If a 38 * probe is runtime-disabled at compilation time, it is not guaranteed to fire 39 * within a compiled function if it is later enabled. 40 * 41 * Not all backends handle all of the probes listed here. 42 */ 43 44 /* 45 * Internal use only: remember whether "profiling", whatever that means, is 46 * currently active. Used for state management. 47 */ 48 extern bool ProfilingActive; 49 50 /* Entering a JS function */ 51 bool EnterScript(JSContext*, JSScript*, JSFunction*, InterpreterFrame*); 52 53 /* About to leave a JS function */ 54 void ExitScript(JSContext*, JSScript*, JSFunction*, bool popProfilerFrame); 55 56 /* 57 * Object has been created. |obj| must exist (its class and size are read) 58 */ 59 bool CreateObject(JSContext* cx, JSObject* obj); 60 61 /* 62 * Object is about to be finalized. |obj| must still exist (its class is 63 * read) 64 */ 65 bool FinalizeObject(JSObject* obj); 66 } // namespace probes 67 68 inline bool probes::CreateObject(JSContext* cx, JSObject* obj) { return true; } 69 70 inline bool probes::FinalizeObject(JSObject* obj) { return true; } 71 72 } /* namespace js */ 73 74 #endif /* vm_Probes_h */