[bmalloc] Each IsoPage gets 1MB VA because VMHeap::tryAllocateLargeChunk rounds up
authorysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jul 2019 02:43:11 +0000 (02:43 +0000)
committerysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jul 2019 02:43:11 +0000 (02:43 +0000)
commita4ec61b4cff00fe365014576a3057f6bc4f38722
tree263b288ae659c908cfb576ca8d1f5f005ebd3717
parent79824a8c268b8272d3945de91bbd73d5633c4625
[bmalloc] Each IsoPage gets 1MB VA because VMHeap::tryAllocateLargeChunk rounds up
https://bugs.webkit.org/show_bug.cgi?id=200024

Reviewed by Saam Barati.

Source/bmalloc:

When we allocate IsoHeap's page, we reused VMHeap::tryAllocateLargeChunk. However, this function is originally designed
to be used for Large allocation in bmalloc (e.g. allocating Chunk in bmalloc). As a result, this function rounds up the
requested size with 1MB (bmalloc::chunkSize). As a result, all IsoHeap's 16KB page gets 1MB VA while it just uses 16KB of
the allocated region. This leads to VA exhaustion since IsoHeap now uses 64x VA than we expected!

This patch fixes the above VA exhaustion issue by allocating a page by using tryVMAllocate. When allocating a page, we start
using a VM tag for IsoHeap. We discussed at e-mail and we decided reusing a VM tag previously assigned to CLoop Stack since
this is less profitable. Since this tag is not Malloc-related tag, Leaks tool can scan memory region conservatively without
registering allocated region into Zone, which was previously done in VMHeap and that's why we reused VMHeap for IsoHeap.

* bmalloc/BVMTags.h:
* bmalloc/IsoPage.cpp:
(bmalloc::IsoPageBase::allocatePageMemory):
* bmalloc/IsoTLS.cpp:
(bmalloc::IsoTLS::ensureEntries):
* bmalloc/VMAllocate.h:
(bmalloc::vmAllocate):

Source/JavaScriptCore:

Discussed and we decided to use this VM tag for IsoHeap instead of CLoop stack.

* interpreter/CLoopStack.cpp:
(JSC::CLoopStack::CLoopStack):

Source/WebCore:

Changed how we interpret VM tags. Add IsoHeap VM tag support, and rename WebAssembly tag
to Gigacage tag.

* page/ResourceUsageData.h:
* page/ResourceUsageOverlay.h:
* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::HistoricResourceUsageData::HistoricResourceUsageData):
* page/cocoa/ResourceUsageThreadCocoa.mm:
(WebCore::displayNameForVMTag):
(WebCore::categoryForVMTag):

Source/WTF:

Start using a VM tag for IsoHeap instead of CLoop Stack.

* wtf/OSAllocator.h:
* wtf/VMTags.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247714 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/interpreter/CLoopStack.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/OSAllocator.h
Source/WTF/wtf/VMTags.h
Source/WebCore/ChangeLog
Source/WebCore/page/ResourceUsageData.h
Source/WebCore/page/ResourceUsageOverlay.h
Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm
Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/BVMTags.h
Source/bmalloc/bmalloc/IsoPage.cpp
Source/bmalloc/bmalloc/IsoTLS.cpp
Source/bmalloc/bmalloc/VMAllocate.h