Ignore:
Timestamp:
Dec 3, 2014, 1:54:53 PM (11 years ago)
Author:
[email protected]
Message:

The parser should allocate all pieces of the AST
https://bugs.webkit.org/show_bug.cgi?id=139230

Reviewed by Oliver Hunt.

This is a step toward a 14% parsing speedup.

Previously, allocation was split between the parser and certain node
constructor functions. This made for some duplicated code and circular
dependencies.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createGetterOrSetterProperty): No need to pass through
the VM, since our callee no longer needs to allocate anything.

(JSC::ASTBuilder::createProperty): Allocate the identifier for our
callee, since that is simpler than requiring our callee to notice that
we didn't do so, and do it for us.

(JSC::ASTBuilder::createForInLoop): Allocate the DeconstructingAssignmentNode
for our callee, since that is simpler than requiring our callee to notice
that we didn't do so, and do it for us.

Also, reuse some code instead of duplicating it.

(JSC::ASTBuilder::createForOfLoop): Ditto.

(JSC::ASTBuilder::createArrayPattern):
(JSC::ASTBuilder::createObjectPattern):
(JSC::ASTBuilder::createBindingLocation): No need to pass through a VM
pointer, since our callee no longer needs to allocate anything.

(JSC::ASTBuilder::createBreakStatement): Deleted.
(JSC::ASTBuilder::createContinueStatement): Deleted.

  • parser/NodeConstructors.h:

(JSC::PropertyNode::PropertyNode):
(JSC::DeconstructionPatternNode::DeconstructionPatternNode):
(JSC::ArrayPatternNode::ArrayPatternNode):
(JSC::ArrayPatternNode::create):
(JSC::ObjectPatternNode::ObjectPatternNode):
(JSC::ObjectPatternNode::create):
(JSC::BindingNode::create):
(JSC::BindingNode::BindingNode):
(JSC::ContinueNode::ContinueNode): Deleted.
(JSC::BreakNode::BreakNode): Deleted.
(JSC::EnumerationNode::EnumerationNode): Deleted.
(JSC::ForInNode::ForInNode): Deleted.
(JSC::ForOfNode::ForOfNode): Deleted. Deleted a bunch of special cases
that don't exist anymore, now that the parser allocates all pieces of
the AST unconditionally.

  • parser/Nodes.h: Ditto.
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseBreakStatement):
(JSC::Parser<LexerType>::parseContinueStatement): Allocate the null
identifier for our callee, since that is simpler than requiring our
callee to notice that we didn't do so, and do it for us.

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

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createProperty): No need to pass through a VM
pointer, since our callee no longer needs to allocate anything.

File:
1 edited

Legend:

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

    r175396 r176754  
    484484        enum Type { Constant = 1, Getter = 2, Setter = 4 };
    485485
    486         PropertyNode(VM*, const Identifier&, ExpressionNode*, Type);
    487         PropertyNode(VM*, double, ExpressionNode*, Type);
    488         PropertyNode(VM*, ExpressionNode* propertyName, ExpressionNode*, Type);
     486        PropertyNode(const Identifier&, ExpressionNode*, Type);
     487        PropertyNode(ExpressionNode* propertyName, ExpressionNode*, Type);
    489488       
    490489        ExpressionNode* expressionName() const { return m_expression; }
     
    12811280    public:
    12821281        EnumerationNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*);
    1283         EnumerationNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);
    12841282       
    12851283    protected:
     
    12921290    public:
    12931291        ForInNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*);
    1294         ForInNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);
    12951292
    12961293    private:
     
    13051302    public:
    13061303        ForOfNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*);
    1307         ForOfNode(VM*, const JSTokenLocation&, DeconstructionPatternNode*, ExpressionNode*, StatementNode*);
    13081304       
    13091305    private:
     
    13131309    class ContinueNode : public StatementNode, public ThrowableExpressionData {
    13141310    public:
    1315         ContinueNode(VM*, const JSTokenLocation&);
    13161311        ContinueNode(const JSTokenLocation&, const Identifier&);
    13171312        Label* trivialTarget(BytecodeGenerator&);
     
    13261321    class BreakNode : public StatementNode, public ThrowableExpressionData {
    13271322    public:
    1328         BreakNode(VM*, const JSTokenLocation&);
    13291323        BreakNode(const JSTokenLocation&, const Identifier&);
    13301324        Label* trivialTarget(BytecodeGenerator&);
     
    16191613       
    16201614    protected:
    1621         DeconstructionPatternNode(VM*);
     1615        DeconstructionPatternNode();
    16221616    };
    16231617
    16241618    class ArrayPatternNode : public DeconstructionPatternNode {
    16251619    public:
    1626         static PassRefPtr<ArrayPatternNode> create(VM*);
     1620        static PassRefPtr<ArrayPatternNode> create();
    16271621        void appendIndex(const JSTokenLocation&, DeconstructionPatternNode* node)
    16281622        {
     
    16311625
    16321626    private:
    1633         ArrayPatternNode(VM*);
     1627        ArrayPatternNode();
    16341628        virtual void collectBoundIdentifiers(Vector<Identifier>&) const override;
    16351629        virtual void bindValue(BytecodeGenerator&, RegisterID*) const override;
     
    16421636    class ObjectPatternNode : public DeconstructionPatternNode {
    16431637    public:
    1644         static PassRefPtr<ObjectPatternNode> create(VM*);
     1638        static PassRefPtr<ObjectPatternNode> create();
    16451639        void appendEntry(const JSTokenLocation&, const Identifier& identifier, bool wasString, DeconstructionPatternNode* pattern)
    16461640        {
     
    16491643       
    16501644    private:
    1651         ObjectPatternNode(VM*);
     1645        ObjectPatternNode();
    16521646        virtual void collectBoundIdentifiers(Vector<Identifier>&) const override;
    16531647        virtual void bindValue(BytecodeGenerator&, RegisterID*) const override;
     
    16691663    class BindingNode : public DeconstructionPatternNode {
    16701664    public:
    1671         static PassRefPtr<BindingNode> create(VM*, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);
     1665        static PassRefPtr<BindingNode> create(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);
    16721666        const Identifier& boundProperty() const { return m_boundProperty; }
    16731667
     
    16761670       
    16771671    private:
    1678         BindingNode(VM*, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);
     1672        BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end);
    16791673
    16801674        virtual void collectBoundIdentifiers(Vector<Identifier>&) const override;
Note: See TracChangeset for help on using the changeset viewer.