[JSC] Remove monotonicallyIncreasingTime and currentTime
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Feb 2018 22:34:16 +0000 (22:34 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Feb 2018 22:34:16 +0000 (22:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182793

Reviewed by Saam Barati.

We would like to drop monotonicallyIncreasingTime and currentTime from our tree by
replacing them with MonotonicTime and WallTime, which are well-typed alternatives,
compared to double.
This patch removes monotonicallyIncreasingTime and currentTime in JSC.

* b3/testb3.cpp:
(JSC::B3::testComplex):
* dfg/DFGPhase.h:
(JSC::DFG::runAndLog):
* dfg/DFGPlan.cpp:
(JSC::DFG::Plan::compileInThread):
(JSC::DFG::Plan::compileInThreadImpl):
* dfg/DFGPlan.h:
* dynbench.cpp:
(JSC::benchmarkImpl):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::isPagedOut):
* heap/BlockDirectory.h:
* heap/FullGCActivityCallback.cpp:
(JSC::FullGCActivityCallback::doCollection):
* heap/Heap.cpp:
(JSC::Heap::isPagedOut):
(JSC::Heap::sweepSynchronously):
* heap/Heap.h:
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::isPagedOut):
* heap/MarkedSpace.h:
* inspector/agents/InspectorConsoleAgent.cpp:
(Inspector::InspectorConsoleAgent::startTiming):
(Inspector::InspectorConsoleAgent::stopTiming):
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
* jit/JIT.cpp:
(JSC::JIT::compileWithoutLinking):
(JSC::JIT::compileTimeStats):
* jit/JIT.h:
* jsc.cpp:
(StopWatch::start):
(StopWatch::stop):
(StopWatch::getElapsedMS):
(functionPreciseTime):
(runJSC):
* profiler/ProfilerDatabase.cpp:
(JSC::Profiler::Database::logEvent):
* profiler/ProfilerEvent.cpp:
(JSC::Profiler::Event::toJS const):
* profiler/ProfilerEvent.h:
(JSC::Profiler::Event::Event):
(JSC::Profiler::Event::time const):
* runtime/CodeCache.cpp:
(JSC::CodeCacheMap::pruneSlowCase):
* runtime/CodeCache.h:
(JSC::CodeCacheMap::CodeCacheMap):
(JSC::CodeCacheMap::prune):
* runtime/DateConstructor.cpp:
(JSC::callDate):
* runtime/TypeProfilerLog.cpp:
(JSC::TypeProfilerLog::processLogEntries):
* testRegExp.cpp:
(StopWatch::start):
(StopWatch::stop):
(StopWatch::getElapsedMS):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228533 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/b3/testb3.cpp
Source/JavaScriptCore/dfg/DFGPhase.h
Source/JavaScriptCore/dfg/DFGPlan.cpp
Source/JavaScriptCore/dfg/DFGPlan.h
Source/JavaScriptCore/dynbench.cpp
Source/JavaScriptCore/heap/BlockDirectory.cpp
Source/JavaScriptCore/heap/BlockDirectory.h
Source/JavaScriptCore/heap/FullGCActivityCallback.cpp
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/MarkedSpace.cpp
Source/JavaScriptCore/heap/MarkedSpace.h
Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
Source/JavaScriptCore/jit/JIT.cpp
Source/JavaScriptCore/jit/JIT.h
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/profiler/ProfilerDatabase.cpp
Source/JavaScriptCore/profiler/ProfilerEvent.cpp
Source/JavaScriptCore/profiler/ProfilerEvent.h
Source/JavaScriptCore/runtime/CodeCache.cpp
Source/JavaScriptCore/runtime/CodeCache.h
Source/JavaScriptCore/runtime/DateConstructor.cpp
Source/JavaScriptCore/runtime/TypeProfilerLog.cpp
Source/JavaScriptCore/testRegExp.cpp

index a2f7d63..8aff7af 100644 (file)
@@ -1,3 +1,74 @@
+2018-02-15  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Remove monotonicallyIncreasingTime and currentTime
+        https://bugs.webkit.org/show_bug.cgi?id=182793
+
+        Reviewed by Saam Barati.
+
+        We would like to drop monotonicallyIncreasingTime and currentTime from our tree by
+        replacing them with MonotonicTime and WallTime, which are well-typed alternatives,
+        compared to double.
+        This patch removes monotonicallyIncreasingTime and currentTime in JSC.
+
+        * b3/testb3.cpp:
+        (JSC::B3::testComplex):
+        * dfg/DFGPhase.h:
+        (JSC::DFG::runAndLog):
+        * dfg/DFGPlan.cpp:
+        (JSC::DFG::Plan::compileInThread):
+        (JSC::DFG::Plan::compileInThreadImpl):
+        * dfg/DFGPlan.h:
+        * dynbench.cpp:
+        (JSC::benchmarkImpl):
+        * heap/BlockDirectory.cpp:
+        (JSC::BlockDirectory::isPagedOut):
+        * heap/BlockDirectory.h:
+        * heap/FullGCActivityCallback.cpp:
+        (JSC::FullGCActivityCallback::doCollection):
+        * heap/Heap.cpp:
+        (JSC::Heap::isPagedOut):
+        (JSC::Heap::sweepSynchronously):
+        * heap/Heap.h:
+        * heap/MarkedSpace.cpp:
+        (JSC::MarkedSpace::isPagedOut):
+        * heap/MarkedSpace.h:
+        * inspector/agents/InspectorConsoleAgent.cpp:
+        (Inspector::InspectorConsoleAgent::startTiming):
+        (Inspector::InspectorConsoleAgent::stopTiming):
+        * inspector/agents/InspectorConsoleAgent.h:
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
+        * jit/JIT.cpp:
+        (JSC::JIT::compileWithoutLinking):
+        (JSC::JIT::compileTimeStats):
+        * jit/JIT.h:
+        * jsc.cpp:
+        (StopWatch::start):
+        (StopWatch::stop):
+        (StopWatch::getElapsedMS):
+        (functionPreciseTime):
+        (runJSC):
+        * profiler/ProfilerDatabase.cpp:
+        (JSC::Profiler::Database::logEvent):
+        * profiler/ProfilerEvent.cpp:
+        (JSC::Profiler::Event::toJS const):
+        * profiler/ProfilerEvent.h:
+        (JSC::Profiler::Event::Event):
+        (JSC::Profiler::Event::time const):
+        * runtime/CodeCache.cpp:
+        (JSC::CodeCacheMap::pruneSlowCase):
+        * runtime/CodeCache.h:
+        (JSC::CodeCacheMap::CodeCacheMap):
+        (JSC::CodeCacheMap::prune):
+        * runtime/DateConstructor.cpp:
+        (JSC::callDate):
+        * runtime/TypeProfilerLog.cpp:
+        (JSC::TypeProfilerLog::processLogEntries):
+        * testRegExp.cpp:
+        (StopWatch::start):
+        (StopWatch::stop):
+        (StopWatch::getElapsedMS):
+
 2018-02-14  Keith Miller  <keith_miller@apple.com>
 
         We should be able to jsDynamicCast from JSType when possible
index 0df3ca1..61e9ebd 100644 (file)
@@ -7963,7 +7963,7 @@ void testBranch8WithLoad8ZIndex()
 
 void testComplex(unsigned numVars, unsigned numConstructs)
 {
-    double before = monotonicallyIncreasingTimeMS();
+    MonotonicTime before = MonotonicTime::now();
     
     Procedure proc;
     BasicBlock* current = proc.addBlock();
@@ -8092,8 +8092,8 @@ void testComplex(unsigned numVars, unsigned numConstructs)
 
     compileProc(proc);
 
-    double after = monotonicallyIncreasingTimeMS();
-    dataLog(toCString("    That took ", after - before, " ms.\n"));
+    MonotonicTime after = MonotonicTime::now();
+    dataLog(toCString("    That took ", (after - before).milliseconds(), " ms.\n"));
 }
 
 void testSimplePatchpoint()
index 0fcfc5f..2d6180b 100644 (file)
@@ -76,16 +76,16 @@ private:
 template<typename PhaseType>
 bool runAndLog(PhaseType& phase)
 {
-    double before = 0;
+    MonotonicTime before { };
 
     if (UNLIKELY(Options::reportDFGPhaseTimes()))
-        before = monotonicallyIncreasingTimeMS();
+        before = MonotonicTime::now();
 
     bool result = phase.run();
 
     if (UNLIKELY(Options::reportDFGPhaseTimes())) {
-        double after = monotonicallyIncreasingTimeMS();
-        dataLogF("Phase %s took %.4f ms\n", phase.name(), after - before);
+        MonotonicTime after = MonotonicTime::now();
+        dataLogF("Phase %s took %.4f ms\n", phase.name(), (after - before).milliseconds());
     }
     if (result && logCompilationChanges(phase.graph().m_plan.mode))
         dataLogF("Phase %s changed the IR.\n", phase.name());
index ad95428..a571471 100644 (file)
 
 namespace JSC {
 
-extern double totalDFGCompileTime;
-extern double totalFTLCompileTime;
-extern double totalFTLDFGCompileTime;
-extern double totalFTLB3CompileTime;
+extern Seconds totalDFGCompileTime;
+extern Seconds totalFTLCompileTime;
+extern Seconds totalFTLDFGCompileTime;
+extern Seconds totalFTLB3CompileTime;
 
 }
 
@@ -173,10 +173,10 @@ void Plan::compileInThread(ThreadData* threadData)
 {
     this->threadData = threadData;
     
-    double before = 0;
+    MonotonicTime before { };
     CString codeBlockName;
     if (UNLIKELY(computeCompileTimes()))
-        before = monotonicallyIncreasingTimeMS();
+        before = MonotonicTime::now();
     if (UNLIKELY(reportCompileTimes()))
         codeBlockName = toCString(*codeBlock);
     
@@ -190,9 +190,9 @@ void Plan::compileInThread(ThreadData* threadData)
     RELEASE_ASSERT(path == CancelPath || finalizer);
     RELEASE_ASSERT((path == CancelPath) == (stage == Cancelled));
     
-    double after = 0;
+    MonotonicTime after { };
     if (UNLIKELY(computeCompileTimes())) {
-        after = monotonicallyIncreasingTimeMS();
+        after = MonotonicTime::now();
     
         if (Options::reportTotalCompileTimes()) {
             if (isFTL(mode)) {
@@ -223,14 +223,14 @@ void Plan::compileInThread(ThreadData* threadData)
     }
     if (codeBlock) { // codeBlock will be null if the compilation was cancelled.
         if (path == FTLPath)
-            CODEBLOCK_LOG_EVENT(codeBlock, "ftlCompile", ("took ", after - before, " ms (DFG: ", m_timeBeforeFTL - before, ", B3: ", after - m_timeBeforeFTL, ") with ", pathName));
+            CODEBLOCK_LOG_EVENT(codeBlock, "ftlCompile", ("took ", (after - before).milliseconds(), " ms (DFG: ", (m_timeBeforeFTL - before).milliseconds(), ", B3: ", (after - m_timeBeforeFTL).milliseconds(), ") with ", pathName));
         else
-            CODEBLOCK_LOG_EVENT(codeBlock, "dfgCompile", ("took ", after - before, " ms with ", pathName));
+            CODEBLOCK_LOG_EVENT(codeBlock, "dfgCompile", ("took ", (after - before).milliseconds(), " ms with ", pathName));
     }
     if (UNLIKELY(reportCompileTimes())) {
-        dataLog("Optimized ", codeBlockName, " using ", mode, " with ", pathName, " into ", finalizer ? finalizer->codeSize() : 0, " bytes in ", after - before, " ms");
+        dataLog("Optimized ", codeBlockName, " using ", mode, " with ", pathName, " into ", finalizer ? finalizer->codeSize() : 0, " bytes in ", (after - before).milliseconds(), " ms");
         if (path == FTLPath)
-            dataLog(" (DFG: ", m_timeBeforeFTL - before, ", B3: ", after - m_timeBeforeFTL, ")");
+            dataLog(" (DFG: ", (m_timeBeforeFTL - before).milliseconds(), ", B3: ", (after - m_timeBeforeFTL).milliseconds(), ")");
         dataLog(".\n");
     }
 }
@@ -491,7 +491,7 @@ Plan::CompilationPath Plan::compileInThreadImpl()
         FTL::lowerDFGToB3(state);
         
         if (UNLIKELY(computeCompileTimes()))
-            m_timeBeforeFTL = monotonicallyIncreasingTimeMS();
+            m_timeBeforeFTL = MonotonicTime::now();
         
         if (Options::b3AlwaysFailsBeforeCompile()) {
             FTL::fail(state);
index 2e23702..a868597 100644 (file)
@@ -125,7 +125,7 @@ private:
     bool isStillValid();
     void reallyAdd(CommonData*);
 
-    double m_timeBeforeFTL;
+    MonotonicTime m_timeBeforeFTL;
 };
 
 #endif // ENABLE(DFG_JIT)
index 16065db..f799068 100644 (file)
@@ -60,10 +60,10 @@ NEVER_INLINE void benchmarkImpl(const char* name, unsigned iterationCount, const
     if (requestedIterationCount)
         iterationCount = requestedIterationCount;
     
-    double before = monotonicallyIncreasingTimeMS();
+    MonotonicTime before = MonotonicTime::now();
     callback(iterationCount);
-    double after = monotonicallyIncreasingTimeMS();
-    dataLog(name, ": ", after - before, " ms.\n");
+    MonotonicTime after = MonotonicTime::now();
+    dataLog(name, ": ", (after - before).milliseconds(), " ms.\n");
 }
 
 } // anonymous namespace
index 8446077..cd8124d 100644 (file)
@@ -56,7 +56,7 @@ void BlockDirectory::setSubspace(Subspace* subspace)
     m_subspace = subspace;
 }
 
-bool BlockDirectory::isPagedOut(double deadline)
+bool BlockDirectory::isPagedOut(MonotonicTime deadline)
 {
     unsigned itersSinceLastTimeCheck = 0;
     for (auto* block : m_blocks) {
@@ -64,7 +64,7 @@ bool BlockDirectory::isPagedOut(double deadline)
             holdLock(block->block().lock());
         ++itersSinceLastTimeCheck;
         if (itersSinceLastTimeCheck >= Heap::s_timeCheckResolution) {
-            double currentTime = WTF::monotonicallyIncreasingTime();
+            MonotonicTime currentTime = MonotonicTime::now();
             if (currentTime > deadline)
                 return true;
             itersSinceLastTimeCheck = 0;
index e78db56..5960f53 100644 (file)
@@ -33,6 +33,7 @@
 #include "MarkedBlock.h"
 #include <wtf/DataLog.h>
 #include <wtf/FastBitVector.h>
+#include <wtf/MonotonicTime.h>
 #include <wtf/SharedTask.h>
 #include <wtf/Vector.h>
 
@@ -112,7 +113,7 @@ public:
     void addBlock(MarkedBlock::Handle*);
     void removeBlock(MarkedBlock::Handle*);
 
-    bool isPagedOut(double deadline);
+    bool isPagedOut(MonotonicTime deadline);
     
     Lock& bitvectorLock() { return m_bitvectorLock; }
 
index ffd63b0..d998a29 100644 (file)
@@ -31,7 +31,7 @@
 namespace JSC {
 
 #if !PLATFORM(IOS)
-const double pagingTimeOut = 0.1; // Time in seconds to allow opportunistic timer to iterate over all blocks to see if the Heap is paged out.
+const constexpr Seconds pagingTimeOut { 100_ms }; // Time in seconds to allow opportunistic timer to iterate over all blocks to see if the Heap is paged out.
 #endif
 
 FullGCActivityCallback::FullGCActivityCallback(Heap* heap)
@@ -45,10 +45,10 @@ void FullGCActivityCallback::doCollection()
     m_didGCRecently = false;
 
 #if !PLATFORM(IOS)
-    double startTime = WTF::monotonicallyIncreasingTime();
+    MonotonicTime startTime = MonotonicTime::now();
     if (heap.isPagedOut(startTime + pagingTimeOut)) {
         cancel();
-        heap.increaseLastFullGCLength(Seconds(pagingTimeOut));
+        heap.increaseLastFullGCLength(pagingTimeOut);
         return;
     }
 #endif
index 1cd041e..dd1e573 100644 (file)
@@ -196,7 +196,7 @@ public:
         , m_name(name)
     {
         if (measurePhaseTiming())
-            m_before = monotonicallyIncreasingTimeMS();
+            m_before = MonotonicTime::now();
     }
     
     TimingScope(Heap& heap, const char* name)
@@ -217,16 +217,16 @@ public:
     ~TimingScope()
     {
         if (measurePhaseTiming()) {
-            double after = monotonicallyIncreasingTimeMS();
-            double timing = after - m_before;
+            MonotonicTime after = MonotonicTime::now();
+            Seconds timing = after - m_before;
             SimpleStats& stats = timingStats(m_name, *m_scope);
-            stats.add(timing);
-            dataLog("[GC:", *m_scope, "] ", m_name, " took: ", timing, "ms (average ", stats.mean(), "ms).\n");
+            stats.add(timing.milliseconds());
+            dataLog("[GC:", *m_scope, "] ", m_name, " took: ", timing.milliseconds(), "ms (average ", stats.mean(), "ms).\n");
         }
     }
 private:
     std::optional<CollectionScope> m_scope;
-    double m_before;
+    MonotonicTime m_before;
     const char* m_name;
 };
 
@@ -362,7 +362,7 @@ Heap::~Heap()
         WeakBlock::destroy(*this, block);
 }
 
-bool Heap::isPagedOut(double deadline)
+bool Heap::isPagedOut(MonotonicTime deadline)
 {
     return m_objectSpace.isPagedOut(deadline);
 }
@@ -1006,16 +1006,16 @@ void Heap::addToRememberedSet(const JSCell* constCell)
 
 void Heap::sweepSynchronously()
 {
-    double before = 0;
+    MonotonicTime before { };
     if (Options::logGC()) {
         dataLog("Full sweep: ", capacity() / 1024, "kb ");
-        before = currentTimeMS();
+        before = MonotonicTime::now();
     }
     m_objectSpace.sweep();
     m_objectSpace.shrink();
     if (Options::logGC()) {
-        double after = currentTimeMS();
-        dataLog("=> ", capacity() / 1024, "kb, ", after - before, "ms");
+        MonotonicTime after = MonotonicTime::now();
+        dataLog("=> ", capacity() / 1024, "kb, ", (after - before).milliseconds(), "ms");
     }
 }
 
index a08471b..5b51da5 100644 (file)
@@ -257,7 +257,7 @@ public:
     void deleteAllUnlinkedCodeBlocks(DeleteAllCodeEffort);
 
     void didAllocate(size_t);
-    bool isPagedOut(double deadline);
+    bool isPagedOut(MonotonicTime deadline);
     
     const JITStubRoutineSet& jitStubRoutines() { return *m_jitStubRoutines; }
     
index e49b80c..9721664 100644 (file)
@@ -347,7 +347,7 @@ void MarkedSpace::resumeAllocating()
     // Nothing to do for LargeAllocations.
 }
 
-bool MarkedSpace::isPagedOut(double deadline)
+bool MarkedSpace::isPagedOut(MonotonicTime deadline)
 {
     bool result = false;
     forEachDirectory(
index 9cd7e76..5774128 100644 (file)
@@ -142,7 +142,7 @@ public:
     size_t size();
     size_t capacity();
 
-    bool isPagedOut(double deadline);
+    bool isPagedOut(MonotonicTime deadline);
     
     HeapVersion markingVersion() const { return m_markingVersion; }
     HeapVersion newlyAllocatedVersion() const { return m_newlyAllocatedVersion; }
index 5c3bf7d..1941175 100644 (file)
@@ -138,7 +138,7 @@ void InspectorConsoleAgent::startTiming(const String& title)
     if (title.isNull())
         return;
 
-    auto result = m_times.add(title, monotonicallyIncreasingTime());
+    auto result = m_times.add(title, MonotonicTime::now());
 
     if (!result.isNewEntry) {
         // FIXME: Send an enum to the frontend for localization?
@@ -161,11 +161,11 @@ void InspectorConsoleAgent::stopTiming(const String& title, Ref<ScriptCallStack>
         return;
     }
 
-    double startTime = it->value;
+    MonotonicTime startTime = it->value;
     m_times.remove(it);
 
-    double elapsed = monotonicallyIncreasingTime() - startTime;
-    String message = title + String::format(": %.3fms", elapsed * 1000);
+    Seconds elapsed = MonotonicTime::now() - startTime;
+    String message = title + String::format(": %.3fms", elapsed.milliseconds());
     addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(callStack)));
 }
 
index a1cf6a2..f1bcc6a 100644 (file)
@@ -30,6 +30,7 @@
 #include "InspectorFrontendDispatchers.h"
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
+#include <wtf/MonotonicTime.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/Vector.h>
 #include <wtf/text/StringHash.h>
@@ -86,7 +87,7 @@ protected:
     Vector<std::unique_ptr<ConsoleMessage>> m_consoleMessages;
     int m_expiredConsoleMessageCount { 0 };
     HashMap<String, unsigned> m_counts;
-    HashMap<String, double> m_times;
+    HashMap<String, MonotonicTime> m_times;
     bool m_enabled { false };
 };
 
index b07aa74..954322d 100644 (file)
@@ -286,7 +286,7 @@ void InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets(ErrorString& er
         return;
     }
 
-    double start = currentTimeMS();
+    MonotonicTime start = MonotonicTime::now();
     m_vm.typeProfilerLog()->processLogEntries(ASCIILiteral("User Query"));
 
     for (size_t i = 0; i < locations.length(); i++) {
@@ -331,9 +331,9 @@ void InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets(ErrorString& er
         typeDescriptions->addItem(WTFMove(description));
     }
 
-    double end = currentTimeMS();
+    MonotonicTime end = MonotonicTime::now();
     if (verbose)
-        dataLogF("Inspector::getRuntimeTypesForVariablesAtOffsets took %lfms\n", end - start);
+        dataLogF("Inspector::getRuntimeTypesForVariablesAtOffsets took %lfms\n", (end - start).milliseconds());
 }
 
 void InspectorRuntimeAgent::willDestroyFrontendAndBackend(DisconnectReason reason)
index 77d40a7..f493266 100644 (file)
@@ -58,11 +58,11 @@ using namespace std;
 
 namespace JSC {
 
-double totalBaselineCompileTime;
-double totalDFGCompileTime;
-double totalFTLCompileTime;
-double totalFTLDFGCompileTime;
-double totalFTLB3CompileTime;
+Seconds totalBaselineCompileTime;
+Seconds totalDFGCompileTime;
+Seconds totalFTLCompileTime;
+Seconds totalFTLDFGCompileTime;
+Seconds totalFTLB3CompileTime;
 
 void ctiPatchCallByReturnAddress(ReturnAddressPtr returnAddress, FunctionPtr newCalleeFunction)
 {
@@ -589,9 +589,9 @@ void JIT::privateCompileSlowCases()
 
 void JIT::compileWithoutLinking(JITCompilationEffort effort)
 {
-    double before = 0;
+    MonotonicTime before { };
     if (UNLIKELY(computeCompileTimes()))
-        before = monotonicallyIncreasingTimeMS();
+        before = MonotonicTime::now();
     
     {
         ConcurrentJSLocker locker(m_codeBlock->m_lock);
@@ -745,9 +745,9 @@ void JIT::compileWithoutLinking(JITCompilationEffort effort)
 
     m_linkBuffer = std::unique_ptr<LinkBuffer>(new LinkBuffer(*this, m_codeBlock, effort));
 
-    double after = 0;
+    MonotonicTime after { };
     if (UNLIKELY(computeCompileTimes())) {
-        after = monotonicallyIncreasingTimeMS();
+        after = MonotonicTime::now();
 
         if (Options::reportTotalCompileTimes())
             totalBaselineCompileTime += after - before;
@@ -755,7 +755,7 @@ void JIT::compileWithoutLinking(JITCompilationEffort effort)
     if (UNLIKELY(reportCompileTimes())) {
         CString codeBlockName = toCString(*m_codeBlock);
         
-        dataLog("Optimized ", codeBlockName, " with Baseline JIT into ", m_linkBuffer->size(), " bytes in ", after - before, " ms.\n");
+        dataLog("Optimized ", codeBlockName, " with Baseline JIT into ", m_linkBuffer->size(), " bytes in ", (after - before).milliseconds(), " ms.\n");
     }
 }
 
@@ -964,9 +964,9 @@ bool JIT::computeCompileTimes()
     return reportCompileTimes() || Options::reportTotalCompileTimes();
 }
 
-HashMap<CString, double> JIT::compileTimeStats()
+HashMap<CString, Seconds> JIT::compileTimeStats()
 {
-    HashMap<CString, double> result;
+    HashMap<CString, Seconds> result;
     if (Options::reportTotalCompileTimes()) {
         result.add("Total Compile Time", totalBaselineCompileTime + totalDFGCompileTime + totalFTLCompileTime);
         result.add("Baseline Compile Time", totalBaselineCompileTime);
index b61874e..6d4317f 100644 (file)
@@ -249,7 +249,7 @@ namespace JSC {
         static unsigned frameRegisterCountFor(CodeBlock*);
         static int stackPointerOffsetFor(CodeBlock*);
 
-        JS_EXPORT_PRIVATE static HashMap<CString, double> compileTimeStats();
+        JS_EXPORT_PRIVATE static HashMap<CString, Seconds> compileTimeStats();
 
     private:
         void privateCompileMainPass();
index 9607262..0602e4d 100644 (file)
 #include <thread>
 #include <type_traits>
 #include <wtf/CommaPrinter.h>
-#include <wtf/CurrentTime.h>
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/StringPrintStream.h>
+#include <wtf/WallTime.h>
 #include <wtf/text/StringBuilder.h>
 
 #if OS(WINDOWS)
@@ -409,23 +409,23 @@ public:
     long getElapsedMS(); // call stop() first
 
 private:
-    double m_startTime;
-    double m_stopTime;
+    MonotonicTime m_startTime;
+    MonotonicTime m_stopTime;
 };
 
 void StopWatch::start()
 {
-    m_startTime = monotonicallyIncreasingTime();
+    m_startTime = MonotonicTime::now();
 }
 
 void StopWatch::stop()
 {
-    m_stopTime = monotonicallyIncreasingTime();
+    m_stopTime = MonotonicTime::now();
 }
 
 long StopWatch::getElapsedMS()
 {
-    return static_cast<long>((m_stopTime - m_startTime) * 1000);
+    return (m_stopTime - m_startTime).millisecondsAs<long>();
 }
 
 template<typename Vector>
@@ -1377,7 +1377,7 @@ EncodedJSValue JSC_HOST_CALL functionReadline(ExecState* exec)
 
 EncodedJSValue JSC_HOST_CALL functionPreciseTime(ExecState*)
 {
-    return JSValue::encode(jsNumber(currentTime()));
+    return JSValue::encode(jsNumber(WallTime::now().secondsSinceEpoch().value()));
 }
 
 EncodedJSValue JSC_HOST_CALL functionNeverInlineFunction(ExecState* exec)
@@ -2649,7 +2649,7 @@ int runJSC(CommandLine options, bool isWorker, const Func& func)
             compileTimeKeys.append(entry.key);
         std::sort(compileTimeKeys.begin(), compileTimeKeys.end());
         for (CString key : compileTimeKeys)
-            printf("%40s: %.3lf ms\n", key.data(), compileTimeStats.get(key));
+            printf("%40s: %.3lf ms\n", key.data(), compileTimeStats.get(key).milliseconds());
     }
 #endif
 
index 8c8a53a..d2823b5 100644 (file)
@@ -181,7 +181,7 @@ void Database::logEvent(CodeBlock* codeBlock, const char* summary, const CString
     
     Bytecodes* bytecodes = ensureBytecodesFor(locker, codeBlock);
     Compilation* compilation = m_compilationMap.get(codeBlock);
-    m_events.append(Event(currentTime(), bytecodes, compilation, summary, detail));
+    m_events.append(Event(WallTime::now(), bytecodes, compilation, summary, detail));
 }
 
 void Database::addDatabaseToAtExit()
index 1a719d7..63f68b6 100644 (file)
@@ -49,7 +49,7 @@ JSValue Event::toJS(ExecState* exec) const
     VM& vm = exec->vm();
     JSObject* result = constructEmptyObject(exec);
     
-    result->putDirect(vm, vm.propertyNames->time, jsNumber(m_time));
+    result->putDirect(vm, vm.propertyNames->time, jsNumber(m_time.secondsSinceEpoch().value()));
     result->putDirect(vm, vm.propertyNames->bytecodesID, jsNumber(m_bytecodes->id()));
     if (m_compilation)
         result->putDirect(vm, vm.propertyNames->compilationUID, m_compilation->uid().toJS(exec));
index 11cb6da..d2b6da6 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "JSCJSValue.h"
 #include <wtf/PrintStream.h>
+#include <wtf/WallTime.h>
 #include <wtf/text/CString.h>
 
 namespace JSC { namespace Profiler {
@@ -40,7 +41,7 @@ public:
     {
     }
     
-    Event(double time, Bytecodes* bytecodes, Compilation* compilation, const char* summary, const CString& detail)
+    Event(WallTime time, Bytecodes* bytecodes, Compilation* compilation, const char* summary, const CString& detail)
         : m_time(time)
         , m_bytecodes(bytecodes)
         , m_compilation(compilation)
@@ -54,7 +55,7 @@ public:
         return m_bytecodes;
     }
     
-    double time() const { return m_time; }
+    WallTime time() const { return m_time; }
     Bytecodes* bytecodes() const { return m_bytecodes; }
     Compilation* compilation() const { return m_compilation; }
     const char* summary() const { return m_summary; }
@@ -64,7 +65,7 @@ public:
     JSValue toJS(ExecState*) const;
     
 private:
-    double m_time { 0 };
+    WallTime m_time { };
     Bytecodes* m_bytecodes { nullptr };
     Compilation* m_compilation { nullptr };
     const char* m_summary { nullptr };
index 6c1c0c0..ad25439 100644 (file)
 
 namespace JSC {
 
-const double CodeCacheMap::workingSetTime = 10.0;
+const Seconds CodeCacheMap::workingSetTime = 10_s;
 
 void CodeCacheMap::pruneSlowCase()
 {
     m_minCapacity = std::max(m_size - m_sizeAtLastPrune, static_cast<int64_t>(0));
     m_sizeAtLastPrune = m_size;
-    m_timeAtLastPrune = monotonicallyIncreasingTime();
+    m_timeAtLastPrune = MonotonicTime::now();
 
     if (m_capacity < m_minCapacity)
         m_capacity = m_minCapacity;
index b03bb2d..4fb5bd1 100644 (file)
@@ -83,7 +83,7 @@ public:
     CodeCacheMap()
         : m_size(0)
         , m_sizeAtLastPrune(0)
-        , m_timeAtLastPrune(monotonicallyIncreasingTime())
+        , m_timeAtLastPrune(MonotonicTime::now())
         , m_minCapacity(0)
         , m_capacity(0)
         , m_age(0)
@@ -149,7 +149,7 @@ public:
 private:
     // This constant factor biases cache capacity toward allowing a minimum
     // working set to enter the cache before it starts evicting.
-    static const double workingSetTime;
+    static const Seconds workingSetTime;
     static const int64_t workingSetMaxBytes = 16000000;
     static const size_t workingSetMaxEntries = 2000;
 
@@ -171,7 +171,7 @@ private:
         if (m_size <= m_capacity && canPruneQuickly())
             return;
 
-        if (monotonicallyIncreasingTime() - m_timeAtLastPrune < workingSetTime
+        if (MonotonicTime::now() - m_timeAtLastPrune < workingSetTime
             && m_size - m_sizeAtLastPrune < workingSetMaxBytes
             && canPruneQuickly())
                 return;
@@ -182,7 +182,7 @@ private:
     MapType m_map;
     int64_t m_size;
     int64_t m_sizeAtLastPrune;
-    double m_timeAtLastPrune;
+    MonotonicTime m_timeAtLastPrune;
     int64_t m_minCapacity;
     int64_t m_capacity;
     int64_t m_age;
index 679965c..61a5952 100644 (file)
@@ -161,7 +161,7 @@ static EncodedJSValue JSC_HOST_CALL callDate(ExecState* exec)
 {
     VM& vm = exec->vm();
     GregorianDateTime ts;
-    msToGregorianDateTime(vm, currentTimeMS(), WTF::LocalTime, ts);
+    msToGregorianDateTime(vm, WallTime::now().secondsSinceEpoch().milliseconds(), WTF::LocalTime, ts);
     return JSValue::encode(jsNontrivialString(&vm, formatDateTime(ts, DateTimeFormatDateAndTime, false)));
 }
 
index 727bbb9..ff0a761 100644 (file)
@@ -57,10 +57,10 @@ TypeProfilerLog::~TypeProfilerLog()
 
 void TypeProfilerLog::processLogEntries(const String& reason)
 {
-    double before = 0;
+    MonotonicTime before { };
     if (TypeProfilerLogInternal::verbose) {
         dataLog("Process caller:'", reason, "'");
-        before = currentTimeMS();
+        before = MonotonicTime::now();
     }
 
     HashMap<Structure*, RefPtr<StructureShape>> cachedMonoProtoShapes;
@@ -114,8 +114,8 @@ void TypeProfilerLog::processLogEntries(const String& reason)
     m_currentLogEntryPtr = m_logStartPtr;
 
     if (TypeProfilerLogInternal::verbose) {
-        double after = currentTimeMS();
-        dataLogF(" Processing the log took: '%f' ms\n", after - before);
+        MonotonicTime after = MonotonicTime::now();
+        dataLogF(" Processing the log took: '%f' ms\n", (after - before).milliseconds());
     }
 }
 
index 63ec7f6..e438f56 100644 (file)
@@ -70,23 +70,23 @@ public:
     long getElapsedMS(); // call stop() first
 
 private:
-    double m_startTime;
-    double m_stopTime;
+    MonotonicTime m_startTime;
+    MonotonicTime m_stopTime;
 };
 
 void StopWatch::start()
 {
-    m_startTime = monotonicallyIncreasingTime();
+    m_startTime = MonotonicTime::now();
 }
 
 void StopWatch::stop()
 {
-    m_stopTime = monotonicallyIncreasingTime();
+    m_stopTime = MonotonicTime::now();
 }
 
 long StopWatch::getElapsedMS()
 {
-    return static_cast<long>((m_stopTime - m_startTime) * 1000);
+    return (m_stopTime - m_startTime).millisecondsAs<long>();
 }
 
 struct RegExpTest {