Source/bmalloc:
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Aug 2016 19:23:47 +0000 (19:23 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Aug 2016 19:23:47 +0000 (19:23 +0000)
Add bmalloc::api::isEnabled().
<https://webkit.org/b/160534>

Reviewed by Joseph Pecoraro.

* bmalloc/bmalloc.h:
(bmalloc::api::isEnabled):

Source/WebCore:
Leaks bot hits an assertion in ResourceUsageThread::platformThreadBody
<https://webkit.org/b/160534>

Reviewed by Joseph Pecoraro.

Use the correct malloc bucket when bmalloc is disabled (which is the case on leaks bots.)

* page/cocoa/ResourceUsageThreadCocoa.mm:
(WebCore::ResourceUsageThread::platformThreadBody):

Source/WTF:
Add WTF::isFastMallocEnabled().
<https://webkit.org/b/160534>

Reviewed by Joseph Pecoraro.

* wtf/FastMalloc.cpp:
(WTF::isFastMallocEnabled):
* wtf/FastMalloc.h:

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

Source/WTF/ChangeLog
Source/WTF/wtf/FastMalloc.cpp
Source/WTF/wtf/FastMalloc.h
Source/WebCore/ChangeLog
Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/bmalloc.h

index 70447e7..37e20a4 100644 (file)
@@ -1,3 +1,14 @@
+2016-08-24  Andreas Kling  <akling@apple.com>
+
+        Add WTF::isFastMallocEnabled().
+        <https://webkit.org/b/160534>
+
+        Reviewed by Joseph Pecoraro.
+
+        * wtf/FastMalloc.cpp:
+        (WTF::isFastMallocEnabled):
+        * wtf/FastMalloc.h:
+
 2016-08-23  Anders Carlsson  <andersca@apple.com>
 
         Add enum traits and use them in the IPC::Decoder
index c4c1d18..10a2fcf 100644 (file)
@@ -81,6 +81,11 @@ TryMallocReturnValue tryFastZeroedMalloc(size_t n)
 
 namespace WTF {
 
+bool isFastMallocEnabled()
+{
+    return false;
+}
+
 size_t fastMallocGoodSize(size_t bytes)
 {
 #if OS(DARWIN)
@@ -188,6 +193,11 @@ size_t fastMallocSize(const void* p)
 
 namespace WTF {
 
+bool isFastMallocEnabled()
+{
+    return bmalloc::api::isEnabled();
+}
+
 void* fastMalloc(size_t size)
 {
     return bmalloc::api::malloc(size);
index 8b4c1fc..16ddf04 100644 (file)
@@ -38,6 +38,8 @@ private:
     mutable void* m_data;
 };
 
+WTF_EXPORT_PRIVATE bool isFastMallocEnabled();
+
 // These functions call CRASH() if an allocation fails.
 WTF_EXPORT_PRIVATE void* fastMalloc(size_t);
 WTF_EXPORT_PRIVATE void* fastZeroedMalloc(size_t);
@@ -99,6 +101,7 @@ template<typename T> inline bool TryMallocReturnValue::getValue(T*& data)
 
 } // namespace WTF
 
+using WTF::isFastMallocEnabled;
 using WTF::fastCalloc;
 using WTF::fastFree;
 using WTF::fastMalloc;
index e4e26cc..ce42b2f 100644 (file)
@@ -1,3 +1,15 @@
+2016-08-24  Andreas Kling  <akling@apple.com>
+
+        Leaks bot hits an assertion in ResourceUsageThread::platformThreadBody
+        <https://webkit.org/b/160534>
+
+        Reviewed by Joseph Pecoraro.
+
+        Use the correct malloc bucket when bmalloc is disabled (which is the case on leaks bots.)
+
+        * page/cocoa/ResourceUsageThreadCocoa.mm:
+        (WebCore::ResourceUsageThread::platformThreadBody):
+
 2016-08-24  Filip Pizlo  <fpizlo@apple.com>
 
         Unreviewed, roll out r204901, r204897, r204866, r204856, r204854.
index d47c489..a13c473 100644 (file)
@@ -227,11 +227,15 @@ void ResourceUsageThread::platformThreadBody(JSC::VM* vm, ResourceUsageData& dat
     data.categories[MemoryCategory::GCOwned].dirtySize = currentGCOwnedExtra - currentGCOwnedExternal;
     data.categories[MemoryCategory::GCOwned].externalSize = currentGCOwnedExternal;
 
-    // Subtract known subchunks from the bmalloc bucket.
-    // FIXME: Handle running with bmalloc disabled.
-    size_t currentGCOwnedGenerallyInBmalloc = currentGCOwnedExtra - currentGCOwnedExternal;
-    ASSERT(currentGCOwnedGenerallyInBmalloc < data.categories[MemoryCategory::bmalloc].dirtySize);
-    data.categories[MemoryCategory::bmalloc].dirtySize -= currentGCHeapCapacity + currentGCOwnedGenerallyInBmalloc;
+    // Subtract known subchunks from the appropriate malloc bucket.
+    size_t currentGCOwnedGenerallyInMalloc = currentGCOwnedExtra - currentGCOwnedExternal;
+    if (isFastMallocEnabled()) {
+        RELEASE_ASSERT(currentGCOwnedGenerallyInMalloc < data.categories[MemoryCategory::bmalloc].dirtySize);
+        data.categories[MemoryCategory::bmalloc].dirtySize -= currentGCHeapCapacity + currentGCOwnedGenerallyInMalloc;
+    } else {
+        RELEASE_ASSERT(currentGCOwnedGenerallyInMalloc < data.categories[MemoryCategory::LibcMalloc].dirtySize);
+        data.categories[MemoryCategory::LibcMalloc].dirtySize -= currentGCHeapCapacity + currentGCOwnedGenerallyInMalloc;
+    }
 
     data.totalExternalSize = currentGCOwnedExternal;
 
index 1219428..c42f61a 100644 (file)
@@ -1,3 +1,13 @@
+2016-08-24  Andreas Kling  <akling@apple.com>
+
+        Add bmalloc::api::isEnabled().
+        <https://webkit.org/b/160534>
+
+        Reviewed by Joseph Pecoraro.
+
+        * bmalloc/bmalloc.h:
+        (bmalloc::api::isEnabled):
+
 2016-08-24  Filip Pizlo  <fpizlo@apple.com>
 
         Unreviewed, roll out r204901, r204897, r204866, r204856, r204854.
index db8ce26..d9f40e4 100644 (file)
@@ -73,5 +73,11 @@ inline void scavenge()
     PerProcess<Heap>::get()->scavenge(lock, std::chrono::milliseconds(0));
 }
 
+inline bool isEnabled()
+{
+    std::unique_lock<StaticMutex> lock(PerProcess<Heap>::mutex());
+    return PerProcess<Heap>::getFastCase()->environment().isBmallocEnabled();
+}
+
 } // namespace api
 } // namespace bmalloc