1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/vm/Probes-inl.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,110 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef vm_Probes_inl_h 1.11 +#define vm_Probes_inl_h 1.12 + 1.13 +#include "vm/Probes.h" 1.14 + 1.15 +#include "jscntxt.h" 1.16 + 1.17 +namespace js { 1.18 + 1.19 +/* 1.20 + * Many probe handlers are implemented inline for minimal performance impact, 1.21 + * especially important when no backends are enabled. 1.22 + */ 1.23 + 1.24 +inline bool 1.25 +probes::CallTrackingActive(JSContext *cx) 1.26 +{ 1.27 +#ifdef INCLUDE_MOZILLA_DTRACE 1.28 + if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED() || JAVASCRIPT_FUNCTION_RETURN_ENABLED()) 1.29 + return true; 1.30 +#endif 1.31 +#ifdef MOZ_TRACE_JSCALLS 1.32 + if (cx->functionCallback) 1.33 + return true; 1.34 +#endif 1.35 + return false; 1.36 +} 1.37 + 1.38 +inline bool 1.39 +probes::WantNativeAddressInfo(JSContext *cx) 1.40 +{ 1.41 + return (cx->reportGranularity >= JITREPORT_GRANULARITY_FUNCTION && 1.42 + JITGranularityRequested(cx) >= JITREPORT_GRANULARITY_FUNCTION); 1.43 +} 1.44 + 1.45 +inline bool 1.46 +probes::EnterScript(JSContext *cx, JSScript *script, JSFunction *maybeFun, 1.47 + InterpreterFrame *fp) 1.48 +{ 1.49 +#ifdef INCLUDE_MOZILLA_DTRACE 1.50 + if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED()) 1.51 + DTraceEnterJSFun(cx, maybeFun, script); 1.52 +#endif 1.53 +#ifdef MOZ_TRACE_JSCALLS 1.54 + cx->doFunctionCallback(maybeFun, script, 1); 1.55 +#endif 1.56 + 1.57 + JSRuntime *rt = cx->runtime(); 1.58 + if (rt->spsProfiler.enabled()) { 1.59 + if (!rt->spsProfiler.enter(script, maybeFun)) 1.60 + return false; 1.61 + JS_ASSERT_IF(!fp->isGeneratorFrame(), !fp->hasPushedSPSFrame()); 1.62 + fp->setPushedSPSFrame(); 1.63 + } 1.64 + 1.65 + return true; 1.66 +} 1.67 + 1.68 +inline void 1.69 +probes::ExitScript(JSContext *cx, JSScript *script, JSFunction *maybeFun, bool popSPSFrame) 1.70 +{ 1.71 +#ifdef INCLUDE_MOZILLA_DTRACE 1.72 + if (JAVASCRIPT_FUNCTION_RETURN_ENABLED()) 1.73 + DTraceExitJSFun(cx, maybeFun, script); 1.74 +#endif 1.75 +#ifdef MOZ_TRACE_JSCALLS 1.76 + cx->doFunctionCallback(maybeFun, script, 0); 1.77 +#endif 1.78 + 1.79 + if (popSPSFrame) 1.80 + cx->runtime()->spsProfiler.exit(script, maybeFun); 1.81 +} 1.82 + 1.83 +inline bool 1.84 +probes::StartExecution(JSScript *script) 1.85 +{ 1.86 + bool ok = true; 1.87 + 1.88 +#ifdef INCLUDE_MOZILLA_DTRACE 1.89 + if (JAVASCRIPT_EXECUTE_START_ENABLED()) 1.90 + JAVASCRIPT_EXECUTE_START((script->filename() ? (char *)script->filename() : nullName), 1.91 + script->lineno()); 1.92 +#endif 1.93 + 1.94 + return ok; 1.95 +} 1.96 + 1.97 +inline bool 1.98 +probes::StopExecution(JSScript *script) 1.99 +{ 1.100 + bool ok = true; 1.101 + 1.102 +#ifdef INCLUDE_MOZILLA_DTRACE 1.103 + if (JAVASCRIPT_EXECUTE_DONE_ENABLED()) 1.104 + JAVASCRIPT_EXECUTE_DONE((script->filename() ? (char *)script->filename() : nullName), 1.105 + script->lineno()); 1.106 +#endif 1.107 + 1.108 + return ok; 1.109 +} 1.110 + 1.111 +} /* namespace js */ 1.112 + 1.113 +#endif /* vm_Probes_inl_h */