Changeset 82905 in webkit


Ignore:
Timestamp:
Apr 4, 2011 10:33:40 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-04 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r82876.
http://trac.webkit.org/changeset/82876
https://bugs.webkit.org/show_bug.cgi?id=57816

Caused a lot of test crashes (Requested by tkent on #webkit).

  • JavaScriptCore.exp:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • wtf/FastMalloc.cpp: (WTF::tryFastMalloc): (WTF::fastMalloc): (WTF::tryFastCalloc): (WTF::fastCalloc): (WTF::fastFree): (WTF::tryFastRealloc): (WTF::fastRealloc): (WTF::fastMallocSize): (WTF::TCMalloc_PageHeap::isScavengerSuspended): (WTF::TCMalloc_PageHeap::scheduleScavenger): (WTF::TCMalloc_PageHeap::suspendScavenger): (WTF::TCMalloc_PageHeap::signalScavenger): (WTF::TCMallocStats::malloc): (WTF::TCMallocStats::free): (WTF::TCMallocStats::fastCalloc): (WTF::TCMallocStats::tryFastCalloc): (WTF::TCMallocStats::calloc): (WTF::TCMallocStats::fastRealloc): (WTF::TCMallocStats::tryFastRealloc): (WTF::TCMallocStats::realloc): (WTF::TCMallocStats::fastMallocSize):
  • wtf/FastMalloc.h: (WTF::Internal::fastMallocMatchValidationType): (WTF::Internal::fastMallocMatchValidationValue): (WTF::Internal::setFastMallocMatchValidationType): (WTF::fastMallocMatchValidateFree):
  • wtf/Platform.h:
Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r82898 r82905  
     12011-04-04  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r82876.
     4        http://trac.webkit.org/changeset/82876
     5        https://bugs.webkit.org/show_bug.cgi?id=57816
     6
     7        Caused a lot of test crashes (Requested by tkent on #webkit).
     8
     9        * JavaScriptCore.exp:
     10        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     11        * wtf/FastMalloc.cpp:
     12        (WTF::tryFastMalloc):
     13        (WTF::fastMalloc):
     14        (WTF::tryFastCalloc):
     15        (WTF::fastCalloc):
     16        (WTF::fastFree):
     17        (WTF::tryFastRealloc):
     18        (WTF::fastRealloc):
     19        (WTF::fastMallocSize):
     20        (WTF::TCMalloc_PageHeap::isScavengerSuspended):
     21        (WTF::TCMalloc_PageHeap::scheduleScavenger):
     22        (WTF::TCMalloc_PageHeap::suspendScavenger):
     23        (WTF::TCMalloc_PageHeap::signalScavenger):
     24        (WTF::TCMallocStats::malloc):
     25        (WTF::TCMallocStats::free):
     26        (WTF::TCMallocStats::fastCalloc):
     27        (WTF::TCMallocStats::tryFastCalloc):
     28        (WTF::TCMallocStats::calloc):
     29        (WTF::TCMallocStats::fastRealloc):
     30        (WTF::TCMallocStats::tryFastRealloc):
     31        (WTF::TCMallocStats::realloc):
     32        (WTF::TCMallocStats::fastMallocSize):
     33        * wtf/FastMalloc.h:
     34        (WTF::Internal::fastMallocMatchValidationType):
     35        (WTF::Internal::fastMallocMatchValidationValue):
     36        (WTF::Internal::setFastMallocMatchValidationType):
     37        (WTF::fastMallocMatchValidateFree):
     38        * wtf/Platform.h:
     39
    1402011-04-04  Oliver Hunt  <oliver@apple.com>
    241
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r82876 r82905  
    493493__ZN3WTF8CollatorC1EPKc
    494494__ZN3WTF8CollatorD1Ev
    495 __ZN3WTF8Internal21fastMallocMatchFailedEPv
    496495__ZN3WTF8fastFreeEPv
    497496__ZN3WTF8msToYearEd
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r82876 r82905  
    162162    ?fastFree@WTF@@YAXPAX@Z
    163163    ?fastMalloc@WTF@@YAPAXI@Z
    164     ?fastMallocMatchFailed@Internal@WTF@@YAXPAX@Z
    165164    ?fastMallocSize@WTF@@YAIPBX@Z
    166165    ?fastRealloc@WTF@@YAPAXPAXI@Z
  • trunk/Source/JavaScriptCore/wtf/FastMalloc.cpp

    r82888 r82905  
    162162namespace WTF {
    163163
     164#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
    164165
    165166namespace Internal {
    166 #if !ENABLE(WTF_MALLOC_VALIDATION)
    167 void fastMallocMatchFailed(void*);
    168 #else
    169 COMPILE_ASSERT(((sizeof(ValidationHeader) % sizeof(AllocAlignmentInteger)) == 0), ValidationHeader_must_produce_correct_alignment);
    170 #endif
     167
    171168void fastMallocMatchFailed(void*)
    172169{
     
    176173} // namespace Internal
    177174
     175#endif
    178176
    179177void* fastZeroedMalloc(size_t n)
     
    224222    ASSERT(!isForbidden());
    225223
    226 #if ENABLE(WTF_MALLOC_VALIDATION)
    227     if (std::numeric_limits<size_t>::max() - Internal::ValidationBufferSize <= n)  // If overflow would occur...
     224#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
     225    if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= n)  // If overflow would occur...
    228226        return 0;
    229227
    230     void* result = malloc(n + Internal::ValidationBufferSize);
     228    void* result = malloc(n + sizeof(AllocAlignmentInteger));
    231229    if (!result)
    232230        return 0;
    233     Internal::ValidationHeader* header = static_cast<Internal::ValidationHeader*>(result);
    234     header->m_size = n;
    235     header->m_type = Internal::AllocTypeMalloc;
    236     header->m_prefix = static_cast<unsigned>(Internal::ValidationPrefix);
    237     result = header + 1;
    238     *Internal::fastMallocValidationSuffix(result) = Internal::ValidationSuffix;
    239     fastMallocValidate(result);
     231
     232    *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
     233    result = static_cast<AllocAlignmentInteger*>(result) + 1;
     234
    240235    return result;
    241236#else
     
    248243    ASSERT(!isForbidden());
    249244
    250 #if ENABLE(WTF_MALLOC_VALIDATION)
     245#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
    251246    TryMallocReturnValue returnValue = tryFastMalloc(n);
    252247    void* result;
     
    274269    ASSERT(!isForbidden());
    275270
    276 #if ENABLE(WTF_MALLOC_VALIDATION)
     271#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
    277272    size_t totalBytes = n_elements * element_size;
    278     if (n_elements > 1 && element_size && (totalBytes / element_size) != n_elements)
     273    if (n_elements > 1 && element_size && (totalBytes / element_size) != n_elements || (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= totalBytes))
    279274        return 0;
    280275
    281     TryMallocReturnValue returnValue = tryFastMalloc(totalBytes);
    282     void* result;
    283     if (!returnValue.getValue(result))
     276    totalBytes += sizeof(AllocAlignmentInteger);
     277    void* result = malloc(totalBytes);
     278    if (!result)
    284279        return 0;
     280
    285281    memset(result, 0, totalBytes);
    286     fastMallocValidate(result);
     282    *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
     283    result = static_cast<AllocAlignmentInteger*>(result) + 1;
    287284    return result;
    288285#else
     
    295292    ASSERT(!isForbidden());
    296293
    297 #if ENABLE(WTF_MALLOC_VALIDATION)
     294#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
    298295    TryMallocReturnValue returnValue = tryFastCalloc(n_elements, element_size);
    299296    void* result;
     
    321318    ASSERT(!isForbidden());
    322319
    323 #if ENABLE(WTF_MALLOC_VALIDATION)
     320#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
    324321    if (!p)
    325322        return;
    326    
    327     fastMallocMatchValidateFree(p, Internal::AllocTypeMalloc);
    328     Internal::ValidationHeader* header = Internal::fastMallocValidationHeader(p);
    329     memset(p, 0xCC, header->m_size);
     323
     324    AllocAlignmentInteger* header = Internal::fastMallocMatchValidationValue(p);
     325    if (*header != Internal::AllocTypeMalloc)
     326        Internal::fastMallocMatchFailed(p);
    330327    free(header);
    331328#else
     
    338335    ASSERT(!isForbidden());
    339336
    340 #if ENABLE(WTF_MALLOC_VALIDATION)
     337#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
    341338    if (p) {
    342         if (std::numeric_limits<size_t>::max() - Internal::ValidationBufferSize <= n)  // If overflow would occur...
     339        if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= n)  // If overflow would occur...
    343340            return 0;
    344         fastMallocValidate(p);
    345         Internal::ValidationHeader* result = static_cast<Internal::ValidationHeader*>(realloc(Internal::fastMallocValidationHeader(p), n + Internal::ValidationBufferSize));
     341        AllocAlignmentInteger* header = Internal::fastMallocMatchValidationValue(p);
     342        if (*header != Internal::AllocTypeMalloc)
     343            Internal::fastMallocMatchFailed(p);
     344        void* result = realloc(header, n + sizeof(AllocAlignmentInteger));
    346345        if (!result)
    347346            return 0;
    348         result->m_size = n;
    349         result = result + 1;
    350         *fastMallocValidationSuffix(result) = Internal::ValidationSuffix;
    351         fastMallocValidate(result);
     347
     348        // This should not be needed because the value is already there:
     349        // *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
     350        result = static_cast<AllocAlignmentInteger*>(result) + 1;
    352351        return result;
    353352    } else {
     
    363362    ASSERT(!isForbidden());
    364363
    365 #if ENABLE(WTF_MALLOC_VALIDATION)
     364#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
    366365    TryMallocReturnValue returnValue = tryFastRealloc(p, n);
    367366    void* result;
     
    387386size_t fastMallocSize(const void* p)
    388387{
    389 #if ENABLE(WTF_MALLOC_VALIDATION)
    390     return Internal::fastMallocValidationHeader(const_cast<void*>(p))->m_size;
    391 #elif OS(DARWIN)
     388#if OS(DARWIN)
    392389    return malloc_size(p);
    393390#elif OS(WINDOWS) && !PLATFORM(BREWMP)
     
    13071304#endif
    13081305
    1309 static SpinLock pageheap_lock = SPINLOCK_INITIALIZER;
    1310 
    13111306class TCMalloc_PageHeap {
    13121307 public:
     
    15351530ALWAYS_INLINE bool TCMalloc_PageHeap::isScavengerSuspended()
    15361531{
    1537     ASSERT(pageheap_lock.IsHeld());
     1532    ASSERT(IsHeld(pageheap_lock));
    15381533    return m_scavengingSuspended;
    15391534}
     
    15411536ALWAYS_INLINE void TCMalloc_PageHeap::scheduleScavenger()
    15421537{
    1543     ASSERT(pageheap_lock.IsHeld());
     1538    ASSERT(IsHeld(pageheap_lock));
    15441539    m_scavengingSuspended = false;
    15451540    dispatch_resume(m_scavengeTimer);
     
    15531548ALWAYS_INLINE void TCMalloc_PageHeap::suspendScavenger()
    15541549{
    1555     ASSERT(pageheap_lock.IsHeld());
     1550    ASSERT(IsHeld(pageheap_lock));
    15561551    m_scavengingSuspended = true;
    15571552    dispatch_suspend(m_scavengeTimer);
     
    24462441
    24472442// Page-level allocator
     2443static SpinLock pageheap_lock = SPINLOCK_INITIALIZER;
    24482444static AllocAlignmentInteger pageheap_memory[(sizeof(TCMalloc_PageHeap) + sizeof(AllocAlignmentInteger) - 1) / sizeof(AllocAlignmentInteger)];
    24492445static bool phinited = false;
     
    24832479ALWAYS_INLINE void TCMalloc_PageHeap::signalScavenger()
    24842480{
    2485     ASSERT(pageheap_lock.IsHeld());
     2481    ASSERT(IsHeld(pageheap_lock));
    24862482    if (isScavengerSuspended() && shouldScavenge())
    24872483        scheduleScavenger();
     
    38293825#endif
    38303826void* malloc(size_t size) {
    3831 #if ENABLE(WTF_MALLOC_VALIDATION)
    3832     if (std::numeric_limits<size_t>::max() - Internal::ValidationBufferSize <= size)  // If overflow would occur...
     3827#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
     3828    if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= size)  // If overflow would occur...
    38333829        return 0;
    3834     void* result = do_malloc(size + Internal::ValidationBufferSize);
     3830    size += sizeof(AllocAlignmentInteger);
     3831    void* result = do_malloc(size);
    38353832    if (!result)
    38363833        return 0;
    38373834
    3838     Internal::ValidationHeader* header = static_cast<Internal::ValidationHeader*>(result);
    3839     header->m_size = size;
    3840     header->m_type = Internal::AllocTypeMalloc;
    3841     header->m_prefix = static_cast<unsigned>(Internal::ValidationPrefix);
    3842     result = header + 1;
    3843     *Internal::fastMallocValidationSuffix(result) = Internal::ValidationSuffix;
    3844     fastMallocValidate(result);
     3835    *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
     3836    result = static_cast<AllocAlignmentInteger*>(result) + 1;
    38453837#else
    38463838    void* result = do_malloc(size);
     
    38613853#endif
    38623854
    3863 #if ENABLE(WTF_MALLOC_VALIDATION)
     3855#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
    38643856    if (!ptr)
    38653857        return;
    38663858
    3867     fastMallocValidate(ptr);
    3868     Internal::ValidationHeader* header = Internal::fastMallocValidationHeader(ptr);
    3869     memset(ptr, 0xCC, header->m_size);
     3859    AllocAlignmentInteger* header = Internal::fastMallocMatchValidationValue(ptr);
     3860    if (*header != Internal::AllocTypeMalloc)
     3861        Internal::fastMallocMatchFailed(ptr);
    38703862    do_free(header);
    38713863#else
     
    38823874void* fastCalloc(size_t n, size_t elem_size)
    38833875{
    3884     void* result = calloc<true>(n, elem_size);
    3885 #if ENABLE(WTF_MALLOC_VALIDATION)
    3886     fastMallocValidate(result);
    3887 #endif
    3888     return result;
     3876    return calloc<true>(n, elem_size);
    38893877}
    38903878
    38913879TryMallocReturnValue tryFastCalloc(size_t n, size_t elem_size)
    38923880{
    3893     void* result = calloc<false>(n, elem_size);
    3894 #if ENABLE(WTF_MALLOC_VALIDATION)
    3895     fastMallocValidate(result);
    3896 #endif
    3897     return result;
     3881    return calloc<false>(n, elem_size);
    38983882}
    38993883
     
    39083892    return 0;
    39093893
    3910 #if ENABLE(WTF_MALLOC_VALIDATION)
    3911     void* result = malloc<crashOnFailure>(totalBytes);
     3894#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
     3895    if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= totalBytes)  // If overflow would occur...
     3896        return 0;
     3897
     3898    totalBytes += sizeof(AllocAlignmentInteger);
     3899    void* result = do_malloc(totalBytes);
    39123900    if (!result)
    39133901        return 0;
    39143902
    39153903    memset(result, 0, totalBytes);
    3916     fastMallocValidate(result);
     3904    *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
     3905    result = static_cast<AllocAlignmentInteger*>(result) + 1;
    39173906#else
    39183907    void* result = do_malloc(totalBytes);
     
    39493938void* fastRealloc(void* old_ptr, size_t new_size)
    39503939{
    3951 #if ENABLE(WTF_MALLOC_VALIDATION)
    3952     fastMallocValidate(old_ptr);
    3953 #endif
    3954     void* result = realloc<true>(old_ptr, new_size);
    3955 #if ENABLE(WTF_MALLOC_VALIDATION)
    3956     fastMallocValidate(result);
    3957 #endif
    3958     return result;
     3940    return realloc<true>(old_ptr, new_size);
    39593941}
    39603942
    39613943TryMallocReturnValue tryFastRealloc(void* old_ptr, size_t new_size)
    39623944{
    3963 #if ENABLE(WTF_MALLOC_VALIDATION)
    3964     fastMallocValidate(old_ptr);
    3965 #endif
    3966     void* result = realloc<false>(old_ptr, new_size);
    3967 #if ENABLE(WTF_MALLOC_VALIDATION)
    3968     fastMallocValidate(result);
    3969 #endif
    3970     return result;
     3945    return realloc<false>(old_ptr, new_size);
    39713946}
    39723947
     
    39763951void* realloc(void* old_ptr, size_t new_size) {
    39773952  if (old_ptr == NULL) {
    3978 #if ENABLE(WTF_MALLOC_VALIDATION)
    3979     void* result = malloc<crashOnFailure>(new_size);
     3953#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
     3954    void* result = malloc(new_size);
    39803955#else
    39813956    void* result = do_malloc(new_size);
     
    39943969  }
    39953970
    3996 #if ENABLE(WTF_MALLOC_VALIDATION)
    3997     if (std::numeric_limits<size_t>::max() - Internal::ValidationBufferSize <= new_size)  // If overflow would occur...
     3971#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
     3972    if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= new_size)  // If overflow would occur...
    39983973        return 0;
    3999     Internal::ValidationHeader* header = Internal::fastMallocValidationHeader(old_ptr);
    4000     fastMallocValidate(old_ptr);
     3974    new_size += sizeof(AllocAlignmentInteger);
     3975    AllocAlignmentInteger* header = Internal::fastMallocMatchValidationValue(old_ptr);
     3976    if (*header != Internal::AllocTypeMalloc)
     3977        Internal::fastMallocMatchFailed(old_ptr);
    40013978    old_ptr = header;
    4002     header->m_size = new_size;
    4003     new_size += Internal::ValidationBufferSize;
    40043979#endif
    40053980
     
    40404015    // would be small, so don't bother.
    40414016    do_free(old_ptr);
    4042 #if ENABLE(WTF_MALLOC_VALIDATION)
    4043     new_ptr = static_cast<Internal::ValidationHeader*>(new_ptr) + 1;
    4044     *Internal::fastMallocValidationSuffix(new_ptr) = Internal::ValidationSuffix;
     4017#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
     4018    new_ptr = static_cast<AllocAlignmentInteger*>(new_ptr) + 1;
    40454019#endif
    40464020    return new_ptr;
    40474021  } else {
    4048 #if ENABLE(WTF_MALLOC_VALIDATION)
    4049     old_ptr = static_cast<Internal::ValidationHeader*>(old_ptr) + 1; // Set old_ptr back to the user pointer.
    4050     *Internal::fastMallocValidationSuffix(old_ptr) = Internal::ValidationSuffix;
     4022#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
     4023    old_ptr = static_cast<AllocAlignmentInteger*>(old_ptr) + 1; // Set old_ptr back to the user pointer.
    40514024#endif
    40524025    return old_ptr;
     
    43094282size_t fastMallocSize(const void* ptr)
    43104283{
    4311 #if ENABLE(WTF_MALLOC_VALIDATION)
    4312     return Internal::fastMallocValidationHeader(p)->m_size;
    4313 #else
    43144284    const PageID p = reinterpret_cast<uintptr_t>(ptr) >> kPageShift;
    43154285    Span* span = pageheap->GetDescriptorEnsureSafe(p);
     
    43274297
    43284298    return span->length << kPageShift;
    4329 #endif
    43304299}
    43314300
  • trunk/Source/JavaScriptCore/wtf/FastMalloc.h

    r82876 r82905  
    104104            AllocTypeNewArray               // Encompasses global operator new[].
    105105        };
    106 
    107         enum {
    108             ValidationPrefix = 0xf00df00d,
    109             ValidationSuffix = 0x0badf00d
    110         };
    111 
    112         typedef unsigned ValidationTag;
    113 
    114         struct ValidationHeader {
    115             AllocType m_type;
    116             unsigned m_size;
    117             ValidationTag m_prefix;
    118             unsigned m_alignment;
    119         };
    120 
    121         static const int ValidationBufferSize = sizeof(ValidationHeader) + sizeof(ValidationTag);
    122     }
    123 
    124 #if ENABLE(WTF_MALLOC_VALIDATION)
     106    }
     107
     108#if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
    125109
    126110    // Malloc validation is a scheme whereby a tag is attached to an
     
    137121
    138122    namespace Internal {
    139    
     123
     124        // Return the AllocType tag associated with the allocated block p.
     125        inline AllocType fastMallocMatchValidationType(const void* p)
     126        {
     127            const AllocAlignmentInteger* type = static_cast<const AllocAlignmentInteger*>(p) - 1;
     128            return static_cast<AllocType>(*type);
     129        }
     130
     131        // Return the address of the AllocType tag associated with the allocated block p.
     132        inline AllocAlignmentInteger* fastMallocMatchValidationValue(void* p)
     133        {
     134            return reinterpret_cast<AllocAlignmentInteger*>(static_cast<char*>(p) - sizeof(AllocAlignmentInteger));
     135        }
     136
     137        // Set the AllocType tag to be associaged with the allocated block p.
     138        inline void setFastMallocMatchValidationType(void* p, AllocType allocType)
     139        {
     140            AllocAlignmentInteger* type = static_cast<AllocAlignmentInteger*>(p) - 1;
     141            *type = static_cast<AllocAlignmentInteger>(allocType);
     142        }
     143
    140144        // Handle a detected alloc/free mismatch. By default this calls CRASH().
    141145        void fastMallocMatchFailed(void* p);
    142146
    143         inline ValidationHeader* fastMallocValidationHeader(void* p)
    144         {
    145             return reinterpret_cast<ValidationHeader*>(static_cast<char*>(p) - sizeof(ValidationHeader));
    146         }
    147 
    148         inline ValidationTag* fastMallocValidationSuffix(void* p)
    149         {
    150             ValidationHeader* header = fastMallocValidationHeader(p);
    151             if (header->m_prefix != static_cast<unsigned>(ValidationPrefix))
    152                 fastMallocMatchFailed(p);
    153            
    154             return reinterpret_cast<ValidationTag*>(static_cast<char*>(p) + header->m_size);
    155         }
    156 
    157         // Return the AllocType tag associated with the allocated block p.
    158         inline AllocType fastMallocMatchValidationType(void* p)
    159         {
    160             return fastMallocValidationHeader(p)->m_type;
    161         }
    162 
    163         // Set the AllocType tag to be associaged with the allocated block p.
    164         inline void setFastMallocMatchValidationType(void* p, AllocType allocType)
    165         {
    166             fastMallocValidationHeader(p)->m_type = allocType;
    167         }
    168 
    169147    } // namespace Internal
    170148
     
    179157
    180158    // This is a higher level function which is used by FastMalloc-using code.
    181     inline void fastMallocMatchValidateFree(void* p, Internal::AllocType)
     159    inline void fastMallocMatchValidateFree(void* p, Internal::AllocType allocType)
    182160    {
    183161        if (!p)
    184162            return;
    185    
    186         Internal::ValidationHeader* header = Internal::fastMallocValidationHeader(p);
    187         if (header->m_prefix != static_cast<unsigned>(Internal::ValidationPrefix))
     163
     164        if (Internal::fastMallocMatchValidationType(p) != allocType)
    188165            Internal::fastMallocMatchFailed(p);
    189 
    190         if (*Internal::fastMallocValidationSuffix(p) != Internal::ValidationSuffix)
    191             Internal::fastMallocMatchFailed(p);
    192 
    193166        Internal::setFastMallocMatchValidationType(p, Internal::AllocTypeMalloc);  // Set it to this so that fastFree thinks it's OK.
    194     }
    195 
    196     inline void fastMallocValidate(void* p)
    197     {
    198         if (!p)
    199             return;
    200        
    201         Internal::ValidationHeader* header = Internal::fastMallocValidationHeader(p);
    202         if (header->m_prefix != static_cast<unsigned>(Internal::ValidationPrefix))
    203             Internal::fastMallocMatchFailed(p);
    204        
    205         if (*Internal::fastMallocValidationSuffix(p) != Internal::ValidationSuffix)
    206             Internal::fastMallocMatchFailed(p);
    207167    }
    208168
  • trunk/Source/JavaScriptCore/wtf/Platform.h

    r82884 r82905  
    876876/* fastMalloc match validation allows for runtime verification that
    877877   new is matched by delete, fastMalloc is matched by fastFree, etc. */
    878 #if !defined(ENABLE_WTF_MALLOC_VALIDATION)
    879 #ifndef NDEBUG
    880 #define ENABLE_WTF_MALLOC_VALIDATION 1
    881 #else
    882 #define ENABLE_WTF_MALLOC_VALIDATION 0
    883 #endif
     878#if !defined(ENABLE_FAST_MALLOC_MATCH_VALIDATION)
     879#define ENABLE_FAST_MALLOC_MATCH_VALIDATION 0
    884880#endif
    885881
Note: See TracChangeset for help on using the changeset viewer.