Certain WebProcesses should opt-out of the freezer.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2019 03:00:44 +0000 (03:00 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2019 03:00:44 +0000 (03:00 +0000)
commit088563dcb3492986b2c80265a726f4151d137a33
tree89fff9998acf1ba8e1cbb05423c698cebb9304d9
parent9442c1624fc5ae1c05906d4842e0dae1495025dd
Certain WebProcesses should opt-out of the freezer.
<rdar://problem/42846139> and https://bugs.webkit.org/show_bug.cgi?id=196062

Reviewed by Andy Estes.

Source/bmalloc:

* bmalloc.xcodeproj/project.pbxproj:
* bmalloc/darwin/MemoryStatusSPI.h:

Source/WebKit:

WebProcesses should opt-in and opt-out of the freezer as is appropriate.
By default a WebProcess is freezer eligible.
If any of the following become true then it should become ineligible:
- The WebProcess is a pre-warmed process.
- The WebProcess is in the process cache.
- The WebProcess is not actively hosting any web pages (e.g. it only has suspending web pages)

The most complicated part of the above is guaranteeing that any operation that changes
the active pages hosted by the process causes a recalculation of the freezer opt-in state.

To do that this replaces the basic WebPageProxyMap with a custom class.

* UIProcess/WebProcessProxy.cpp:
(WebKit::globalPageMap):
(WebKit::WebProcessProxy::WebProcessProxy):
(WebKit::WebProcessProxy::validateFreezerStatus):
(WebKit::WebProcessProxy::setIsInProcessCache):
(WebKit::WebProcessProxy::markIsNoLongerInPrewarmedPool):
(WebKit::WebProcessProxy::didFinishLaunching):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::WebPageProxyMap::WebPageProxyMap):
(WebKit::WebProcessProxy::WebPageProxyMap::size const):
(WebKit::WebProcessProxy::WebPageProxyMap::values):
(WebKit::WebProcessProxy::WebPageProxyMap::values const):
(WebKit::WebProcessProxy::WebPageProxyMap::begin):
(WebKit::WebProcessProxy::WebPageProxyMap::end):
(WebKit::WebProcessProxy::WebPageProxyMap::get):
(WebKit::WebProcessProxy::WebPageProxyMap::contains const):
(WebKit::WebProcessProxy::WebPageProxyMap::isEmpty const):
(WebKit::WebProcessProxy::WebPageProxyMap::set):
(WebKit::WebProcessProxy::WebPageProxyMap::take):

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::setFreezable):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessProxy.h
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Source/WebKit/WebProcess/WebProcess.messages.in
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
Source/bmalloc/bmalloc/darwin/MemoryStatusSPI.h