LCOV - code coverage report
Current view: top level - js/src/vm - Probes.h (source / functions) Hit Total Coverage
Test: output.info Lines: 3 6 50.0 %
Date: 2017-07-14 16:53:18 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13