Ignore:
Timestamp:
Aug 20, 2009, 11:04:37 AM (16 years ago)
Author:
[email protected]
Message:

Roll out r47571 and related build fixes as it caused us to leak the world without warning.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/ParserArena.cpp

    r47573 r47582  
    3131namespace JSC {
    3232
    33 ParserArena::ParserArena()
    34     : m_freeableMemory(0)
    35     , m_freeablePoolEnd(0)
    36     , m_identifierArena(new IdentifierArena)
    37 {
    38 }
    39 
    40 inline void* ParserArena::freeablePool()
    41 {
    42     ASSERT(m_freeablePoolEnd);
    43     return m_freeablePoolEnd - freeablePoolSize;
    44 }
    45 
    46 inline void ParserArena::deallocateObjects()
    47 {
    48     if (m_freeablePoolEnd)
    49         fastFree(freeablePool());
    50 
    51     size_t size = m_freeablePools.size();
    52     for (size_t i = 0; i < size; ++i)
    53         fastFree(m_freeablePools[i]);
    54 
    55     size = m_deletableObjects.size();
    56     for (size_t i = 0; i < size; ++i) {
    57         ParserArenaDeletable* object = m_deletableObjects[i];
    58         object->~ParserArenaDeletable();
    59         fastFree(object);
    60     }
    61 }
    62 
    6333ParserArena::~ParserArena()
    6434{
    65     deallocateObjects();
     35    deleteAllValues(m_deletableObjects);
    6636}
    6737
     
    8353void ParserArena::reset()
    8454{
    85     // Since this code path is used only when parsing fails, it's not bothering to reuse
    86     // any of the memory the arena allocated. We could improve that later if we want to
    87     // efficiently reuse the same arena.
    88 
    89     deallocateObjects();
    90 
    91     m_freeableMemory = 0;
    92     m_freeablePoolEnd = 0;
    93     m_identifierArena->clear();
    94     m_freeablePools.clear();
    95     m_deletableObjects.clear();
    96     m_refCountedObjects.clear();
    97 }
    98 
    99 void ParserArena::allocateFreeablePool()
    100 {
    101     if (m_freeablePoolEnd)
    102         m_freeablePools.append(freeablePool());
    103 
    104     char* pool = static_cast<char*>(fastMalloc(freeablePoolSize));
    105     m_freeableMemory = pool;
    106     m_freeablePoolEnd = pool + freeablePoolSize;
    107     ASSERT(freeablePool() == pool);
    108 }
    109 
    110 bool ParserArena::isEmpty() const
    111 {
    112     return !m_freeablePoolEnd
    113         && m_identifierArena->isEmpty()
    114         && m_freeablePools.isEmpty()
    115         && m_deletableObjects.isEmpty()
    116         && m_refCountedObjects.isEmpty();
    117 }
    118 
    119 void ParserArena::derefWithArena(PassRefPtr<ParserArenaRefCounted> object)
    120 {
    121     m_refCountedObjects.append(object);
     55    deleteAllValues(m_deletableObjects);
     56    m_deletableObjects.shrink(0);
     57    m_refCountedObjects.shrink(0);
    12258}
    12359
Note: See TracChangeset for help on using the changeset viewer.