Bug 1371261 - ScriptLoader: Work-around the lack of Epoch from TimeStamp class. r=mrbkap
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Fri, 09 Jun 2017 13:52:52 +0000
changeset 411372 eb644e17a1a425060663da2c2196084ca6fb47de
parent 411371 35d8d330b97d94eb1885400b674661d49823f39a
child 411373 46707f69b3aa27a874881824d782f8e8099c472b
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1371261
milestone55.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 1371261 - ScriptLoader: Work-around the lack of Epoch from TimeStamp class. r=mrbkap
dom/script/ScriptLoader.cpp
--- a/dom/script/ScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -1983,25 +1983,25 @@ ScriptLoader::ShouldCacheBytecode(Script
 
   // Check that the cache entry got accessed recently, before caching it.
   if (hasTimeSinceLastFetched) {
     uint32_t lastFetched = 0;
     if (NS_FAILED(aRequest->mCacheInfo->GetCacheTokenLastFetched(&lastFetched))) {
       LOG(("ScriptLoadRequest (%p): Bytecode-cache: Cannot get lastFetched.", aRequest));
       return false;
     }
-    TimeStamp now = TimeStamp::NowLoRes();
-    TimeStamp last = TimeStamp() + TimeDuration::FromSeconds(lastFetched);
-    if (now < last) {
+    uint32_t now = PR_Now() / PR_USEC_PER_SEC;
+    if (now < lastFetched) {
       LOG(("ScriptLoadRequest (%p): Bytecode-cache: (What?) lastFetched set in the future.", aRequest));
       return false;
     }
+    TimeDuration since = TimeDuration::FromSeconds(now - lastFetched);
     LOG(("ScriptLoadRequest (%p): Bytecode-cache: lastFetched = %f sec. ago.",
-         aRequest, (now - last).ToSeconds()));
-    if (now - last >= timeSinceLastFetched) {
+         aRequest, since.ToSeconds()));
+    if (since >= timeSinceLastFetched) {
       return false;
     }
   }
 
   LOG(("ScriptLoadRequest (%p): Bytecode-cache: Trigger encoding.", aRequest));
   return true;
 }