Changeset 38632 in webkit for trunk/JavaScriptCore/parser/Lexer.h


Ignore:
Timestamp:
Nov 20, 2008, 2:27:34 PM (17 years ago)
Author:
[email protected]
Message:

2008-11-20 Sam Weinig <[email protected]>

Reviewed by Geoffrey Garen.

Speedup the lexer to offset coming re-parsing patch.

  • .6% progression on Sunspider.
  • bytecompiler/SegmentedVector.h: (JSC::SegmentedVector::shrink): Fixed bug where m_size would not be set when shrinking to 0.
  • parser/Lexer.cpp: (JSC::Lexer::Lexer): (JSC::Lexer::isIdentStart): Use isASCIIAlpha and isASCII to avoid going into ICU in the common cases. (JSC::Lexer::isIdentPart): Use isASCIIAlphanumeric and isASCII to avoid going into ICU in the common cases (JSC::isDecimalDigit): Use version in ASCIICType.h. Inlining it was a regression. (JSC::Lexer::isHexDigit): Ditto. (JSC::Lexer::isOctalDigit): Ditto. (JSC::Lexer::clear): Resize the m_identifiers SegmentedVector to initial capacity
  • parser/Lexer.h: Remove unused m_strings vector. Make m_identifiers a SegmentedVector<Identifier> to avoid allocating a new Identifier* for each identifier found. The SegmentedVector is need so we can passes references to the Identifier to the parser, which remain valid even when the vector is resized. (JSC::Lexer::makeIdentifier): Inline and return a reference to the added Identifier.
File:
1 edited

Legend:

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

    r38205 r38632  
    2424#define Lexer_h
    2525
     26#include "Identifier.h"
    2627#include "Lookup.h"
    27 #include "UString.h"
     28#include "SegmentedVector.h"
     29#include "SourceCode.h"
    2830#include <wtf/Vector.h>
    29 #include "SourceCode.h"
    3031
    3132namespace JSC {
    3233
    33     class Identifier;
    3434    class RegExp;
    3535
     
    113113        void record16(UChar);
    114114
    115         JSC::Identifier* makeIdentifier(const Vector<UChar>& buffer);
     115        JSC::Identifier* makeIdentifier(const Vector<UChar>& buffer)
     116        {
     117            m_identifiers.append(JSC::Identifier(m_globalData, buffer.data(), buffer.size()));
     118            return &m_identifiers.last();
     119        }
     120
     121        static const size_t initialReadBufferCapacity = 32;
     122        static const size_t initialIdentifierTableCapacity = 64;
    116123
    117124        int yylineno;
     
    149156        int m_nextOffset3;
    150157       
    151         Vector<UString*> m_strings;
    152         Vector<JSC::Identifier*> m_identifiers;
     158        SegmentedVector<JSC::Identifier, initialIdentifierTableCapacity> m_identifiers;
    153159
    154160        JSGlobalData* m_globalData;
Note: See TracChangeset for help on using the changeset viewer.