Ignore:
Timestamp:
May 24, 2011, 11:49:18 AM (14 years ago)
Author:
[email protected]
Message:

2011-05-24 Oliver Hunt <[email protected]>

Reviewed by Geoffrey Garen.

Avoid creating unnecessary identifiers and strings in the syntax checker
https://bugs.webkit.org/show_bug.cgi?id=61378

Selectively tell the lexer that there are some places it does not need to
do the real work of creating Identifiers for IDENT and STRING tokens.

Make parseString and parseIdentifier templatized on whether they should
do real work, or merely validate the tokens.

SunSpider --parse-only reports ~5-8% win depending on hardware.

  • parser/ASTBuilder.h: (JSC::ASTBuilder::createDotAccess):
  • parser/JSParser.cpp: (JSC::JSParser::next): (JSC::JSParser::consume): (JSC::JSParser::parseVarDeclarationList): (JSC::JSParser::parseConstDeclarationList): (JSC::JSParser::parseExpression): (JSC::JSParser::parseAssignmentExpression): (JSC::JSParser::parseConditionalExpression): (JSC::JSParser::parseBinaryExpression): (JSC::JSParser::parseProperty): (JSC::JSParser::parseObjectLiteral): (JSC::JSParser::parseArrayLiteral): (JSC::JSParser::parseArguments): (JSC::JSParser::parseMemberExpression):
  • parser/Lexer.cpp: (JSC::Lexer::parseIdentifier): (JSC::Lexer::parseString): (JSC::Lexer::lex):
  • parser/Lexer.h:
  • parser/SyntaxChecker.h: (JSC::SyntaxChecker::createDotAccess): (JSC::SyntaxChecker::createProperty):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r76177 r87177  
    2727#define SyntaxChecker_h
    2828
     29#include "Lexer.h"
    2930#include <yarr/YarrSyntaxChecker.h>
    3031
     
    114115    static const bool NeedsFreeVariableInfo = false;
    115116    static const bool CanUseFunctionCache = true;
     117    static const unsigned DontBuildKeywords = Lexer::DontBuildKeywords;
     118    static const unsigned DontBuildStrings = Lexer::DontBuildStrings;
    116119
    117120    int createSourceElements() { return 1; }
     
    140143    ExpressionType createNull() { return NullExpr; }
    141144    ExpressionType createBracketAccess(ExpressionType, ExpressionType, bool, int, int, int) { return BracketExpr; }
    142     ExpressionType createDotAccess(ExpressionType, const Identifier&, int, int, int) { return DotExpr; }
     145    ExpressionType createDotAccess(ExpressionType, const Identifier*, int, int, int) { return DotExpr; }
    143146    ExpressionType createRegExp(const Identifier& pattern, const Identifier&, int) { return Yarr::checkSyntax(pattern.ustring()) ? 0 : RegExpExpr; }
    144147    ExpressionType createNewExpr(ExpressionType, int, int, int, int) { return NewExpr; }
     
    154157    template <bool complete> Property createProperty(const Identifier* name, int, PropertyNode::Type type)
    155158    {
    156         ASSERT(name);
    157159        if (!complete)
    158160            return Property(type);
     161        ASSERT(name);
    159162        return Property(name, type);
    160163    }
Note: See TracChangeset for help on using the changeset viewer.