[bmalloc] Add IsoHeap test to ensure that IsoHeap pages are not allocating too large VA
authorysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2019 03:42:09 +0000 (03:42 +0000)
committerysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2019 03:42:09 +0000 (03:42 +0000)
commit0e8e45102f38fb2727c0bca8a5aab780b5cb6e45
treecf09a6f261c7bc7046cb2aae0138f6ab1095685f
parentaed155079b7c6e13a3d01de9760d0381aa159255
[bmalloc] Add IsoHeap test to ensure that IsoHeap pages are not allocating too large VA
https://bugs.webkit.org/show_bug.cgi?id=200103

Reviewed by Mark Lam.

Source/bmalloc:

* bmalloc/IsoPage.cpp:

Source/WebCore:

No behavior change in WebCore.

* page/MemoryRelease.cpp:
* page/ResourceUsageThread.h:
(WebCore::TagInfo::TagInfo): Deleted.
* page/cocoa/ResourceUsageThreadCocoa.mm:
(WebCore::vmPageSize): Deleted.
(WebCore::logFootprintComparison): Deleted.
(WebCore::displayNameForVMTag): Deleted.
(WebCore::pagesPerVMTag): Deleted.

Source/WebCore/PAL:

Move VMTag page memory investigation code from PAL to WTF to reuse it in TestWTF.

* PAL.xcodeproj/project.pbxproj:
* pal/PlatformMac.cmake:

Source/WebKit:

Move MachVMSPI.h from PAL to WTF.

* Platform/cocoa/SharedMemoryCocoa.cpp:

Source/WTF:

We move VMTag page investigation code from PAL to WTF to use it in TestWTF.
And we also accumulate allocated VA size in `reserved` field of `TagInfo`.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/PlatformMac.cmake:
* wtf/ResourceUsage.h: Added.
* wtf/cocoa/MemoryPressureHandlerCocoa.mm:
* wtf/cocoa/ResourceUsageCocoa.cpp: Added.
(WTF::vmPageSize):
(WTF::logFootprintComparison):
(WTF::displayNameForVMTag):
(WTF::pagesPerVMTag):
* wtf/spi/cocoa/MachVMSPI.h: Added.

Tools:

This patch adds tests to TestWTF IsoHeap tests to ensure that IsoHeap's component is not leaking pages or not allocating too large VAs for memory allocation.
We use VMTag to get the system view of the allocated VAs and check whether it is not incredibly large.

While the tests are white-box tests (it means that this is a bit flaky to the implementation changes of IsoHeap), I adjusted some threshold to make this less-flaky
to the future implementation changes while it catches the severe issues we had.

* TestWebKitAPI/Tests/WTF/bmalloc/IsoHeap.cpp:
(assertEmptyPointerSet):
(assertHasOnlyObjects):
(assertClean):
(TEST):
(allocateAndDeallocate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247815 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/PlatformMac.cmake
Source/WTF/wtf/ResourceUsage.h [new file with mode: 0644]
Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm
Source/WTF/wtf/cocoa/ResourceUsageCocoa.cpp [new file with mode: 0644]
Source/WTF/wtf/spi/cocoa/MachVMSPI.h [moved from Source/WebCore/PAL/pal/spi/cocoa/MachVMSPI.h with 100% similarity]
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
Source/WebCore/PAL/pal/PlatformMac.cmake
Source/WebCore/page/MemoryRelease.cpp
Source/WebCore/page/ResourceUsageThread.h
Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm
Source/WebKit/ChangeLog
Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/IsoPage.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/bmalloc/IsoHeap.cpp