Bug 1328378 (part 4) - Remove sample_obj. r=mstange.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 27 Feb 2017 12:32:55 +1100
changeset 374174 6c2a029b41ea26131a0abae7d6e304567ff2615a
parent 374173 6b7e1d039956e207ca24ebfc2629ebd3b6f3c3f0
child 374175 22974497e57e814c3119a30b483842c793067434
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1328378
milestone54.0a1
Bug 1328378 (part 4) - Remove sample_obj. r=mstange. It's silly indirection.
tools/profiler/core/platform-linux-android.cpp
tools/profiler/core/platform-macos.cpp
tools/profiler/core/platform-win32.cpp
--- a/tools/profiler/core/platform-linux-android.cpp
+++ b/tools/profiler/core/platform-linux-android.cpp
@@ -176,28 +176,27 @@ static void SetSampleContext(TickSample*
 }
 
 static void
 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;
 }
 
 #if defined(GP_OS_android)
 #define SYS_tgkill __NR_tgkill
 #endif
--- a/tools/profiler/core/platform-macos.cpp
+++ b/tools/profiler/core/platform-macos.cpp
@@ -185,25 +185,24 @@ public:
     }
   }
 
   void SampleContext(ThreadInfo* aThreadInfo, bool isFirstProfiledThread)
   {
     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
     // we're using on Linux) has less consistent performance and causes
     // strange crashes, see bug 1166778 and bug 1166808.
 
     if (KERN_SUCCESS != thread_suspend(profiled_thread)) return;
 
@@ -228,25 +227,25 @@ public:
 #else
 #error Unsupported Mac OS X host architecture.
 #endif  // GP_ARCH_*
 
     if (thread_get_state(profiled_thread,
                          flavor,
                          reinterpret_cast<natural_t*>(&state),
                          &count) == KERN_SUCCESS) {
-      sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip));
-      sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp));
-      sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp));
-      sample->timestamp = mozilla::TimeStamp::Now();
-      sample->threadInfo = aThreadInfo;
+      sample.pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip));
+      sample.sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp));
+      sample.fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp));
+      sample.timestamp = mozilla::TimeStamp::Now();
+      sample.threadInfo = aThreadInfo;
 
 #undef REGISTER_FIELD
 
-      Tick(sample);
+      Tick(&sample);
     }
     thread_resume(profiled_thread);
   }
 
 private:
   pthread_t mThread;
 
   int mIntervalMicro;
--- a/tools/profiler/core/platform-win32.cpp
+++ b/tools/profiler/core/platform-win32.cpp
@@ -197,31 +197,30 @@ class SamplerThread
     HANDLE profiled_thread = reinterpret_cast<HANDLE>(thread);
     if (profiled_thread == NULL)
       return;
 
     // Context used for sampling the register state of the profiled thread.
     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<DWORD>(-1);
     if (SuspendThread(profiled_thread) == kSuspendFailed)
       return;
 
     // SuspendThread is asynchronous, so the thread may still be running.
     // Call GetThreadContext first to ensure the thread is really suspended.
     // See https://blogs.msdn.microsoft.com/oldnewthing/20150205-00/?p=44743.
@@ -234,28 +233,28 @@ class SamplerThread
     context.ContextFlags = CONTEXT_CONTROL;
 #endif
     if (!GetThreadContext(profiled_thread, &context)) {
       ResumeThread(profiled_thread);
       return;
     }
 
 #if defined(GP_ARCH_amd64)
-    sample->pc = reinterpret_cast<Address>(context.Rip);
-    sample->sp = reinterpret_cast<Address>(context.Rsp);
-    sample->fp = reinterpret_cast<Address>(context.Rbp);
+    sample.pc = reinterpret_cast<Address>(context.Rip);
+    sample.sp = reinterpret_cast<Address>(context.Rsp);
+    sample.fp = reinterpret_cast<Address>(context.Rbp);
 #else
-    sample->pc = reinterpret_cast<Address>(context.Eip);
-    sample->sp = reinterpret_cast<Address>(context.Esp);
-    sample->fp = reinterpret_cast<Address>(context.Ebp);
+    sample.pc = reinterpret_cast<Address>(context.Eip);
+    sample.sp = reinterpret_cast<Address>(context.Esp);
+    sample.fp = reinterpret_cast<Address>(context.Ebp);
 #endif
 
-    sample->context = &context;
+    sample.context = &context;
 
-    Tick(sample);
+    Tick(&sample);
 
     ResumeThread(profiled_thread);
   }
 
 private:
   HANDLE mThread;
   Thread::tid_t mThreadId;