From 54ff9e9a142d4b59bb5ba3af32f31404a14cd0fd Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 27 Feb 2017 12:32:55 +1100 Subject: [PATCH] Bug 1328378 (part 4) - Remove sample_obj. r=mstange. It's silly indirection. --HG-- extra : rebase_source : 6eb2f7c13d689db57e604f871372e98d06fea5a1 --- .../profiler/core/platform-linux-android.cpp | 17 +++++------ tools/profiler/core/platform-macos.cpp | 21 +++++++------- tools/profiler/core/platform-win32.cpp | 29 +++++++++---------- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/tools/profiler/core/platform-linux-android.cpp b/tools/profiler/core/platform-linux-android.cpp index bdb481dbe407..61ca9f94636e 100644 --- a/tools/profiler/core/platform-linux-android.cpp +++ b/tools/profiler/core/platform-linux-android.cpp @@ -181,18 +181,17 @@ SigprofHandler(int signal, siginfo_t* info, void* context) // Avoid TSan warning about clobbering errno. int savedErrno = errno; - TickSample sample_obj; - TickSample* sample = &sample_obj; - sample->context = context; + TickSample sample; + sample.context = context; // Extract the current pc and sp. - SetSampleContext(sample, context); - sample->threadInfo = gCurrentThreadInfo; - sample->timestamp = mozilla::TimeStamp::Now(); - sample->rssMemory = gRssMemory; - sample->ussMemory = gUssMemory; + SetSampleContext(&sample, context); + sample.threadInfo = gCurrentThreadInfo; + sample.timestamp = mozilla::TimeStamp::Now(); + sample.rssMemory = gRssMemory; + sample.ussMemory = gUssMemory; - Tick(sample); + Tick(&sample); sem_post(&gSignalHandlingDone); errno = savedErrno; diff --git a/tools/profiler/core/platform-macos.cpp b/tools/profiler/core/platform-macos.cpp index d2566e2faeb4..6e556b33081d 100644 --- a/tools/profiler/core/platform-macos.cpp +++ b/tools/profiler/core/platform-macos.cpp @@ -190,15 +190,14 @@ public: thread_act_t profiled_thread = aThreadInfo->GetPlatformData()->profiled_thread(); - TickSample sample_obj; - TickSample* sample = &sample_obj; + TickSample sample; // Unique Set Size is not supported on Mac. - sample->ussMemory = 0; - sample->rssMemory = 0; + sample.ussMemory = 0; + sample.rssMemory = 0; if (isFirstProfiledThread && gProfileMemory) { - sample->rssMemory = nsMemoryReporterManager::ResidentFast(); + sample.rssMemory = nsMemoryReporterManager::ResidentFast(); } // We're using thread_suspend on OS X because pthread_kill (which is what @@ -233,15 +232,15 @@ public: flavor, reinterpret_cast(&state), &count) == KERN_SUCCESS) { - sample->pc = reinterpret_cast
(state.REGISTER_FIELD(ip)); - sample->sp = reinterpret_cast
(state.REGISTER_FIELD(sp)); - sample->fp = reinterpret_cast
(state.REGISTER_FIELD(bp)); - sample->timestamp = mozilla::TimeStamp::Now(); - sample->threadInfo = aThreadInfo; + sample.pc = reinterpret_cast
(state.REGISTER_FIELD(ip)); + sample.sp = reinterpret_cast
(state.REGISTER_FIELD(sp)); + sample.fp = reinterpret_cast
(state.REGISTER_FIELD(bp)); + sample.timestamp = mozilla::TimeStamp::Now(); + sample.threadInfo = aThreadInfo; #undef REGISTER_FIELD - Tick(sample); + Tick(&sample); } thread_resume(profiled_thread); } diff --git a/tools/profiler/core/platform-win32.cpp b/tools/profiler/core/platform-win32.cpp index 26ed3bc50df6..3cbb1e7789b5 100644 --- a/tools/profiler/core/platform-win32.cpp +++ b/tools/profiler/core/platform-win32.cpp @@ -202,21 +202,20 @@ class SamplerThread CONTEXT context; memset(&context, 0, sizeof(context)); - TickSample sample_obj; - TickSample* sample = &sample_obj; + TickSample sample; // Grab the timestamp before pausing the thread, to avoid deadlocks. - sample->timestamp = mozilla::TimeStamp::Now(); - sample->threadInfo = aThreadInfo; + sample.timestamp = mozilla::TimeStamp::Now(); + sample.threadInfo = aThreadInfo; if (isFirstProfiledThread && gProfileMemory) { - sample->rssMemory = nsMemoryReporterManager::ResidentFast(); + sample.rssMemory = nsMemoryReporterManager::ResidentFast(); } else { - sample->rssMemory = 0; + sample.rssMemory = 0; } // Unique Set Size is not supported on Windows. - sample->ussMemory = 0; + sample.ussMemory = 0; static const DWORD kSuspendFailed = static_cast(-1); if (SuspendThread(profiled_thread) == kSuspendFailed) @@ -239,18 +238,18 @@ class SamplerThread } #if defined(GP_ARCH_amd64) - sample->pc = reinterpret_cast
(context.Rip); - sample->sp = reinterpret_cast
(context.Rsp); - sample->fp = reinterpret_cast
(context.Rbp); + sample.pc = reinterpret_cast
(context.Rip); + sample.sp = reinterpret_cast
(context.Rsp); + sample.fp = reinterpret_cast
(context.Rbp); #else - sample->pc = reinterpret_cast
(context.Eip); - sample->sp = reinterpret_cast
(context.Esp); - sample->fp = reinterpret_cast
(context.Ebp); + sample.pc = reinterpret_cast
(context.Eip); + sample.sp = reinterpret_cast
(context.Esp); + sample.fp = reinterpret_cast
(context.Ebp); #endif - sample->context = &context; + sample.context = &context; - Tick(sample); + Tick(&sample); ResumeThread(profiled_thread); }