Ignore:
Timestamp:
Dec 8, 2014, 5:53:53 PM (10 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore:
Removed some allocation and cruft from the parser
https://bugs.webkit.org/show_bug.cgi?id=139416

Reviewed by Mark Lam.

Now, the only AST nodes that require a destructor are the ones that
relate to pickling a function's arguments -- which will required some
deeper thinking to resolve.

This is a < 1% parser speedup.

was unused.

  • bytecompiler/NodesCodegen.cpp:

(JSC::CommaNode::emitBytecode):
(JSC::SourceElements::lastStatement):
(JSC::SourceElements::emitBytecode): Updated for interface change to linked list.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::ASTBuilder):
(JSC::ASTBuilder::varDeclarations):
(JSC::ASTBuilder::funcDeclarations):
(JSC::ASTBuilder::createFuncDeclStatement):
(JSC::ASTBuilder::addVar): Removed the ParserArenaData abstraction because
it wasn't buying us anything. We can just use Vector directly.

(JSC::ASTBuilder::createCommaExpr):
(JSC::ASTBuilder::appendToCommaExpr): Changed to use a linked list instead
of a vector, to avoid allocating a vector with inline capacity in the
common case in which an expression is not followed by a vector.

(JSC::ASTBuilder::Scope::Scope): Use Vector directly to avoid new'ing
up a Vector*.

(JSC::ASTBuilder::appendToComma): Deleted.
(JSC::ASTBuilder::combineCommaNodes): Deleted.

  • parser/Lexer.cpp:
  • parser/NodeConstructors.h:

(JSC::StatementNode::StatementNode):
(JSC::CommaNode::CommaNode):
(JSC::SourceElements::SourceElements): Updated for interface change to linked list.

  • parser/NodeInfo.h: Removed.
  • parser/Nodes.cpp:

(JSC::SourceElements::append):
(JSC::SourceElements::singleStatement): Use a linked list instead of a
vector to track the statements in a list. This removes some allocation
and it means that we don't need a destructor anymore.

(JSC::ScopeNode::ScopeNode):
(JSC::ProgramNode::ProgramNode):
(JSC::EvalNode::EvalNode):
(JSC::FunctionNode::FunctionNode): Updated for interface change to reference,
since these values are never null.

  • parser/Nodes.h:

(JSC::StatementNode::next):
(JSC::StatementNode::setNext):
(JSC::CommaNode::append): Deleted. Updated for interface change to linked list.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::didFinishParsing): Updated for interface change to reference.

(JSC::Parser<LexerType>::parseVarDeclarationList):
(JSC::Parser<LexerType>::parseExpression): Track comma expressions as
an explicit list of CommaNodes, removing a use of vector and a destructor.

  • parser/Parser.h:

(JSC::Parser<LexerType>::parse):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createCommaExpr):
(JSC::SyntaxChecker::appendToCommaExpr):
(JSC::SyntaxChecker::appendToComma): Deleted. Updated for interface changes.

LayoutTests:
Removed the custom allocator for ParserArena
https://bugs.webkit.org/show_bug.cgi?id=139305

Reviewed by Mark Lam.

Added a test for something I messed up while writing this patch.

  • js/basic-strict-mode-expected.txt:
  • js/script-tests/basic-strict-mode.js:
File:
1 edited

Legend:

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

    r176825 r177001  
    532532    String parseInner();
    533533
    534     void didFinishParsing(SourceElements*, ParserArenaData<DeclarationStacks::VarStack>*,
    535         ParserArenaData<DeclarationStacks::FunctionStack>*, CodeFeatures, int, IdentifierSet&, const Vector<RefPtr<StringImpl>>&&);
     534    void didFinishParsing(SourceElements*, DeclarationStacks::VarStack&,
     535        DeclarationStacks::FunctionStack&, CodeFeatures, int, IdentifierSet&, const Vector<RefPtr<StringImpl>>&&);
    536536
    537537    // Used to determine type of error to report.
     
    834834    SourceElements* m_sourceElements;
    835835    bool m_parsingBuiltin;
    836     ParserArenaData<DeclarationStacks::VarStack>* m_varDeclarations;
    837     ParserArenaData<DeclarationStacks::FunctionStack>* m_funcDeclarations;
     836    DeclarationStacks::VarStack m_varDeclarations;
     837    DeclarationStacks::FunctionStack m_funcDeclarations;
    838838    IdentifierSet m_capturedVariables;
    839839    Vector<RefPtr<StringImpl>> m_closedVariables;
     
    906906                                    endColumn,
    907907                                    m_sourceElements,
    908                                     m_varDeclarations ? &m_varDeclarations->data : 0,
    909                                     m_funcDeclarations ? &m_funcDeclarations->data : 0,
     908                                    m_varDeclarations,
     909                                    m_funcDeclarations,
    910910                                    m_capturedVariables,
    911911                                    *m_source,
Note: See TracChangeset for help on using the changeset viewer.