Added a bmalloc back-end for FastMalloc
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Apr 2014 20:36:17 +0000 (20:36 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Apr 2014 20:36:17 +0000 (20:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131387

Reviewed by Andreas Kling.

We'll need to rethink some things if we adopt this back-end. For example,
fastMallocSize() and fastMallocGoodSize() are no longer real things. But,
this is enough to test for now.

* wtf/FastMalloc.cpp:
(WTF::fastMalloc):
(WTF::fastCalloc):
(WTF::fastRealloc):
(WTF::fastFree):
(WTF::fastMallocSize):
(WTF::fastMallocGoodSize):
(WTF::tryFastMalloc):
(WTF::tryFastRealloc):
(WTF::tryFastCalloc):
(WTF::releaseFastMallocFreeMemory):
(WTF::fastMallocStatistics):

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

Source/WTF/ChangeLog
Source/WTF/wtf/FastMalloc.cpp

index f0997dd..265bac3 100644 (file)
@@ -1,3 +1,27 @@
+2014-04-08  Geoffrey Garen  <ggaren@apple.com>
+
+        Added a bmalloc back-end for FastMalloc
+        https://bugs.webkit.org/show_bug.cgi?id=131387
+
+        Reviewed by Andreas Kling.
+
+        We'll need to rethink some things if we adopt this back-end. For example,
+        fastMallocSize() and fastMallocGoodSize() are no longer real things. But,
+        this is enough to test for now.
+
+        * wtf/FastMalloc.cpp:
+        (WTF::fastMalloc):
+        (WTF::fastCalloc):
+        (WTF::fastRealloc):
+        (WTF::fastFree):
+        (WTF::fastMallocSize):
+        (WTF::fastMallocGoodSize):
+        (WTF::tryFastMalloc):
+        (WTF::tryFastRealloc):
+        (WTF::tryFastCalloc):
+        (WTF::releaseFastMallocFreeMemory):
+        (WTF::fastMallocStatistics):
+
 2014-04-08  Andres Gomez  <agomez@igalia.com>
 
         [GTK] [EFL] Build fails with GCC < 4.8.x
index 35e6dca..5cb20b2 100644 (file)
@@ -423,6 +423,68 @@ size_t fastMallocSize(const void* p)
 extern "C" WTF_EXPORT_PRIVATE const int jscore_fastmalloc_introspection = 0;
 #endif
 
+#elif defined(USE_BMALLOC) && USE_BMALLOC // FORCE_SYSTEM_MALLOC
+
+#include "bmalloc.h"
+
+namespace WTF {
+
+void* fastMalloc(size_t size)
+{
+    ASSERT(!isForbidden());
+    return bmalloc::api::malloc(size);
+}
+
+void* fastCalloc(size_t numElements, size_t elementSize)
+{
+    return fastZeroedMalloc(numElements * elementSize);
+}
+    
+void* fastRealloc(void* object, size_t size)
+{
+    return bmalloc::api::realloc(object, size);
+}
+    
+void fastFree(void* object)
+{
+    bmalloc::api::free(object);
+}
+    
+size_t fastMallocSize(const void*)
+{
+    return 1;
+}
+    
+size_t fastMallocGoodSize(size_t size)
+{
+    return size;
+}
+    
+TryMallocReturnValue tryFastMalloc(size_t size)
+{
+    return fastMalloc(size);
+}
+    
+TryMallocReturnValue tryFastRealloc(void* p, size_t n)
+{
+    return fastRealloc(p, n);
+}
+    
+TryMallocReturnValue tryFastCalloc(size_t numElements, size_t elementSize)
+{
+    return fastCalloc(numElements, elementSize);
+}
+    
+void releaseFastMallocFreeMemory() { }
+
+FastMallocStatistics fastMallocStatistics()
+{
+    FastMallocStatistics statistics = { 0, 0, 0 };
+    return statistics;
+}
+
+} // namespace WTF
+
 #else // FORCE_SYSTEM_MALLOC
 
 #include "TCPackedCache.h"