Changeset 202166 in webkit
- Timestamp:
- Jun 17, 2016 6:35:32 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r202162 r202166 1 2016-06-17 Andreas Kling <akling@apple.com> 2 3 [iOS] Throw away linked code when navigating to a new page. 4 <https://webkit.org/b/153851> 5 6 Reviewed by Antti Koivisto. 7 8 When navigating to a new page, tell JSC to throw out any linked code it has lying around. 9 Linked code is tied to a specific global object, and as we're creating a new one for the 10 new page, none of it is useful to us here. 11 12 In the event that the user navigates back, the cost of relinking some code will be far 13 lower than the memory cost of keeping all of it around. 14 15 This was in-tree before but was rolled out due to regressing JSBench. It was a slowdown 16 due to the benchmark harness using top-level navigations to drive the tests. 17 This new version avoids that problem by only throwing out code if we haven't navigated 18 in the last 2 seconds. This also prevents excessive work in response to redirects. 19 20 I've also moved this into MemoryPressureHandler so we don't make a mess in FrameLoader. 21 22 * loader/FrameLoader.cpp: 23 (WebCore::FrameLoader::commitProvisionalLoad): 24 * platform/MemoryPressureHandler.cpp: 25 (WebCore::MemoryPressureHandler::jettisonExpensiveObjectsOnTopLevelNavigation): 26 * platform/MemoryPressureHandler.h: 27 1 28 2016-06-17 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 29 -
trunk/Source/WebCore/loader/FrameLoader.cpp
r202139 r202166 1787 1787 // We are doing this here because we know for sure that a new page is about to be loaded. 1788 1788 PageCache::singleton().addIfCacheable(*history().currentItem(), m_frame.page()); 1789 1790 MemoryPressureHandler::singleton().jettisonExpensiveObjectsOnTopLevelNavigation(); 1789 1791 } 1790 1792 -
trunk/Source/WebCore/platform/MemoryPressureHandler.cpp
r202090 r202166 42 42 #include "WorkerThread.h" 43 43 #include <JavaScriptCore/IncrementalSweeper.h> 44 #include <chrono> 44 45 #include <wtf/CurrentTime.h> 45 46 #include <wtf/FastMalloc.h> … … 160 161 } 161 162 163 void MemoryPressureHandler::jettisonExpensiveObjectsOnTopLevelNavigation() 164 { 165 #if PLATFORM(IOS) 166 // Protect against doing excessive jettisoning during repeated navigations. 167 const auto minimumTimeSinceNavigation = 2s; 168 169 static auto timeOfLastNavigation = std::chrono::steady_clock::now(); 170 auto now = std::chrono::steady_clock::now(); 171 bool shouldJettison = now - timeOfLastNavigation >= minimumTimeSinceNavigation; 172 timeOfLastNavigation = now; 173 174 if (!shouldJettison) 175 return; 176 177 // Throw away linked JS code. Linked code is tied to a global object and is not reusable. 178 // The immediate memory savings outweigh the cost of recompilation in case we go back again. 179 GCController::singleton().deleteAllLinkedCode(); 180 #endif 181 } 182 162 183 void MemoryPressureHandler::releaseMemory(Critical critical, Synchronous synchronous) 163 184 { -
trunk/Source/WebCore/platform/MemoryPressureHandler.h
r202090 r202166 69 69 m_lowMemoryHandler = handler; 70 70 } 71 72 void jettisonExpensiveObjectsOnTopLevelNavigation(); 71 73 72 74 bool isUnderMemoryPressure() const { return m_underMemoryPressure; }
Note: See TracChangeset
for help on using the changeset viewer.