js/src/builtin/Profilers.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 /*
michael@0 8 * Functions for controlling profilers from within JS: Valgrind, Perf,
michael@0 9 * Shark, etc.
michael@0 10 */
michael@0 11 #ifndef builtin_Profilers_h
michael@0 12 #define builtin_Profilers_h
michael@0 13
michael@0 14 #include "jstypes.h"
michael@0 15
michael@0 16 #ifdef _MSC_VER
michael@0 17 typedef int pid_t;
michael@0 18 #else
michael@0 19 #include <unistd.h>
michael@0 20 #endif
michael@0 21
michael@0 22 /**
michael@0 23 * Start any profilers that are available and have been configured on for this
michael@0 24 * platform. This is NOT thread safe.
michael@0 25 *
michael@0 26 * The profileName is used by some profilers to describe the current profiling
michael@0 27 * run. It may be used for part of the filename of the output, but the
michael@0 28 * specifics depend on the profiler. Many profilers will ignore it. Passing in
michael@0 29 * nullptr is legal; some profilers may use it to output to stdout or similar.
michael@0 30 *
michael@0 31 * Returns true if no profilers fail to start.
michael@0 32 */
michael@0 33 extern JS_PUBLIC_API(bool)
michael@0 34 JS_StartProfiling(const char *profileName, pid_t pid);
michael@0 35
michael@0 36 /**
michael@0 37 * Stop any profilers that were previously started with JS_StartProfiling.
michael@0 38 * Returns true if no profilers fail to stop.
michael@0 39 */
michael@0 40 extern JS_PUBLIC_API(bool)
michael@0 41 JS_StopProfiling(const char *profileName);
michael@0 42
michael@0 43 /**
michael@0 44 * Write the current profile data to the given file, if applicable to whatever
michael@0 45 * profiler is being used.
michael@0 46 */
michael@0 47 extern JS_PUBLIC_API(bool)
michael@0 48 JS_DumpProfile(const char *outfile, const char *profileName);
michael@0 49
michael@0 50 /**
michael@0 51 * Pause currently active profilers (only supported by some profilers). Returns
michael@0 52 * whether any profilers failed to pause. (Profilers that do not support
michael@0 53 * pause/resume do not count.)
michael@0 54 */
michael@0 55 extern JS_PUBLIC_API(bool)
michael@0 56 JS_PauseProfilers(const char *profileName);
michael@0 57
michael@0 58 /**
michael@0 59 * Resume suspended profilers
michael@0 60 */
michael@0 61 extern JS_PUBLIC_API(bool)
michael@0 62 JS_ResumeProfilers(const char *profileName);
michael@0 63
michael@0 64 /**
michael@0 65 * The profiling API calls are not able to report errors, so they use a
michael@0 66 * thread-unsafe global memory buffer to hold the last error encountered. This
michael@0 67 * should only be called after something returns false.
michael@0 68 */
michael@0 69 JS_PUBLIC_API(const char *)
michael@0 70 JS_UnsafeGetLastProfilingError();
michael@0 71
michael@0 72 #ifdef MOZ_CALLGRIND
michael@0 73
michael@0 74 extern JS_FRIEND_API(bool)
michael@0 75 js_StopCallgrind();
michael@0 76
michael@0 77 extern JS_FRIEND_API(bool)
michael@0 78 js_StartCallgrind();
michael@0 79
michael@0 80 extern JS_FRIEND_API(bool)
michael@0 81 js_DumpCallgrind(const char *outfile);
michael@0 82
michael@0 83 #endif /* MOZ_CALLGRIND */
michael@0 84
michael@0 85 #ifdef __linux__
michael@0 86
michael@0 87 extern JS_FRIEND_API(bool)
michael@0 88 js_StartPerf();
michael@0 89
michael@0 90 extern JS_FRIEND_API(bool)
michael@0 91 js_StopPerf();
michael@0 92
michael@0 93 #endif /* __linux__ */
michael@0 94
michael@0 95 #endif /* builtin_Profilers_h */

mercurial