Changeset 69943 in webkit


Ignore:
Timestamp:
Oct 18, 2010 12:25:32 AM (14 years ago)
Author:
zoltan@webkit.org
Message:

Change FastAllocBase implementation into a macro
https://bugs.webkit.org/show_bug.cgi?id=42998

Reviewed by Darin Adler.

It was investigated in bug #33896 that inheriting classes from FastAllocBase
can result in objects getting larger which leads to memory regressions.
Using a macro instead of inheriting classes from FastAllocBase would solve the issue.

  • wtf/FastAllocBase.h: Add a WTF_MAKE_FAST_ALLOCATED macro
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r69941 r69943  
     12010-10-18  Zoltan Horvath  <zoltan@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Change FastAllocBase implementation into a macro
     6        https://bugs.webkit.org/show_bug.cgi?id=42998
     7
     8        It was investigated in bug #33896 that inheriting classes from FastAllocBase
     9        can result in objects getting larger which leads to memory regressions.
     10        Using a macro instead of inheriting classes from FastAllocBase would solve the issue.
     11
     12        * wtf/FastAllocBase.h: Add a WTF_MAKE_FAST_ALLOCATED macro
     13
    1142010-10-17  Oliver Hunt  <oliver@apple.com>
    215
  • trunk/JavaScriptCore/wtf/FastAllocBase.h

    r48259 r69943  
    8686namespace WTF {
    8787
    88     class FastAllocBase {
    89     public:
    90         // Placement operator new.
    91         void* operator new(size_t, void* p) { return p; }
    92         void* operator new[](size_t, void* p) { return p; }
    93 
    94         void* operator new(size_t size)
    95         {
    96             void* p = fastMalloc(size);
    97             fastMallocMatchValidateMalloc(p, Internal::AllocTypeClassNew);
    98             return p;
    99         }
    100 
    101         void operator delete(void* p)
    102         {
    103             fastMallocMatchValidateFree(p, Internal::AllocTypeClassNew);
    104             fastFree(p);
    105         }
    106 
    107         void* operator new[](size_t size)
    108         {
    109             void* p = fastMalloc(size);
    110             fastMallocMatchValidateMalloc(p, Internal::AllocTypeClassNewArray);
    111             return p;
    112         }
    113 
    114         void operator delete[](void* p)
    115         {
    116             fastMallocMatchValidateFree(p, Internal::AllocTypeClassNewArray);
    117             fastFree(p);
    118         }
    119     };
     88#define WTF_MAKE_FAST_ALLOCATED \
     89public: \
     90    void* operator new(size_t, void* p) { return p; } \
     91    void* operator new[](size_t, void* p) { return p; } \
     92    \
     93    void* operator new(size_t size) \
     94    { \
     95        void* p = ::WTF::fastMalloc(size); \
     96         ::WTF::fastMallocMatchValidateMalloc(p, ::WTF::Internal::AllocTypeClassNew); \
     97        return p; \
     98    } \
     99    \
     100    void operator delete(void* p) \
     101    { \
     102        ::WTF::fastMallocMatchValidateFree(p, ::WTF::Internal::AllocTypeClassNew); \
     103        ::WTF::fastFree(p); \
     104    } \
     105    \
     106    void* operator new[](size_t size) \
     107    { \
     108        void* p = ::WTF::fastMalloc(size); \
     109        ::WTF::fastMallocMatchValidateMalloc(p, ::WTF::Internal::AllocTypeClassNewArray); \
     110        return p; \
     111    } \
     112    \
     113    void operator delete[](void* p) \
     114    { \
     115         ::WTF::fastMallocMatchValidateFree(p, ::WTF::Internal::AllocTypeClassNewArray); \
     116         ::WTF::fastFree(p); \
     117    } \
     118private:
     119
     120class FastAllocBase {
     121    WTF_MAKE_FAST_ALLOCATED 
     122};
    120123
    121124    // fastNew / fastDelete
Note: See TracChangeset for help on using the changeset viewer.