Title: [247965] branches/safari-608-branch/Source
Revision
247965
Author
alanc...@apple.com
Date
2019-07-29 20:54:48 -0700 (Mon, 29 Jul 2019)

Log Message

Cherry-pick r247714. rdar://problem/53647616

    [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/_javascript_Core:

    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

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/_javascript_Core/ChangeLog (247964 => 247965)


--- branches/safari-608-branch/Source/_javascript_Core/ChangeLog	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/_javascript_Core/ChangeLog	2019-07-30 03:54:48 UTC (rev 247965)
@@ -1,5 +1,75 @@
 2019-07-29  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r247714. rdar://problem/53647616
+
+    [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/_javascript_Core:
+    
+    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
+
+    2019-07-22  Yusuke Suzuki  <ysuz...@apple.com>
+
+            [bmalloc] Each IsoPage gets 1MB VA because VMHeap::tryAllocateLargeChunk rounds up
+            https://bugs.webkit.org/show_bug.cgi?id=200024
+
+            Reviewed by Saam Barati.
+
+            Discussed and we decided to use this VM tag for IsoHeap instead of CLoop stack.
+
+            * interpreter/CLoopStack.cpp:
+            (JSC::CLoopStack::CLoopStack):
+
+2019-07-29  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r247713. rdar://problem/53648241
 
     Turn off Wasm fast memory on iOS

Modified: branches/safari-608-branch/Source/_javascript_Core/interpreter/CLoopStack.cpp (247964 => 247965)


--- branches/safari-608-branch/Source/_javascript_Core/interpreter/CLoopStack.cpp	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/_javascript_Core/interpreter/CLoopStack.cpp	2019-07-30 03:54:48 UTC (rev 247965)
@@ -59,7 +59,7 @@
     capacity = WTF::roundUpToMultipleOf(pageSize(), capacity);
     ASSERT(capacity && isPageAligned(capacity));
 
-    m_reservation = PageReservation::reserve(WTF::roundUpToMultipleOf(commitSize(), capacity), OSAllocator::JSVMStackPages);
+    m_reservation = PageReservation::reserve(WTF::roundUpToMultipleOf(commitSize(), capacity), OSAllocator::UnknownUsage);
 
     auto* bottomOfStack = highAddress();
     setCLoopStackLimit(bottomOfStack);

Modified: branches/safari-608-branch/Source/WTF/ChangeLog (247964 => 247965)


--- branches/safari-608-branch/Source/WTF/ChangeLog	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/WTF/ChangeLog	2019-07-30 03:54:48 UTC (rev 247965)
@@ -1,3 +1,73 @@
+2019-07-29  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r247714. rdar://problem/53647616
+
+    [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/_javascript_Core:
+    
+    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
+
+    2019-07-22  Yusuke Suzuki  <ysuz...@apple.com>
+
+            [bmalloc] Each IsoPage gets 1MB VA because VMHeap::tryAllocateLargeChunk rounds up
+            https://bugs.webkit.org/show_bug.cgi?id=200024
+
+            Reviewed by Saam Barati.
+
+            Start using a VM tag for IsoHeap instead of CLoop Stack.
+
+            * wtf/OSAllocator.h:
+            * wtf/VMTags.h:
+
 2019-07-24  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r247754. rdar://problem/53483290

Modified: branches/safari-608-branch/Source/WTF/wtf/OSAllocator.h (247964 => 247965)


--- branches/safari-608-branch/Source/WTF/wtf/OSAllocator.h	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/WTF/wtf/OSAllocator.h	2019-07-30 03:54:48 UTC (rev 247965)
@@ -35,7 +35,6 @@
     enum Usage {
         UnknownUsage = -1,
         FastMallocPages = VM_TAG_FOR_TCMALLOC_MEMORY,
-        JSVMStackPages = VM_TAG_FOR_REGISTERFILE_MEMORY,
         JSJITCodePages = VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY,
     };
 

Modified: branches/safari-608-branch/Source/WTF/wtf/VMTags.h (247964 => 247965)


--- branches/safari-608-branch/Source/WTF/wtf/VMTags.h	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/WTF/wtf/VMTags.h	2019-07-30 03:54:48 UTC (rev 247965)
@@ -30,7 +30,7 @@
 #define VM_TAG_FOR_TCMALLOC_MEMORY -1
 #define VM_TAG_FOR_WEBASSEMBLY_MEMORY -1
 #define VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY -1
-#define VM_TAG_FOR_REGISTERFILE_MEMORY -1
+#define VM_TAG_FOR_ISOHEAP_MEMORY -1
 
 #else
 

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (247964 => 247965)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-07-30 03:54:48 UTC (rev 247965)
@@ -1,5 +1,81 @@
 2019-07-29  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r247714. rdar://problem/53647616
+
+    [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/_javascript_Core:
+    
+    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
+
+    2019-07-22  Yusuke Suzuki  <ysuz...@apple.com>
+
+            [bmalloc] Each IsoPage gets 1MB VA because VMHeap::tryAllocateLargeChunk rounds up
+            https://bugs.webkit.org/show_bug.cgi?id=200024
+
+            Reviewed by Saam Barati.
+
+            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):
+
+2019-07-29  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r247702. rdar://problem/53575409
 
     [iOS] [WK1] UIWebView always jumps to the top left corner when scrolling to reveal the selection

Modified: branches/safari-608-branch/Source/WebCore/page/ResourceUsageData.h (247964 => 247965)


--- branches/safari-608-branch/Source/WebCore/page/ResourceUsageData.h	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/WebCore/page/ResourceUsageData.h	2019-07-30 03:54:48 UTC (rev 247965)
@@ -39,12 +39,13 @@
     v(bmalloc, 0, false) \
     v(LibcMalloc, 1, false) \
     v(JSJIT, 2, false) \
-    v(WebAssembly, 3, false) \
+    v(Gigacage, 3, false) \
     v(Images, 4, false) \
     v(GCHeap, 5, true) \
     v(GCOwned, 6, true) \
     v(Other, 7, false) \
     v(Layers, 8, false) \
+    v(IsoHeap, 9, false) \
 
 namespace MemoryCategory {
 #define WEBCORE_DEFINE_MEMORY_CATEGORY(name, id, subcategory) static constexpr unsigned name = id;

Modified: branches/safari-608-branch/Source/WebCore/page/ResourceUsageOverlay.h (247964 => 247965)


--- branches/safari-608-branch/Source/WebCore/page/ResourceUsageOverlay.h	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/WebCore/page/ResourceUsageOverlay.h	2019-07-30 03:54:48 UTC (rev 247965)
@@ -58,7 +58,7 @@
 #endif
 
     static const int normalWidth = 570;
-    static const int normalHeight = 160;
+    static const int normalHeight = 180;
 
 private:
     void willMoveToPage(PageOverlay&, Page*) override { }

Modified: branches/safari-608-branch/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (247964 => 247965)


--- branches/safari-608-branch/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm	2019-07-30 03:54:48 UTC (rev 247965)
@@ -163,11 +163,12 @@
 {
     // VM tag categories.
     categories[MemoryCategory::JSJIT] = HistoricMemoryCategoryInfo(MemoryCategory::JSJIT, 0xFFFF60FF, "JS JIT");
-    categories[MemoryCategory::WebAssembly] = HistoricMemoryCategoryInfo(MemoryCategory::WebAssembly, 0xFF654FF0, "WebAssembly");
+    categories[MemoryCategory::Gigacage] = HistoricMemoryCategoryInfo(MemoryCategory::Gigacage, 0xFF654FF0, "Gigacage");
     categories[MemoryCategory::Images] = HistoricMemoryCategoryInfo(MemoryCategory::Images, 0xFFFFFF00, "Images");
     categories[MemoryCategory::Layers] = HistoricMemoryCategoryInfo(MemoryCategory::Layers, 0xFF00FFFF, "Layers");
     categories[MemoryCategory::LibcMalloc] = HistoricMemoryCategoryInfo(MemoryCategory::LibcMalloc, 0xFF00FF00, "libc malloc");
     categories[MemoryCategory::bmalloc] = HistoricMemoryCategoryInfo(MemoryCategory::bmalloc, 0xFFFF6060, "bmalloc");
+    categories[MemoryCategory::IsoHeap] = HistoricMemoryCategoryInfo(MemoryCategory::IsoHeap, 0xFF809F40, "IsoHeap");
     categories[MemoryCategory::Other] = HistoricMemoryCategoryInfo(MemoryCategory::Other, 0xFFC0FF00, "Other");
 
     // Sub categories (e.g breakdown of bmalloc tag.)

Modified: branches/safari-608-branch/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm (247964 => 247965)


--- branches/safari-608-branch/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm	2019-07-30 03:54:48 UTC (rev 247965)
@@ -83,8 +83,9 @@
     case VM_MEMORY_LAYERKIT: return "CoreAnimation";
     case VM_MEMORY_IMAGEIO: return "ImageIO";
     case VM_MEMORY_CGIMAGE: return "CG image";
+    case VM_MEMORY_JAVASCRIPT_CORE: return "Gigacage";
     case VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: return "JSC JIT";
-    case VM_MEMORY_JAVASCRIPT_CORE: return "WebAssembly";
+    case VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE: return "IsoHeap";
     case VM_MEMORY_MALLOC: return "malloc";
     case VM_MEMORY_MALLOC_HUGE: return "malloc (huge)";
     case VM_MEMORY_MALLOC_LARGE: return "malloc (large)";
@@ -151,10 +152,12 @@
     case VM_MEMORY_IMAGEIO:
     case VM_MEMORY_CGIMAGE:
         return MemoryCategory::Images;
+    case VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE:
+        return MemoryCategory::IsoHeap;
     case VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR:
         return MemoryCategory::JSJIT;
     case VM_MEMORY_JAVASCRIPT_CORE:
-        return MemoryCategory::WebAssembly;
+        return MemoryCategory::Gigacage;
     case VM_MEMORY_MALLOC:
     case VM_MEMORY_MALLOC_HUGE:
     case VM_MEMORY_MALLOC_LARGE:

Modified: branches/safari-608-branch/Source/bmalloc/ChangeLog (247964 => 247965)


--- branches/safari-608-branch/Source/bmalloc/ChangeLog	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/bmalloc/ChangeLog	2019-07-30 03:54:48 UTC (rev 247965)
@@ -1,5 +1,88 @@
 2019-07-29  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r247714. rdar://problem/53647616
+
+    [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/_javascript_Core:
+    
+    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
+
+    2019-07-22  Yusuke Suzuki  <ysuz...@apple.com>
+
+            [bmalloc] Each IsoPage gets 1MB VA because VMHeap::tryAllocateLargeChunk rounds up
+            https://bugs.webkit.org/show_bug.cgi?id=200024
+
+            Reviewed by Saam Barati.
+
+            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):
+
+2019-07-29  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r247711. rdar://problem/53647462
 
     Unreviewed, follow-up fix for tls->size() access

Modified: branches/safari-608-branch/Source/bmalloc/bmalloc/BVMTags.h (247964 => 247965)


--- branches/safari-608-branch/Source/bmalloc/bmalloc/BVMTags.h	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/bmalloc/bmalloc/BVMTags.h	2019-07-30 03:54:48 UTC (rev 247965)
@@ -46,9 +46,9 @@
 #endif // defined(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR)
 
 #if defined(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE)
-#define VM_TAG_FOR_REGISTERFILE_MEMORY VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE)
+#define VM_TAG_FOR_ISOHEAP_MEMORY VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE)
 #else
-#define VM_TAG_FOR_REGISTERFILE_MEMORY VM_MAKE_TAG(65)
+#define VM_TAG_FOR_ISOHEAP_MEMORY VM_MAKE_TAG(65)
 #endif // defined(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE)
 
 #if defined(VM_MEMORY_JAVASCRIPT_CORE)
@@ -62,7 +62,7 @@
 #define VM_TAG_FOR_TCMALLOC_MEMORY -1
 #define VM_TAG_FOR_GIGACAGE_MEMORY -1
 #define VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY -1
-#define VM_TAG_FOR_REGISTERFILE_MEMORY -1
+#define VM_TAG_FOR_ISOHEAP_MEMORY -1
 
 #endif // BOS(DARWIN)
 
@@ -71,7 +71,7 @@
 enum class VMTag {
     Unknown = -1,
     Malloc = VM_TAG_FOR_TCMALLOC_MEMORY,
-    JSVMStack = VM_TAG_FOR_REGISTERFILE_MEMORY,
+    IsoHeap = VM_TAG_FOR_ISOHEAP_MEMORY,
     JSJITCode = VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY,
     JSGigacage = VM_TAG_FOR_GIGACAGE_MEMORY,
 };

Modified: branches/safari-608-branch/Source/bmalloc/bmalloc/IsoPage.cpp (247964 => 247965)


--- branches/safari-608-branch/Source/bmalloc/bmalloc/IsoPage.cpp	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/bmalloc/bmalloc/IsoPage.cpp	2019-07-30 03:54:48 UTC (rev 247965)
@@ -32,7 +32,7 @@
 
 void* IsoPageBase::allocatePageMemory()
 {
-    return VMHeap::get()->tryAllocateLargeChunk(pageSize, pageSize).begin();
+    return tryVMAllocate(pageSize, pageSize, VMTag::IsoHeap);
 }
 
 } // namespace bmalloc

Modified: branches/safari-608-branch/Source/bmalloc/bmalloc/IsoTLS.cpp (247964 => 247965)


--- branches/safari-608-branch/Source/bmalloc/bmalloc/IsoTLS.cpp	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/bmalloc/bmalloc/IsoTLS.cpp	2019-07-30 03:54:48 UTC (rev 247965)
@@ -100,7 +100,7 @@
         size_t requiredSize = sizeForCapacity(requiredCapacity);
         size_t goodSize = roundUpToMultipleOf(vmPageSize(), requiredSize);
         size_t goodCapacity = capacityForSize(goodSize);
-        void* memory = vmAllocate(goodSize);
+        void* memory = vmAllocate(goodSize, VMTag::IsoHeap);
         IsoTLS* newTLS = new (memory) IsoTLS();
         newTLS->m_capacity = goodCapacity;
         if (tls) {

Modified: branches/safari-608-branch/Source/bmalloc/bmalloc/VMAllocate.h (247964 => 247965)


--- branches/safari-608-branch/Source/bmalloc/bmalloc/VMAllocate.h	2019-07-30 03:54:43 UTC (rev 247964)
+++ branches/safari-608-branch/Source/bmalloc/bmalloc/VMAllocate.h	2019-07-30 03:54:48 UTC (rev 247965)
@@ -130,9 +130,9 @@
     return result;
 }
 
-inline void* vmAllocate(size_t vmSize)
+inline void* vmAllocate(size_t vmSize, VMTag usage = VMTag::Malloc)
 {
-    void* result = tryVMAllocate(vmSize);
+    void* result = tryVMAllocate(vmSize, usage);
     RELEASE_BASSERT(result);
     return result;
 }
@@ -189,9 +189,9 @@
     return aligned;
 }
 
-inline void* vmAllocate(size_t vmAlignment, size_t vmSize)
+inline void* vmAllocate(size_t vmAlignment, size_t vmSize, VMTag usage = VMTag::Malloc)
 {
-    void* result = tryVMAllocate(vmAlignment, vmSize);
+    void* result = tryVMAllocate(vmAlignment, vmSize, usage);
     RELEASE_BASSERT(result);
     return result;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to