Ignore:
Timestamp:
May 13, 2009, 2:53:59 PM (16 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2009-05-13 Darin Adler <Darin Adler>

Revert the parser arena change. It was a slowdown, not a speedup.
Better luck next time (I'll break it up into pieces).

WebCore:

2009-05-13 Darin Adler <Darin Adler>

Revert the parser arena change. It was a slowdown, not a speedup.
Better luck next time (I'll break it up into pieces).

WebKit/mac:

2009-05-13 Darin Adler <Darin Adler>

Revert the parser arena change. It was a slowdown, not a speedup.
Better luck next time (I'll break it up into pieces).

File:
1 edited

Legend:

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

    r43642 r43661  
    2727#define ParserArena_h
    2828
    29 #include "Identifier.h"
    30 #include "SegmentedVector.h"
     29#include <wtf/PassRefPtr.h>
     30#include <wtf/RefPtr.h>
     31#include <wtf/Vector.h>
    3132
    3233namespace JSC {
     
    3536    class ParserArenaRefCounted;
    3637
    37     typedef SegmentedVector<Identifier, 64> IdentifierArena;
    38 
    39     class ParserArena : Noncopyable {
     38    class ParserArena {
    4039    public:
    41         ParserArena();
    42         ~ParserArena();
    43 
    4440        void swap(ParserArena& otherArena)
    4541        {
    46             std::swap(m_freeableMemory, otherArena.m_freeableMemory);
    47             std::swap(m_freeablePoolEnd, otherArena.m_freeablePoolEnd);
    48             m_identifierArena.swap(otherArena.m_identifierArena);
    49             m_freeablePools.swap(otherArena.m_freeablePools);
    5042            m_deletableObjects.swap(otherArena.m_deletableObjects);
    5143            m_refCountedObjects.swap(otherArena.m_refCountedObjects);
    5244        }
     45        ~ParserArena();
    5346
    54         void* allocateFreeable(size_t size)
    55         {
    56             ASSERT(size);
    57             ASSERT(size <= freeablePoolSize);
    58             size_t alignedSize = alignSize(size);
    59             ASSERT(alignedSize <= freeablePoolSize);
    60             if (UNLIKELY(static_cast<size_t>(m_freeablePoolEnd - m_freeableMemory) < alignedSize))
    61                 allocateFreeablePool();
    62             void* block = m_freeableMemory;
    63             m_freeableMemory += alignedSize;
    64             return block;
    65         }
     47        void deleteWithArena(ParserArenaDeletable* object) { m_deletableObjects.append(object); }
     48        void derefWithArena(PassRefPtr<ParserArenaRefCounted> object) { m_refCountedObjects.append(object); }
    6649
    67         void* allocateDeletable(size_t size)
    68         {
    69             ParserArenaDeletable* deletable = static_cast<ParserArenaDeletable*>(fastMalloc(size));
    70             m_deletableObjects.append(deletable);
    71             return deletable;
    72         }
    73 
    74         void derefWithArena(PassRefPtr<ParserArenaRefCounted> object) { m_refCountedObjects.append(object); }
    7550        bool contains(ParserArenaRefCounted*) const;
    7651        ParserArenaRefCounted* last() const;
    7752        void removeLast();
    7853
    79         bool isEmpty() const;
     54        bool isEmpty() const { return m_deletableObjects.isEmpty() && m_refCountedObjects.isEmpty(); }
    8055        void reset();
    8156
    82         const Identifier& makeIdentifier(JSGlobalData*, const UChar* character, size_t length);
    83         const Identifier& makeNumericIdentifier(JSGlobalData*, double number);
    84 
    85         IdentifierArena& identifierArena() { return *m_identifierArena; }
    86 
    8757    private:
    88         static const size_t freeablePoolSize = 8000;
    89 
    90         static size_t alignSize(size_t size)
    91         {
    92             return (size + sizeof(WTF::AllocAlignmentInteger) - 1) & ~(sizeof(WTF::AllocAlignmentInteger) - 1);
    93         }
    94 
    95         void* freeablePool();
    96         void allocateFreeablePool();
    97         void deallocateObjects();
    98 
    99         char* m_freeableMemory;
    100         char* m_freeablePoolEnd;
    101 
    102         OwnPtr<IdentifierArena> m_identifierArena;
    103         Vector<void*> m_freeablePools;
    10458        Vector<ParserArenaDeletable*> m_deletableObjects;
    10559        Vector<RefPtr<ParserArenaRefCounted> > m_refCountedObjects;
    10660    };
    10761
    108     ALWAYS_INLINE const Identifier& makeIdentifier(IdentifierArena& arena, JSGlobalData* globalData, const UChar* characters, size_t length)
    109     {
    110         arena.append(Identifier(globalData, characters, length));
    111         return arena.last();
    112     }
    113 
    114     ALWAYS_INLINE const Identifier& ParserArena::makeIdentifier(JSGlobalData* globalData, const UChar* characters, size_t length)
    115     {
    116         return JSC::makeIdentifier(*m_identifierArena, globalData, characters, length);
    117     }
    118 
    11962}
    12063
Note: See TracChangeset for help on using the changeset viewer.