Title: [243702] trunk/Source/_javascript_Core
Revision
243702
Author
[email protected]
Date
2019-04-01 11:33:45 -0700 (Mon, 01 Apr 2019)

Log Message

[JSC] JSRunLoopTimer::Manager should be small
https://bugs.webkit.org/show_bug.cgi?id=196425

Reviewed by Darin Adler.

Using very large Key or Value in HashMap potentially bloats memory since HashMap pre-allocates large size of
memory ((sizeof(Key) + sizeof(Value)) * N) for its backing storage's array. Using std::unique_ptr<> for JSRunLoopTimer's
PerVMData to keep HashMap's backing store size small.

* runtime/JSRunLoopTimer.cpp:
(JSC::JSRunLoopTimer::Manager::timerDidFire):
(JSC::JSRunLoopTimer::Manager::registerVM):
(JSC::JSRunLoopTimer::Manager::scheduleTimer):
(JSC::JSRunLoopTimer::Manager::cancelTimer):
(JSC::JSRunLoopTimer::Manager::timeUntilFire):
(JSC::JSRunLoopTimer::Manager::didChangeRunLoop):
* runtime/JSRunLoopTimer.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (243701 => 243702)


--- trunk/Source/_javascript_Core/ChangeLog	2019-04-01 18:33:04 UTC (rev 243701)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-04-01 18:33:45 UTC (rev 243702)
@@ -1,3 +1,23 @@
+2019-04-01  Yusuke Suzuki  <[email protected]>
+
+        [JSC] JSRunLoopTimer::Manager should be small
+        https://bugs.webkit.org/show_bug.cgi?id=196425
+
+        Reviewed by Darin Adler.
+
+        Using very large Key or Value in HashMap potentially bloats memory since HashMap pre-allocates large size of
+        memory ((sizeof(Key) + sizeof(Value)) * N) for its backing storage's array. Using std::unique_ptr<> for JSRunLoopTimer's
+        PerVMData to keep HashMap's backing store size small.
+
+        * runtime/JSRunLoopTimer.cpp:
+        (JSC::JSRunLoopTimer::Manager::timerDidFire):
+        (JSC::JSRunLoopTimer::Manager::registerVM):
+        (JSC::JSRunLoopTimer::Manager::scheduleTimer):
+        (JSC::JSRunLoopTimer::Manager::cancelTimer):
+        (JSC::JSRunLoopTimer::Manager::timeUntilFire):
+        (JSC::JSRunLoopTimer::Manager::didChangeRunLoop):
+        * runtime/JSRunLoopTimer.h:
+
 2019-04-01  Stephan Szabo  <[email protected]>
 
         [PlayStation] Add initialization for JSC shell for PlayStation port

Modified: trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.cpp (243701 => 243702)


--- trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.cpp	2019-04-01 18:33:04 UTC (rev 243701)
+++ trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.cpp	2019-04-01 18:33:45 UTC (rev 243702)
@@ -121,7 +121,7 @@
 #endif
         EpochTime nowEpochTime = epochTime(0_s);
         for (auto& entry : m_mapping) {
-            PerVMData& data = ""
+            PerVMData& data = ""
 #if USE(CF)
             if (data.runLoop.get() != currentRunLoop)
                 continue;
@@ -172,9 +172,9 @@
 
 void JSRunLoopTimer::Manager::registerVM(VM& vm)
 {
-    PerVMData data { *this };
+    auto data = ""
 #if USE(CF)
-    data.setRunLoop(this, vm.runLoop());
+    data->setRunLoop(this, vm.runLoop());
 #endif
 
     auto locker = holdLock(m_lock);
@@ -199,7 +199,7 @@
     auto iter = m_mapping.find(timer.m_apiLock);
     RELEASE_ASSERT(iter != m_mapping.end()); // We don't allow calling this after the VM dies.
 
-    PerVMData& data = ""
+    PerVMData& data = ""
     EpochTime scheduleTime = fireEpochTime;
     bool found = false;
     for (auto& entry : data.timers) {
@@ -229,7 +229,7 @@
         return;
     }
 
-    PerVMData& data = ""
+    PerVMData& data = ""
     EpochTime scheduleTime = epochTime(s_decade);
     for (unsigned i = 0; i < data.timers.size(); ++i) {
         {
@@ -261,7 +261,7 @@
     auto iter = m_mapping.find(timer.m_apiLock);
     RELEASE_ASSERT(iter != m_mapping.end()); // We only allow this to be called with a live VM.
 
-    PerVMData& data = ""
+    PerVMData& data = ""
     for (auto& entry : data.timers) {
         if (entry.first.ptr() == &timer) {
             EpochTime nowEpochTime = epochTime(0_s);
@@ -279,7 +279,7 @@
     auto iter = m_mapping.find({ vm.apiLock() });
     RELEASE_ASSERT(iter != m_mapping.end());
 
-    PerVMData& data = ""
+    PerVMData& data = ""
     data.setRunLoop(this, newRunLoop);
 }
 #endif

Modified: trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.h (243701 => 243702)


--- trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.h	2019-04-01 18:33:04 UTC (rev 243701)
+++ trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.h	2019-04-01 18:33:45 UTC (rev 243702)
@@ -78,15 +78,11 @@
         Lock m_lock;
 
         struct PerVMData {
-            PerVMData() = default;
 #if USE(CF)
             PerVMData(Manager&) { }
 #else
             PerVMData(Manager&);
 #endif
-            PerVMData(PerVMData&&) = default;
-            PerVMData& operator=(PerVMData&&) = default;
-
             ~PerVMData();
 
 #if USE(CF)
@@ -101,7 +97,7 @@
             Vector<std::pair<Ref<JSRunLoopTimer>, EpochTime>> timers;
         };
 
-        HashMap<Ref<JSLock>, PerVMData> m_mapping;
+        HashMap<Ref<JSLock>, std::unique_ptr<PerVMData>> m_mapping;
     };
 
     JSRunLoopTimer(VM*);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to