Bug 784859 - Part 3: Refactor TickCount64 to make its signature similar to GetTickCount64; r=bbondy
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 08 Sep 2012 14:12:14 -0400
changeset 104648 9b7184f6e154
parent 104647 2a8acb221714
child 104649 64ea34bc583e
push id14615
push usereakhgari@mozilla.com
push date2012-09-08 18:13 +0000
treeherdermozilla-inbound@d4a8c7efef04 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs784859
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 784859 - Part 3: Refactor TickCount64 to make its signature similar to GetTickCount64; r=bbondy
xpcom/ds/TimeStamp_windows.cpp
--- a/xpcom/ds/TimeStamp_windows.cpp
+++ b/xpcom/ds/TimeStamp_windows.cpp
@@ -408,18 +408,19 @@ InitResolution()
   sResolutionSigDigs = sigDigs;
 }
 
 // Function protecting GetTickCount result from rolling over, result is in [ms]
 // @param gtc
 // Result of GetTickCount().  Passing it as an arg lets us call it out
 // of the common mutex.
 static inline ULONGLONG
-TickCount64(DWORD now)
+TickCount64()
 {
+  DWORD now = GetTickCount();
   ULONGLONG lastResultHiPart = sLastGTCResult & (~0ULL << 32);
   ULONGLONG result = lastResultHiPart | ULONGLONG(now);
 
   // It may happen that when accessing GTC on multiple threads the results
   // may differ (GTC value may be lower due to running before the others
   // right around the overflow moment).  That falsely shifts the high part.
   // Easiest solution is to check for a significant difference.
 
@@ -560,24 +561,23 @@ CalibratedPerformanceCounter()
   // startup, really needs a better initation code here.
   StandbyObserver::Ensure();
 
   // Don't hold the lock over call to QueryPerformanceCounter, since it is
   // the largest bottleneck, let threads read the value concurently to have
   // possibly a better performance.
 
   ULONGLONG qpc = PerformanceCounter();
-  DWORD gtcw = GetTickCount();
 
   ULONGLONG result;
   {
   AutoCriticalSection lock(&sTimeStampLock);
 
   // Rollover protection
-  ULONGLONG gtc = TickCount64(gtcw);
+  ULONGLONG gtc = TickCount64();
 
   LONGLONG diff = qpc - ms2mt(gtc) - sSkew;
   LONGLONG overflow = 0;
 
   if (diff < sUnderrunThreshold) {
     overflow = sUnderrunThreshold - diff;
   }
   else if (diff > sOverrunThreshold) {
@@ -667,17 +667,17 @@ TimeStamp::Startup()
 
     LOG(("TimeStamp: using GetTickCount"));
     return NS_OK;
   }
 
   sFrequencyPerSec = freq.QuadPart;
 
   ULONGLONG qpc = PerformanceCounter();
-  sLastCalibrated = TickCount64(::GetTickCount());
+  sLastCalibrated = TickCount64();
   sSkew = qpc - ms2mt(sLastCalibrated);
 
   InitThresholds();
   InitResolution();
 
   sHasStableTSC = HasStableTSC();
 
   LOG(("TimeStamp: initial skew is %1.2fms", mt2ms_d(sSkew)));