Ignore:
Timestamp:
Apr 8, 2014, 1:36:17 PM (11 years ago)
Author:
[email protected]
Message:

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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/wtf/FastMalloc.cpp

    r166184 r166957  
    424424#endif
    425425
     426#elif defined(USE_BMALLOC) && USE_BMALLOC // FORCE_SYSTEM_MALLOC
     427
     428#include "bmalloc.h"
     429
     430namespace WTF {
     431
     432void* fastMalloc(size_t size)
     433{
     434    ASSERT(!isForbidden());
     435    return bmalloc::api::malloc(size);
     436}
     437
     438void* fastCalloc(size_t numElements, size_t elementSize)
     439{
     440    return fastZeroedMalloc(numElements * elementSize);
     441}
     442   
     443void* fastRealloc(void* object, size_t size)
     444{
     445    return bmalloc::api::realloc(object, size);
     446}
     447   
     448void fastFree(void* object)
     449{
     450    bmalloc::api::free(object);
     451}
     452   
     453size_t fastMallocSize(const void*)
     454{
     455    return 1;
     456}
     457   
     458size_t fastMallocGoodSize(size_t size)
     459{
     460    return size;
     461}
     462   
     463TryMallocReturnValue tryFastMalloc(size_t size)
     464{
     465    return fastMalloc(size);
     466}
     467   
     468TryMallocReturnValue tryFastRealloc(void* p, size_t n)
     469{
     470    return fastRealloc(p, n);
     471}
     472   
     473TryMallocReturnValue tryFastCalloc(size_t numElements, size_t elementSize)
     474{
     475    return fastCalloc(numElements, elementSize);
     476}
     477   
     478void releaseFastMallocFreeMemory() { }
     479
     480FastMallocStatistics fastMallocStatistics()
     481{
     482    FastMallocStatistics statistics = { 0, 0, 0 };
     483    return statistics;
     484}
     485
     486} // namespace WTF
     487
    426488#else // FORCE_SYSTEM_MALLOC
    427489
Note: See TracChangeset for help on using the changeset viewer.