We should be OK with the gigacage being disabled on gmalloc
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Aug 2017 19:57:50 +0000 (19:57 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Aug 2017 19:57:50 +0000 (19:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175082

Reviewed by Michael Saboff.
Source/bmalloc:

This adds Gigacage::shouldBeEnabled(), which returns false when we're using gmalloc or other things
that enable DebugHeap.

* bmalloc/Environment.cpp:
(bmalloc::Environment::Environment):
* bmalloc/Environment.h:
* bmalloc/Gigacage.cpp:
(Gigacage::ensureGigacage):
(Gigacage::shouldBeEnabled):
* bmalloc/Gigacage.h:
* bmalloc/Heap.cpp:
(bmalloc::Heap::Heap):
* bmalloc/Heap.h:

Source/JavaScriptCore:

* jsc.cpp:
(jscmain):

Source/WebKit:

* WebProcess/WebProcess.cpp:
(WebKit::m_webSQLiteDatabaseTracker):

Source/WTF:

* wtf/Gigacage.h:
(Gigacage::shouldBeEnabled):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220148 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/jsc.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/Gigacage.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebProcess.cpp
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/Environment.cpp
Source/bmalloc/bmalloc/Environment.h
Source/bmalloc/bmalloc/Gigacage.cpp
Source/bmalloc/bmalloc/Gigacage.h
Source/bmalloc/bmalloc/Heap.cpp
Source/bmalloc/bmalloc/Heap.h

index 1d7dff6de99bcf42ba14c07f15e384bc572ed375..b37bce1aff2fc3859d4b174e242aa8ec7511d759 100644 (file)
@@ -1,3 +1,13 @@
+2017-08-02  Filip Pizlo  <fpizlo@apple.com>
+
+        We should be OK with the gigacage being disabled on gmalloc
+        https://bugs.webkit.org/show_bug.cgi?id=175082
+
+        Reviewed by Michael Saboff.
+
+        * jsc.cpp:
+        (jscmain):
+
 2017-08-02  Saam Barati  <sbarati@apple.com>
 
         On memory-constrained iOS devices, reduce the rate at which the JS heap grows before a GC to try to keep more memory available for the system
index 9f093cee30537e1bbf65fd816e96fd53f78c95e0..9e3db46b4bc26f1c26c4d826fabbf69598551c96 100644 (file)
@@ -3826,7 +3826,7 @@ int jscmain(int argc, char** argv)
 #if ENABLE(WEBASSEMBLY)
     JSC::Wasm::enableFastMemory();
 #endif
-    if (GIGACAGE_ENABLED)
+    if (Gigacage::shouldBeEnabled())
         Gigacage::addDisableCallback(gigacageDisabled, nullptr);
 
     int result;
index a98e7ec6b7cd3ab61e22c6cd156271515ef03b3e..aaa74b52e4c35cc6b27e451c42082da2dd7a09f2 100644 (file)
@@ -1,3 +1,13 @@
+2017-08-02  Filip Pizlo  <fpizlo@apple.com>
+
+        We should be OK with the gigacage being disabled on gmalloc
+        https://bugs.webkit.org/show_bug.cgi?id=175082
+
+        Reviewed by Michael Saboff.
+
+        * wtf/Gigacage.h:
+        (Gigacage::shouldBeEnabled):
+
 2017-08-01  Filip Pizlo  <fpizlo@apple.com>
 
         Bmalloc and GC should put auxiliaries (butterflies, typed array backing stores) in a gigacage (separate multi-GB VM region)
index f289ef962f9b91bad3819e512b44270719a40965..dd2df2b2959e1d74961964a27e75de35a7cc6505 100644 (file)
@@ -39,6 +39,7 @@ namespace Gigacage {
 
 inline void ensureGigacage() { }
 inline void disableGigacage() { }
+inline bool shouldBeEnabled() { return false; }
 
 inline void addDisableCallback(void (*)(void*), void*) { }
 inline void removeDisableCallback(void (*)(void*), void*) { }
index cdc58bab2be42b5d5e693ca6a0973ad17cb0e94a..1779797addddafcc3ad0152d7ffa491ca752e2d3 100644 (file)
@@ -1,3 +1,13 @@
+2017-08-02  Filip Pizlo  <fpizlo@apple.com>
+
+        We should be OK with the gigacage being disabled on gmalloc
+        https://bugs.webkit.org/show_bug.cgi?id=175082
+
+        Reviewed by Michael Saboff.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::m_webSQLiteDatabaseTracker):
+
 2017-08-02  Brian Burg  <bburg@apple.com>
 
         Web Automation: files selected for upload should be checked against values of the 'accept' attribute
index 695ec04e409aeee5c95fdef1e9242b24e0d09d8c..a3ee40172252dd864a72ccd0eff23959893eddf8 100644 (file)
@@ -202,7 +202,7 @@ WebProcess::WebProcess()
         parentProcessConnection()->send(Messages::WebResourceLoadStatisticsStore::ResourceLoadStatisticsUpdated(WTFMove(statistics)), 0);
     });
 
-    if (GIGACAGE_ENABLED)
+    if (Gigacage::shouldBeEnabled())
         Gigacage::addDisableCallback(gigacageDisabled, nullptr);
 }
 
index 0c3e56967b4dcdeb67a6df25e09b25dfc438208b..ecc46474bc0f00c22fa3756490b241ddfa89c71f 100644 (file)
@@ -1,3 +1,24 @@
+2017-08-02  Filip Pizlo  <fpizlo@apple.com>
+
+        We should be OK with the gigacage being disabled on gmalloc
+        https://bugs.webkit.org/show_bug.cgi?id=175082
+
+        Reviewed by Michael Saboff.
+        
+        This adds Gigacage::shouldBeEnabled(), which returns false when we're using gmalloc or other things
+        that enable DebugHeap.
+
+        * bmalloc/Environment.cpp:
+        (bmalloc::Environment::Environment):
+        * bmalloc/Environment.h:
+        * bmalloc/Gigacage.cpp:
+        (Gigacage::ensureGigacage):
+        (Gigacage::shouldBeEnabled):
+        * bmalloc/Gigacage.h:
+        * bmalloc/Heap.cpp:
+        (bmalloc::Heap::Heap):
+        * bmalloc/Heap.h:
+
 2017-08-01  Filip Pizlo  <fpizlo@apple.com>
 
         Bmalloc and GC should put auxiliaries (butterflies, typed array backing stores) in a gigacage (separate multi-GB VM region)
index 19e047f2c0ce7f53165fc683b6ab592c2e92f5f8..c78089f498b40b9786dc62da94e225d63cd77118 100644 (file)
@@ -107,7 +107,7 @@ static bool isSanitizerEnabled()
 #endif
 }
 
-Environment::Environment()
+Environment::Environment(std::lock_guard<StaticMutex>&)
     : m_isDebugHeapEnabled(computeIsDebugHeapEnabled())
 {
 }
index 3e46a43592aa01410931aa0543d5429ea84f4087..16b26cd9d7ff978d76ccb18826595ee71d143ddb 100644 (file)
 #ifndef Environment_h
 #define Environment_h
 
+#include "StaticMutex.h"
+
 namespace bmalloc {
 
 class Environment {
 public:
-    Environment();
+    Environment(std::lock_guard<StaticMutex>&);
     
     bool isDebugHeapEnabled() { return m_isDebugHeapEnabled; }
 
index f8a13353daa11764b863825883da867560ddb28d..6c1b9eef7d2e6bf7a906cfb78acdfc3b90794cd9 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "Gigacage.h"
 
+#include "Environment.h"
 #include "PerProcess.h"
 #include "VMAllocate.h"
 #include "Vector.h"
@@ -65,6 +66,9 @@ void ensureGigacage()
     std::call_once(
         onceFlag,
         [] {
+            if (!shouldBeEnabled())
+                return;
+            
             void* basePtr = tryVMAllocate(GIGACAGE_SIZE, GIGACAGE_SIZE + GIGACAGE_RUNWAY);
             if (!basePtr)
                 return;
@@ -121,6 +125,11 @@ void removeDisableCallback(void (*function)(void*), void* argument)
     }
 }
 
+bool shouldBeEnabled()
+{
+    return GIGACAGE_ENABLED && !PerProcess<Environment>::get()->isDebugHeapEnabled();
+}
+
 } // namespace Gigacage
 
 
index 0e9acefe195a1f47afa45bc99112c398c57d07e6..83998f9669fe01810d1dd4b783e011e2a73eeae5 100644 (file)
@@ -71,6 +71,8 @@ inline bool isCaged(const void* ptr)
     return caged(ptr) == ptr;
 }
 
+BEXPORT bool shouldBeEnabled();
+
 } // namespace Gigacage
 
 
index cdc26ca3d33215974346a1997a63bff1a4e27071..3d5058ac142f24c757ae439dbc29c5162336edff 100644 (file)
@@ -28,6 +28,7 @@
 #include "AvailableMemory.h"
 #include "BumpAllocator.h"
 #include "Chunk.h"
+#include "Environment.h"
 #include "Gigacage.h"
 #include "DebugHeap.h"
 #include "PerProcess.h"
@@ -52,7 +53,7 @@ Heap::Heap(HeapKind kind, std::lock_guard<StaticMutex>&)
     initializeLineMetadata();
     initializePageMetadata();
     
-    if (m_environment.isDebugHeapEnabled())
+    if (PerProcess<Environment>::get()->isDebugHeapEnabled())
         m_debugHeap = PerProcess<DebugHeap>::get();
     else {
         Gigacage::ensureGigacage();
index 606adbd6c770c2961e21208988e1bd651e835c01..aae9c31b0bd6a5bb9ae36050537a8abeb1e46278 100644 (file)
@@ -30,7 +30,6 @@
 #include "AsyncTask.h"
 #include "BumpRange.h"
 #include "Chunk.h"
-#include "Environment.h"
 #include "HeapKind.h"
 #include "LargeMap.h"
 #include "LineMetadata.h"
@@ -136,7 +135,6 @@ private:
     
     AsyncTask<Heap, decltype(&Heap::concurrentScavenge)> m_scavenger;
 
-    Environment m_environment;
     DebugHeap* m_debugHeap;
 };