Changeset 243702 in webkit
- Timestamp:
- Apr 1, 2019, 11:33:45 AM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
runtime/JSRunLoopTimer.cpp (modified) (6 diffs)
-
runtime/JSRunLoopTimer.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r243700 r243702 1 2019-04-01 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] JSRunLoopTimer::Manager should be small 4 https://bugs.webkit.org/show_bug.cgi?id=196425 5 6 Reviewed by Darin Adler. 7 8 Using very large Key or Value in HashMap potentially bloats memory since HashMap pre-allocates large size of 9 memory ((sizeof(Key) + sizeof(Value)) * N) for its backing storage's array. Using std::unique_ptr<> for JSRunLoopTimer's 10 PerVMData to keep HashMap's backing store size small. 11 12 * runtime/JSRunLoopTimer.cpp: 13 (JSC::JSRunLoopTimer::Manager::timerDidFire): 14 (JSC::JSRunLoopTimer::Manager::registerVM): 15 (JSC::JSRunLoopTimer::Manager::scheduleTimer): 16 (JSC::JSRunLoopTimer::Manager::cancelTimer): 17 (JSC::JSRunLoopTimer::Manager::timeUntilFire): 18 (JSC::JSRunLoopTimer::Manager::didChangeRunLoop): 19 * runtime/JSRunLoopTimer.h: 20 1 21 2019-04-01 Stephan Szabo <stephan.szabo@sony.com> 2 22 -
trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp
r239427 r243702 122 122 EpochTime nowEpochTime = epochTime(0_s); 123 123 for (auto& entry : m_mapping) { 124 PerVMData& data = entry.value;124 PerVMData& data = *entry.value; 125 125 #if USE(CF) 126 126 if (data.runLoop.get() != currentRunLoop) … … 173 173 void JSRunLoopTimer::Manager::registerVM(VM& vm) 174 174 { 175 PerVMData data { *this };176 #if USE(CF) 177 data .setRunLoop(this, vm.runLoop());175 auto data = std::make_unique<PerVMData>(*this); 176 #if USE(CF) 177 data->setRunLoop(this, vm.runLoop()); 178 178 #endif 179 179 … … 200 200 RELEASE_ASSERT(iter != m_mapping.end()); // We don't allow calling this after the VM dies. 201 201 202 PerVMData& data = iter->value;202 PerVMData& data = *iter->value; 203 203 EpochTime scheduleTime = fireEpochTime; 204 204 bool found = false; … … 230 230 } 231 231 232 PerVMData& data = iter->value;232 PerVMData& data = *iter->value; 233 233 EpochTime scheduleTime = epochTime(s_decade); 234 234 for (unsigned i = 0; i < data.timers.size(); ++i) { … … 262 262 RELEASE_ASSERT(iter != m_mapping.end()); // We only allow this to be called with a live VM. 263 263 264 PerVMData& data = iter->value;264 PerVMData& data = *iter->value; 265 265 for (auto& entry : data.timers) { 266 266 if (entry.first.ptr() == &timer) { … … 280 280 RELEASE_ASSERT(iter != m_mapping.end()); 281 281 282 PerVMData& data = iter->value;282 PerVMData& data = *iter->value; 283 283 data.setRunLoop(this, newRunLoop); 284 284 } -
trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.h
r241923 r243702 79 79 80 80 struct PerVMData { 81 PerVMData() = default;82 81 #if USE(CF) 83 82 PerVMData(Manager&) { } … … 85 84 PerVMData(Manager&); 86 85 #endif 87 PerVMData(PerVMData&&) = default;88 PerVMData& operator=(PerVMData&&) = default;89 90 86 ~PerVMData(); 91 87 … … 102 98 }; 103 99 104 HashMap<Ref<JSLock>, PerVMData> m_mapping;100 HashMap<Ref<JSLock>, std::unique_ptr<PerVMData>> m_mapping; 105 101 }; 106 102
Note:
See TracChangeset
for help on using the changeset viewer.