Changeset 179923 in webkit


Ignore:
Timestamp:
Feb 11, 2015 4:15:23 AM (9 years ago)
Author:
gyuyoung.kim@samsung.com
Message:

[EFL][GTK] Use bmalloc instead of tcmalloc
https://bugs.webkit.org/show_bug.cgi?id=140162

Reviewed by Carlos Garcia Campos.

.:

Add bmalloc directory to build list.

  • CMakeLists.txt: Define BMALLOC_DIR directory.
  • Source/CMakeLists.txt: Add bmalloc path to sub-directories list.

Source/bmalloc:

Support to use bmalloc on EFL and GTK ports.

  • CMakeLists.txt: Added.
  • bmalloc/Allocator.cpp:

(bmalloc::Allocator::allocate):

Fix unused return value caused by posix_memalign().

  • bmalloc/AsyncTask.h:
  • bmalloc/BoundaryTag.h:

(bmalloc::BoundaryTag::clear):

  • bmalloc/Chunk.h:

Change Traits::Page with Traits::PageType in order to fix
-fpermitive build error on EFL and GTK port.

  • bmalloc/EndTag.h:

(bmalloc::EndTag::operator=):

  • bmalloc/Line.h: ditto.
  • bmalloc/MediumTraits.h:
  • bmalloc/Page.h: ditto.
  • bmalloc/PerThread.h:

EFL port doesn't support has_include definition yet.
Define HAVE_PTHREAD_MACHDEP_H according to check if
has_include is supported.

  • bmalloc/SmallTraits.h: ditto.
  • bmalloc/VMAllocate.h:

(bmalloc::vmDeallocatePhysicalPages):
(bmalloc::vmAllocatePhysicalPages):

  • bmalloc/Vector.h:

(bmalloc::Vector<T>::push):
(bmalloc::Vector<T>::reallocateBuffer):

Source/WTF:

  • wtf/CMakeLists.txt:
  • wtf/FastMalloc.cpp:

Enable bmalloc on GTK ports, but EFL port will enable it when bmalloc supports
memory statistics.

Location:
trunk
Files:
1 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/CMakeLists.txt

    r179251 r179923  
    55# Default library type
    66# -----------------------------------------------------------------------------
     7set(BMALLOC_DIR "${CMAKE_SOURCE_DIR}/Source/bmalloc")
    78set(WTF_DIR "${CMAKE_SOURCE_DIR}/Source/WTF")
    89set(JAVASCRIPTCORE_DIR "${CMAKE_SOURCE_DIR}/Source/JavaScriptCore")
  • trunk/ChangeLog

    r179922 r179923  
     12015-02-11  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
     2
     3        [EFL][GTK] Use bmalloc instead of tcmalloc
     4        https://bugs.webkit.org/show_bug.cgi?id=140162
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Add bmalloc directory to build list.
     9
     10        * CMakeLists.txt: Define BMALLOC_DIR directory.
     11        * Source/CMakeLists.txt: Add bmalloc path to sub-directories list.
     12
    1132015-02-11  Carlos Garcia Campos  <cgarcia@igalia.com>
    214
  • trunk/Source/CMakeLists.txt

    r172902 r179923  
    22# Add module directories
    33# -----------------------------------------------------------------------------
     4add_subdirectory(bmalloc)
     5
    46add_subdirectory(WTF)
    57
     
    2729# Set compiler flags for all targets
    2830# -----------------------------------------------------------------------------
     31WEBKIT_SET_EXTRA_COMPILER_FLAGS(bmalloc ${ADDITIONAL_COMPILER_FLAGS})
    2932WEBKIT_SET_EXTRA_COMPILER_FLAGS(WTF ${ADDITIONAL_COMPILER_FLAGS})
    3033WEBKIT_SET_EXTRA_COMPILER_FLAGS(JavaScriptCore ${ADDITIONAL_COMPILER_FLAGS})
  • trunk/Source/WTF/ChangeLog

    r179915 r179923  
     12015-02-11  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
     2
     3        [EFL][GTK] Use bmalloc instead of tcmalloc
     4        https://bugs.webkit.org/show_bug.cgi?id=140162
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * wtf/CMakeLists.txt:
     9        * wtf/FastMalloc.cpp:
     10            Enable bmalloc on GTK ports, but EFL port will enable it when bmalloc supports
     11            memory statistics.
     12
    1132015-02-10  Darin Adler  <darin@apple.com>
    214
  • trunk/Source/WTF/wtf/CMakeLists.txt

    r177455 r179923  
    214214
    215215set(WTF_INCLUDE_DIRECTORIES
     216    "${BMALLOC_DIR}"
    216217    "${WTF_DIR}"
    217218    "${WTF_DIR}/wtf"
     
    227228set(WTF_LIBRARIES
    228229    ${CMAKE_DL_LIBS}
     230    bmalloc
    229231)
    230232
  • trunk/Source/WTF/wtf/FastMalloc.cpp

    r179915 r179923  
    101101#endif
    102102
    103 #if PLATFORM(COCOA)
     103#if PLATFORM(COCOA) || PLATFORM(GTK)
    104104#define USE_BMALLOC 1
    105105#endif
  • trunk/Source/bmalloc/ChangeLog

    r179450 r179923  
     12015-02-11  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
     2
     3        [EFL][GTK] Use bmalloc instead of tcmalloc
     4        https://bugs.webkit.org/show_bug.cgi?id=140162
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Support to use bmalloc on EFL and GTK ports.
     9
     10        * CMakeLists.txt: Added.
     11        * bmalloc/Allocator.cpp:
     12        (bmalloc::Allocator::allocate):
     13            Fix unused return value caused by posix_memalign().
     14        * bmalloc/AsyncTask.h:
     15        * bmalloc/BoundaryTag.h:
     16        (bmalloc::BoundaryTag::clear):
     17        * bmalloc/Chunk.h:
     18            Change Traits::Page with Traits::PageType in order to fix
     19            -fpermitive build error on EFL and GTK port.
     20        * bmalloc/EndTag.h:
     21        (bmalloc::EndTag::operator=):
     22        * bmalloc/Line.h: ditto.
     23        * bmalloc/MediumTraits.h:
     24        * bmalloc/Page.h: ditto.
     25        * bmalloc/PerThread.h:
     26            EFL port doesn't support __has_include definition yet.
     27            Define HAVE_PTHREAD_MACHDEP_H according to check if __has_include is supported.
     28        * bmalloc/SmallTraits.h: ditto.
     29        * bmalloc/VMAllocate.h:
     30        (bmalloc::vmDeallocatePhysicalPages):
     31        (bmalloc::vmAllocatePhysicalPages):
     32        * bmalloc/Vector.h:
     33        (bmalloc::Vector<T>::push):
     34        (bmalloc::Vector<T>::reallocateBuffer):
     35
    1362015-01-31  Sam Weinig  <sam@webkit.org>
    237
  • trunk/Source/bmalloc/bmalloc/Allocator.cpp

    r178861 r179923  
    5757    if (!m_isBmallocEnabled) {
    5858        void* result = nullptr;
    59         posix_memalign(&result, alignment, size);
     59        if (posix_memalign(&result, alignment, size))
     60            return nullptr;
    6061        return result;
    6162    }
  • trunk/Source/bmalloc/bmalloc/AsyncTask.h

    r167540 r179923  
    6565};
    6666
    67 template<typename Object, typename Function> const std::chrono::seconds AsyncTask<Object, Function>::exitDelay;
     67template<typename Object, typename Function> const constexpr std::chrono::seconds AsyncTask<Object, Function>::exitDelay;
    6868
    6969template<typename Object, typename Function>
  • trunk/Source/bmalloc/bmalloc/BoundaryTag.h

    r178861 r179923  
    3030#include "Range.h"
    3131#include "Sizes.h"
     32#include <cstring>
    3233
    3334namespace bmalloc {
     
    5556
    5657    bool isNull() { return !m_size; }
    57     void clear() { memset(this, 0, sizeof(*this)); }
     58    void clear() { std::memset(this, 0, sizeof(*this)); }
    5859   
    5960    size_t size() { return m_size; }
  • trunk/Source/bmalloc/bmalloc/Chunk.h

    r175751 r179923  
    3636class Chunk {
    3737public:
    38     typedef typename Traits::Page Page;
    39     typedef typename Traits::Line Line;
     38    typedef typename Traits::PageType Page;
     39    typedef typename Traits::LineType Line;
     40
    4041    static const size_t lineSize = Traits::lineSize;
    4142    static const size_t chunkSize = Traits::chunkSize;
     
    6364    // Align to vmPageSize to avoid sharing physical pages with metadata.
    6465    // Otherwise, we'll confuse the scavenger into trying to scavenge metadata.
    65     alignas(vmPageSize) char m_memory[];
     66#if BPLATFORM(IOS)
     67    char m_memory[] __attribute__((aligned(16384)));
     68    static_assert(vmPageSize == 16384, "vmPageSize and alignment must be same");
     69#else
     70    char m_memory[] __attribute__((aligned(4096)));
     71    static_assert(vmPageSize == 4096, "vmPageSize and alignment must be same");
     72#endif
    6673};
    6774
  • trunk/Source/bmalloc/bmalloc/EndTag.h

    r166893 r179923  
    3838inline EndTag& EndTag::operator=(const BeginTag& other)
    3939{
    40     memcpy(this, &other, sizeof(BoundaryTag));
     40    std::memcpy(this, &other, sizeof(BoundaryTag));
    4141    setEnd(true);
    4242    return *this;
  • trunk/Source/bmalloc/bmalloc/LargeChunk.h

    r175751 r179923  
    6868    // Align to vmPageSize to avoid sharing physical pages with metadata.
    6969    // Otherwise, we'll confuse the scavenger into trying to scavenge metadata.
    70     alignas(vmPageSize) char m_memory[];
     70#if BPLATFORM(IOS)
     71    char m_memory[] __attribute__((aligned(16384)));
     72    static_assert(vmPageSize == 16384, "vmPageSize and alignment must be same");
     73#else
     74    char m_memory[] __attribute__((aligned(4096)));
     75    static_assert(vmPageSize == 4096, "vmPageSize and alignment must be same");
     76#endif
    7177};
    7278
  • trunk/Source/bmalloc/bmalloc/Line.h

    r173881 r179923  
    3737class Line {
    3838public:
    39     typedef typename Traits::Chunk Chunk;
     39    typedef typename Traits::ChunkType Chunk;
     40
    4041    static const size_t minimumObjectSize = Traits::minimumObjectSize;
    4142    static const size_t lineSize = Traits::lineSize;
  • trunk/Source/bmalloc/bmalloc/MediumTraits.h

    r166893 r179923  
    3737
    3838struct MediumTraits {
    39     typedef Chunk<MediumTraits> Chunk;
    40     typedef Line<MediumTraits> Line;
    41     typedef Page<MediumTraits> Page;
     39    typedef Chunk<MediumTraits> ChunkType;
     40    typedef Line<MediumTraits> LineType;
     41    typedef Page<MediumTraits> PageType;
    4242
    4343    static const size_t lineSize = mediumLineSize;
  • trunk/Source/bmalloc/bmalloc/Page.h

    r173881 r179923  
    3737class Page {
    3838public:
    39     typedef typename Traits::Chunk Chunk;
    40     typedef typename Traits::Line Line;
     39    typedef typename Traits::ChunkType Chunk;
     40    typedef typename Traits::LineType Line;
     41
    4142    static const size_t lineSize = Traits::lineSize;
    4243    static const size_t lineCount = vmPageSize / lineSize;
  • trunk/Source/bmalloc/bmalloc/PerThread.h

    r177931 r179923  
    3131#include <mutex>
    3232#include <pthread.h>
    33 #if defined(__has_include) && __has_include(<System/pthread_machdep.h>)
     33
     34#if defined(__has_include)
     35#if __has_include(<System/pthread_machdep.h>)
    3436#include <System/pthread_machdep.h>
     37#define HAVE_PTHREAD_MACHDEP_H 1
     38#else
     39#define HAVE_PTHREAD_MACHDEP_H 0
     40#endif
     41#else
     42#define HAVE_PTHREAD_MACHDEP_H 0
    3543#endif
    3644
     
    5159};
    5260
    53 #if defined(__has_include) && __has_include(<System/pthread_machdep.h>)
     61#if HAVE_PTHREAD_MACHDEP_H
    5462
    5563class Cache;
     
    101109template<typename T> std::once_flag PerThreadStorage<T>::s_onceFlag;
    102110
    103 #endif // defined(__has_include) && __has_include(<System/pthread_machdep.h>)
     111#endif
    104112
    105113template<typename T>
  • trunk/Source/bmalloc/bmalloc/SmallTraits.h

    r167546 r179923  
    3636
    3737struct SmallTraits {
    38     typedef Chunk<SmallTraits> Chunk;
    39     typedef Line<SmallTraits> Line;
    40     typedef Page<SmallTraits> Page;
     38    typedef Chunk<SmallTraits> ChunkType;
     39    typedef Line<SmallTraits> LineType;
     40    typedef Page<SmallTraits> PageType;
    4141
    4242    static const size_t lineSize = smallLineSize;
  • trunk/Source/bmalloc/bmalloc/VMAllocate.h

    r178861 r179923  
    3232#include "Syscall.h"
    3333#include <algorithm>
    34 #include <mach/vm_statistics.h>
    3534#include <sys/mman.h>
    3635#include <unistd.h>
    3736
     37#if BOS(DARWIN)
     38#include <mach/vm_statistics.h>
     39#endif
     40
    3841namespace bmalloc {
    3942
     43#if BOS(DARWIN)
    4044#define BMALLOC_VM_TAG VM_MAKE_TAG(VM_MEMORY_TCMALLOC)
     45#else
     46#define BMALLOC_VM_TAG -1
     47#endif
    4148
    4249inline size_t vmSize(size_t size)
     
    108115{
    109116    vmValidate(p, vmSize);
     117#if BOS(DARWIN)
    110118    SYSCALL(madvise(p, vmSize, MADV_FREE_REUSABLE));
     119#else
     120    SYSCALL(madvise(p, vmSize, MADV_DONTNEED));
     121#endif
    111122}
    112123
     
    114125{
    115126    vmValidate(p, vmSize);
     127#if BOS(DARWIN)
    116128    SYSCALL(madvise(p, vmSize, MADV_FREE_REUSE));
     129#else
     130    SYSCALL(madvise(p, vmSize, MADV_NORMAL));
     131#endif
    117132}
    118133
  • trunk/Source/bmalloc/bmalloc/Vector.h

    r173589 r179923  
    3030#include "VMAllocate.h"
    3131#include <cstddef>
    32 #include <string>
     32#include <cstring>
    3333
    3434namespace bmalloc {
     
    113113    if (newSize > m_capacity)
    114114        growCapacity(newSize);
    115     memcpy(this->end(), begin, (end - begin) * sizeof(T));
     115    std::memcpy(this->end(), begin, (end - begin) * sizeof(T));
    116116    m_size = newSize;
    117117}
     
    149149    T* newBuffer = static_cast<T*>(vmAllocate(vmSize));
    150150    if (m_buffer) {
    151         memcpy(newBuffer, m_buffer, m_size * sizeof(T));
     151        std::memcpy(newBuffer, m_buffer, m_size * sizeof(T));
    152152        vmDeallocate(m_buffer, bmalloc::vmSize(m_capacity * sizeof(T)));
    153153    }
Note: See TracChangeset for help on using the changeset viewer.