From 4cd04ecc8a6558f9e1d42667a69490bf858c3f0b Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Thu, 23 Feb 2017 23:04:13 +0100 Subject: [PATCH] Bug 1341255 - Profiler tidyups: remove StackEntry, rename ProfileEntry to ProfileBufferEntry (part 1: remove StackEntry). r=n.nethercote. --HG-- extra : rebase_source : 6418946b1ebeb82abdccdb10a03380a40c00da21 --- tools/profiler/core/platform.cpp | 18 +++++++++--------- tools/profiler/public/PseudoStack.h | 16 ++-------------- xpcom/threads/ThreadStackHelper.cpp | 6 +++--- xpcom/threads/ThreadStackHelper.h | 5 ++--- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index cfb0c9991df9..7beaecedc7bd 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -251,12 +251,12 @@ AddDynamicCodeLocationTag(ThreadInfo& aInfo, const char* aStr) } static void -AddPseudoEntry(volatile StackEntry& entry, ThreadInfo& aInfo, +AddPseudoEntry(volatile js::ProfileEntry& entry, ThreadInfo& aInfo, PseudoStack* stack, void* lastpc) { // Pseudo-frames with the BEGIN_PSEUDO_JS flag are just annotations and // should not be recorded in the profile. - if (entry.hasFlag(StackEntry::BEGIN_PSEUDO_JS)) { + if (entry.hasFlag(js::ProfileEntry::BEGIN_PSEUDO_JS)) { return; } @@ -307,8 +307,8 @@ AddPseudoEntry(volatile StackEntry& entry, ThreadInfo& aInfo, } uint32_t category = entry.category(); - MOZ_ASSERT(!(category & StackEntry::IS_CPP_ENTRY)); - MOZ_ASSERT(!(category & StackEntry::FRAME_LABEL_COPY)); + MOZ_ASSERT(!(category & js::ProfileEntry::IS_CPP_ENTRY)); + MOZ_ASSERT(!(category & js::ProfileEntry::FRAME_LABEL_COPY)); if (category) { aInfo.addTag(ProfileEntry::Category((int)category)); @@ -345,7 +345,7 @@ MergeStacksIntoProfile(ThreadInfo& aInfo, TickSample* aSample, NativeStack& aNativeStack) { PseudoStack* pseudoStack = aInfo.Stack(); - volatile StackEntry* pseudoFrames = pseudoStack->mStack; + volatile js::ProfileEntry* pseudoFrames = pseudoStack->mStack; uint32_t pseudoCount = pseudoStack->stackSize(); // Make a copy of the JS stack into a JSFrame array. This is necessary since, @@ -420,7 +420,7 @@ MergeStacksIntoProfile(ThreadInfo& aInfo, TickSample* aSample, uint8_t* nativeStackAddr = nullptr; if (pseudoIndex != pseudoCount) { - volatile StackEntry& pseudoFrame = pseudoFrames[pseudoIndex]; + volatile js::ProfileEntry& pseudoFrame = pseudoFrames[pseudoIndex]; if (pseudoFrame.isCpp()) { lastPseudoCppStackAddr = (uint8_t*) pseudoFrame.stackAddress(); @@ -471,7 +471,7 @@ MergeStacksIntoProfile(ThreadInfo& aInfo, TickSample* aSample, // Check to see if pseudoStack frame is top-most. if (pseudoStackAddr > jsStackAddr && pseudoStackAddr > nativeStackAddr) { MOZ_ASSERT(pseudoIndex < pseudoCount); - volatile StackEntry& pseudoFrame = pseudoFrames[pseudoIndex]; + volatile js::ProfileEntry& pseudoFrame = pseudoFrames[pseudoIndex]; AddPseudoEntry(pseudoFrame, aInfo, pseudoStack, nullptr); pseudoIndex++; continue; @@ -616,7 +616,7 @@ DoNativeBacktrace(ThreadInfo& aInfo, TickSample* aSample) for (uint32_t i = pseudoStack->stackSize(); i > 0; --i) { // The pseudostack grows towards higher indices, so we iterate // backwards (from callee to caller). - volatile StackEntry& entry = pseudoStack->mStack[i - 1]; + volatile js::ProfileEntry& entry = pseudoStack->mStack[i - 1]; if (!entry.isJs() && strcmp(entry.label(), "EnterJIT") == 0) { // Found JIT entry frame. Unwind up to that point (i.e., force // the stack walk to stop before the block of saved registers; @@ -2486,7 +2486,7 @@ profiler_get_backtrace_noalloc(char *output, size_t outputSize) return; } - volatile StackEntry *pseudoFrames = pseudoStack->mStack; + volatile js::ProfileEntry *pseudoFrames = pseudoStack->mStack; uint32_t pseudoCount = pseudoStack->stackSize(); for (uint32_t i = 0; i < pseudoCount; i++) { diff --git a/tools/profiler/public/PseudoStack.h b/tools/profiler/public/PseudoStack.h index cabeabe17f9d..c5e8765401cf 100644 --- a/tools/profiler/public/PseudoStack.h +++ b/tools/profiler/public/PseudoStack.h @@ -49,18 +49,6 @@ LinuxKernelMemoryBarrierFunc pLinuxKernelMemoryBarrier __attribute__((weak)) = # error "Memory clobber not supported for your platform." #endif -// A stack entry exists to allow the JS engine to inform the Gecko Profiler of -// the current backtrace, but also to instrument particular points in C++ in -// case stack walking is not available on the platform we are running on. -// -// Each entry has a descriptive string, a relevant stack address, and some extra -// information the JS engine might want to inform the Gecko Profiler of. This -// class inherits from the JS engine's version of the entry to ensure that the -// size and layout of the two representations are consistent. -class StackEntry : public js::ProfileEntry -{ -}; - class ProfilerMarkerPayload; template class ProfilerLinkedList; @@ -273,7 +261,7 @@ public: return; } - volatile StackEntry& entry = mStack[mStackPointer]; + volatile js::ProfileEntry& entry = mStack[mStackPointer]; // Make sure we increment the pointer after the name has been written such // that mStack is always consistent. @@ -412,7 +400,7 @@ private: public: // The list of active checkpoints. - StackEntry volatile mStack[1024]; + js::ProfileEntry volatile mStack[1024]; private: // A list of pending markers that must be moved to the circular buffer. diff --git a/xpcom/threads/ThreadStackHelper.cpp b/xpcom/threads/ThreadStackHelper.cpp index 66d1d550adcd..0e2437e8cc6e 100644 --- a/xpcom/threads/ThreadStackHelper.cpp +++ b/xpcom/threads/ThreadStackHelper.cpp @@ -426,7 +426,7 @@ GetPathAfterComponent(const char* filename, const char (&component)[LEN]) { } // namespace const char* -ThreadStackHelper::AppendJSEntry(const volatile StackEntry* aEntry, +ThreadStackHelper::AppendJSEntry(const volatile js::ProfileEntry* aEntry, intptr_t& aAvailableBufferSize, const char* aPrevLabel) { @@ -513,8 +513,8 @@ ThreadStackHelper::FillStackBuffer() intptr_t availableBufferSize = intptr_t(reservedBufferSize); // Go from front to back - const volatile StackEntry* entry = mPseudoStack->mStack; - const volatile StackEntry* end = entry + mPseudoStack->stackSize(); + const volatile js::ProfileEntry* entry = mPseudoStack->mStack; + const volatile js::ProfileEntry* end = entry + mPseudoStack->stackSize(); // Deduplicate identical, consecutive frames const char* prevLabel = nullptr; for (; reservedSize-- && entry != end; entry++) { diff --git a/xpcom/threads/ThreadStackHelper.h b/xpcom/threads/ThreadStackHelper.h index 12e9e6487b9d..347f7c0d4c97 100644 --- a/xpcom/threads/ThreadStackHelper.h +++ b/xpcom/threads/ThreadStackHelper.h @@ -8,8 +8,7 @@ #define mozilla_ThreadStackHelper_h #include "mozilla/ThreadHangStats.h" - -#include "GeckoProfiler.h" +#include "js/ProfilingStack.h" #include @@ -79,7 +78,7 @@ private: void FillStackBuffer(); void FillThreadContext(void* aContext = nullptr); #ifdef MOZ_THREADSTACKHELPER_PSEUDO - const char* AppendJSEntry(const volatile StackEntry* aEntry, + const char* AppendJSEntry(const volatile js::ProfileEntry* aEntry, intptr_t& aAvailableBufferSize, const char* aPrevLabel); #endif