Changeset View
Changeset View
Standalone View
Standalone View
libraries/source/spidermonkey/include-win32-debug/js/ProfilingStack.h
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||||
* vim: set ts=8 sts=4 et sw=4 tw=99: | * vim: set ts=8 sts=4 et sw=4 tw=99: | ||||
* This Source Code Form is subject to the terms of the Mozilla Public | * This Source Code Form is subject to the terms of the Mozilla Public | ||||
* License, v. 2.0. If a copy of the MPL was not distributed with this | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||||
#ifndef js_ProfilingStack_h | #ifndef js_ProfilingStack_h | ||||
#define js_ProfilingStack_h | #define js_ProfilingStack_h | ||||
#include "jsbytecode.h" | #include "jsbytecode.h" | ||||
#include "jstypes.h" | #include "jstypes.h" | ||||
#include "js/TypeDecls.h" | #include "js/TypeDecls.h" | ||||
#include "js/Utility.h" | #include "js/Utility.h" | ||||
struct JSRuntime; | struct JSRuntime; | ||||
class JSTracer; | |||||
namespace js { | namespace js { | ||||
// A call stack can be specified to the JS engine such that all JS entry/exits | // A call stack can be specified to the JS engine such that all JS entry/exits | ||||
// to functions push/pop an entry to/from the specified stack. | // to functions push/pop an entry to/from the specified stack. | ||||
// | // | ||||
// For more detailed information, see vm/SPSProfiler.h. | // For more detailed information, see vm/SPSProfiler.h. | ||||
// | // | ||||
Show All 12 Lines | class ProfileEntry | ||||
// Descriptive string of this entry. | // Descriptive string of this entry. | ||||
const char * volatile string; | const char * volatile string; | ||||
// Stack pointer for non-JS entries, the script pointer otherwise. | // Stack pointer for non-JS entries, the script pointer otherwise. | ||||
void * volatile spOrScript; | void * volatile spOrScript; | ||||
// Line number for non-JS entries, the bytecode offset otherwise. | // Line number for non-JS entries, the bytecode offset otherwise. | ||||
int32_t volatile lineOrPc; | int32_t volatile lineOrPcOffset; | ||||
// General purpose storage describing this frame. | // General purpose storage describing this frame. | ||||
uint32_t volatile flags_; | uint32_t volatile flags_; | ||||
public: | public: | ||||
// These traits are bit masks. Make sure they're powers of 2. | // These traits are bit masks. Make sure they're powers of 2. | ||||
enum Flags { | enum Flags : uint32_t { | ||||
// Indicate whether a profile entry represents a CPP frame. If not set, | // Indicate whether a profile entry represents a CPP frame. If not set, | ||||
// a JS frame is assumed by default. You're not allowed to publicly | // a JS frame is assumed by default. You're not allowed to publicly | ||||
// change the frame type. Instead, initialize the ProfileEntry as either | // change the frame type. Instead, initialize the ProfileEntry as either | ||||
// a JS or CPP frame with `initJsFrame` or `initCppFrame` respectively. | // a JS or CPP frame with `initJsFrame` or `initCppFrame` respectively. | ||||
IS_CPP_ENTRY = 0x01, | IS_CPP_ENTRY = 0x01, | ||||
// Indicate that copying the frame label is not necessary when taking a | // Indicate that copying the frame label is not necessary when taking a | ||||
// sample of the pseudostack. | // sample of the pseudostack. | ||||
Show All 9 Lines | enum Flags : uint32_t { | ||||
// Union of all flags. | // Union of all flags. | ||||
ALL = IS_CPP_ENTRY|FRAME_LABEL_COPY|BEGIN_PSEUDO_JS|OSR, | ALL = IS_CPP_ENTRY|FRAME_LABEL_COPY|BEGIN_PSEUDO_JS|OSR, | ||||
// Mask for removing all flags except the category information. | // Mask for removing all flags except the category information. | ||||
CATEGORY_MASK = ~ALL | CATEGORY_MASK = ~ALL | ||||
}; | }; | ||||
// Keep these in sync with devtools/client/performance/modules/global.js | // Keep these in sync with devtools/client/performance/modules/categories.js | ||||
enum class Category : uint32_t { | enum class Category : uint32_t { | ||||
OTHER = 0x10, | OTHER = 0x10, | ||||
CSS = 0x20, | CSS = 0x20, | ||||
JS = 0x40, | JS = 0x40, | ||||
GC = 0x80, | GC = 0x80, | ||||
CC = 0x100, | CC = 0x100, | ||||
NETWORK = 0x200, | NETWORK = 0x200, | ||||
GRAPHICS = 0x400, | GRAPHICS = 0x400, | ||||
Show All 23 Lines | public: | ||||
void initJsFrame(JSScript* aScript, jsbytecode* aPc) volatile { | void initJsFrame(JSScript* aScript, jsbytecode* aPc) volatile { | ||||
flags_ = 0; | flags_ = 0; | ||||
spOrScript = aScript; | spOrScript = aScript; | ||||
setPC(aPc); | setPC(aPc); | ||||
} | } | ||||
void initCppFrame(void* aSp, uint32_t aLine) volatile { | void initCppFrame(void* aSp, uint32_t aLine) volatile { | ||||
flags_ = IS_CPP_ENTRY; | flags_ = IS_CPP_ENTRY; | ||||
spOrScript = aSp; | spOrScript = aSp; | ||||
lineOrPc = static_cast<int32_t>(aLine); | lineOrPcOffset = static_cast<int32_t>(aLine); | ||||
} | } | ||||
void setFlag(uint32_t flag) volatile { | void setFlag(uint32_t flag) volatile { | ||||
MOZ_ASSERT(flag != IS_CPP_ENTRY); | MOZ_ASSERT(flag != IS_CPP_ENTRY); | ||||
flags_ |= flag; | flags_ |= flag; | ||||
} | } | ||||
void unsetFlag(uint32_t flag) volatile { | void unsetFlag(uint32_t flag) volatile { | ||||
MOZ_ASSERT(flag != IS_CPP_ENTRY); | MOZ_ASSERT(flag != IS_CPP_ENTRY); | ||||
Show All 28 Lines | public: | ||||
bool isOSR() const volatile { | bool isOSR() const volatile { | ||||
return hasFlag(OSR); | return hasFlag(OSR); | ||||
} | } | ||||
void* stackAddress() const volatile { | void* stackAddress() const volatile { | ||||
MOZ_ASSERT(!isJs()); | MOZ_ASSERT(!isJs()); | ||||
return spOrScript; | return spOrScript; | ||||
} | } | ||||
JSScript* script() const volatile { | JS_PUBLIC_API(JSScript*) script() const volatile; | ||||
MOZ_ASSERT(isJs()); | |||||
return (JSScript*)spOrScript; | |||||
} | |||||
uint32_t line() const volatile { | uint32_t line() const volatile { | ||||
MOZ_ASSERT(!isJs()); | MOZ_ASSERT(!isJs()); | ||||
return static_cast<uint32_t>(lineOrPc); | return static_cast<uint32_t>(lineOrPcOffset); | ||||
} | |||||
// Note that the pointer returned might be invalid. | |||||
JSScript* rawScript() const volatile { | |||||
MOZ_ASSERT(isJs()); | |||||
return (JSScript*)spOrScript; | |||||
} | } | ||||
// We can't know the layout of JSScript, so look in vm/SPSProfiler.cpp. | // We can't know the layout of JSScript, so look in vm/SPSProfiler.cpp. | ||||
JS_FRIEND_API(jsbytecode*) pc() const volatile; | JS_FRIEND_API(jsbytecode*) pc() const volatile; | ||||
JS_FRIEND_API(void) setPC(jsbytecode* pc) volatile; | JS_FRIEND_API(void) setPC(jsbytecode* pc) volatile; | ||||
void trace(JSTracer* trc); | |||||
// The offset of a pc into a script's code can actually be 0, so to | // The offset of a pc into a script's code can actually be 0, so to | ||||
// signify a nullptr pc, use a -1 index. This is checked against in | // signify a nullptr pc, use a -1 index. This is checked against in | ||||
// pc() and setPC() to set/get the right pc. | // pc() and setPC() to set/get the right pc. | ||||
static const int32_t NullPCOffset = -1; | static const int32_t NullPCOffset = -1; | ||||
static size_t offsetOfLabel() { return offsetof(ProfileEntry, string); } | static size_t offsetOfLabel() { return offsetof(ProfileEntry, string); } | ||||
static size_t offsetOfSpOrScript() { return offsetof(ProfileEntry, spOrScript); } | static size_t offsetOfSpOrScript() { return offsetof(ProfileEntry, spOrScript); } | ||||
static size_t offsetOfLineOrPc() { return offsetof(ProfileEntry, lineOrPc); } | static size_t offsetOfLineOrPcOffset() { return offsetof(ProfileEntry, lineOrPcOffset); } | ||||
static size_t offsetOfFlags() { return offsetof(ProfileEntry, flags_); } | static size_t offsetOfFlags() { return offsetof(ProfileEntry, flags_); } | ||||
}; | }; | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
SetRuntimeProfilingStack(JSRuntime* rt, ProfileEntry* stack, uint32_t* size, | SetContextProfilingStack(JSContext* cx, ProfileEntry* stack, uint32_t* size, | ||||
uint32_t max); | uint32_t max); | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
EnableRuntimeProfilingStack(JSRuntime* rt, bool enabled); | EnableContextProfilingStack(JSContext* cx, bool enabled); | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
RegisterRuntimeProfilingEventMarker(JSRuntime* rt, void (*fn)(const char*)); | RegisterContextProfilingEventMarker(JSContext* cx, void (*fn)(const char*)); | ||||
JS_FRIEND_API(jsbytecode*) | JS_FRIEND_API(jsbytecode*) | ||||
ProfilingGetPC(JSRuntime* rt, JSScript* script, void* ip); | ProfilingGetPC(JSContext* cx, JSScript* script, void* ip); | ||||
} // namespace js | } // namespace js | ||||
#endif /* js_ProfilingStack_h */ | #endif /* js_ProfilingStack_h */ |
Wildfire Games · Phabricator