Ignore:
Timestamp:
Jun 13, 2011, 3:38:22 PM (14 years ago)
Author:
[email protected]
Message:

2011-06-13 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Make it possible to inline the common case of identifier lexing
https://bugs.webkit.org/show_bug.cgi?id=62600

Add a lexing function that expects to lex an "normal" alpha numeric
identifier (that ignores keywords) so it's possible to inline the
common parsing cases. This comes out as a reasonable parsing speed
boost.

  • parser/JSParser.cpp: (JSC::JSParser::nextExpectIdentifier): (JSC::JSParser::parseProperty): (JSC::JSParser::parseMemberExpression):
  • parser/Lexer.cpp:
  • parser/Lexer.h: (JSC::Lexer::makeIdentifier): (JSC::Lexer::lexExpectIdentifier):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/JSParser.cpp

    r88083 r88719  
    106106        m_lexer->setLastLineNumber(m_lastLine);
    107107        m_token.m_type = m_lexer->lex(&m_token.m_data, &m_token.m_info, lexType, strictMode());
     108    }
     109   
     110    ALWAYS_INLINE void nextExpectIdentifier(unsigned lexType = 0)
     111    {
     112        m_lastLine = m_token.m_info.line;
     113        m_lastTokenEnd = m_token.m_info.endOffset;
     114        m_lexer->setLastLineNumber(m_lastLine);
     115        m_token.m_type = m_lexer->lexExpectIdentifier(&m_token.m_data, &m_token.m_info, lexType, strictMode());
    108116    }
    109117   
     
    17081716        const Identifier* ident = m_token.m_data.ident;
    17091717        if (complete || (wasIdent && (*ident == m_globalData->propertyNames->get || *ident == m_globalData->propertyNames->set)))
    1710             next(Lexer::IgnoreReservedWords);
     1718            nextExpectIdentifier(Lexer::IgnoreReservedWords);
    17111719        else
    1712             next(Lexer::IgnoreReservedWords | TreeBuilder::DontBuildKeywords);
     1720            nextExpectIdentifier(Lexer::IgnoreReservedWords | TreeBuilder::DontBuildKeywords);
    17131721
    17141722        if (match(COLON)) {
     
    20392047            m_nonTrivialExpressionCount++;
    20402048            int expressionEnd = lastTokenEnd();
    2041             next(Lexer::IgnoreReservedWords | TreeBuilder::DontBuildKeywords);
     2049            nextExpectIdentifier(Lexer::IgnoreReservedWords | TreeBuilder::DontBuildKeywords);
    20422050            matchOrFail(IDENT);
    20432051            base = context.createDotAccess(base, m_token.m_data.ident, expressionStart, expressionEnd, tokenEnd());
Note: See TracChangeset for help on using the changeset viewer.