michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef vm_Probes_inl_h michael@0: #define vm_Probes_inl_h michael@0: michael@0: #include "vm/Probes.h" michael@0: michael@0: #include "jscntxt.h" michael@0: michael@0: namespace js { michael@0: michael@0: /* michael@0: * Many probe handlers are implemented inline for minimal performance impact, michael@0: * especially important when no backends are enabled. michael@0: */ michael@0: michael@0: inline bool michael@0: probes::CallTrackingActive(JSContext *cx) michael@0: { michael@0: #ifdef INCLUDE_MOZILLA_DTRACE michael@0: if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED() || JAVASCRIPT_FUNCTION_RETURN_ENABLED()) michael@0: return true; michael@0: #endif michael@0: #ifdef MOZ_TRACE_JSCALLS michael@0: if (cx->functionCallback) michael@0: return true; michael@0: #endif michael@0: return false; michael@0: } michael@0: michael@0: inline bool michael@0: probes::WantNativeAddressInfo(JSContext *cx) michael@0: { michael@0: return (cx->reportGranularity >= JITREPORT_GRANULARITY_FUNCTION && michael@0: JITGranularityRequested(cx) >= JITREPORT_GRANULARITY_FUNCTION); michael@0: } michael@0: michael@0: inline bool michael@0: probes::EnterScript(JSContext *cx, JSScript *script, JSFunction *maybeFun, michael@0: InterpreterFrame *fp) michael@0: { michael@0: #ifdef INCLUDE_MOZILLA_DTRACE michael@0: if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED()) michael@0: DTraceEnterJSFun(cx, maybeFun, script); michael@0: #endif michael@0: #ifdef MOZ_TRACE_JSCALLS michael@0: cx->doFunctionCallback(maybeFun, script, 1); michael@0: #endif michael@0: michael@0: JSRuntime *rt = cx->runtime(); michael@0: if (rt->spsProfiler.enabled()) { michael@0: if (!rt->spsProfiler.enter(script, maybeFun)) michael@0: return false; michael@0: JS_ASSERT_IF(!fp->isGeneratorFrame(), !fp->hasPushedSPSFrame()); michael@0: fp->setPushedSPSFrame(); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: inline void michael@0: probes::ExitScript(JSContext *cx, JSScript *script, JSFunction *maybeFun, bool popSPSFrame) michael@0: { michael@0: #ifdef INCLUDE_MOZILLA_DTRACE michael@0: if (JAVASCRIPT_FUNCTION_RETURN_ENABLED()) michael@0: DTraceExitJSFun(cx, maybeFun, script); michael@0: #endif michael@0: #ifdef MOZ_TRACE_JSCALLS michael@0: cx->doFunctionCallback(maybeFun, script, 0); michael@0: #endif michael@0: michael@0: if (popSPSFrame) michael@0: cx->runtime()->spsProfiler.exit(script, maybeFun); michael@0: } michael@0: michael@0: inline bool michael@0: probes::StartExecution(JSScript *script) michael@0: { michael@0: bool ok = true; michael@0: michael@0: #ifdef INCLUDE_MOZILLA_DTRACE michael@0: if (JAVASCRIPT_EXECUTE_START_ENABLED()) michael@0: JAVASCRIPT_EXECUTE_START((script->filename() ? (char *)script->filename() : nullName), michael@0: script->lineno()); michael@0: #endif michael@0: michael@0: return ok; michael@0: } michael@0: michael@0: inline bool michael@0: probes::StopExecution(JSScript *script) michael@0: { michael@0: bool ok = true; michael@0: michael@0: #ifdef INCLUDE_MOZILLA_DTRACE michael@0: if (JAVASCRIPT_EXECUTE_DONE_ENABLED()) michael@0: JAVASCRIPT_EXECUTE_DONE((script->filename() ? (char *)script->filename() : nullName), michael@0: script->lineno()); michael@0: #endif michael@0: michael@0: return ok; michael@0: } michael@0: michael@0: } /* namespace js */ michael@0: michael@0: #endif /* vm_Probes_inl_h */