Ignore:
Timestamp:
Dec 4, 2014, 4:59:33 PM (10 years ago)
Author:
[email protected]
Message:

Removed the concept of ParserArenaRefCounted
https://bugs.webkit.org/show_bug.cgi?id=139277

Reviewed by Oliver Hunt.

This is a step toward a parser speedup.

Now that we have a clear root node type for each parse tree, there's no
need to have a concept for "I might be refcounted or arena allocated".
Instead, we can just use unique_ptr to manage the tree as a whole.

  • API/JSScriptRef.cpp:

(parseScript):

  • builtins/BuiltinExecutables.cpp:

(JSC::BuiltinExecutables::createBuiltinExecutable): Updated for type change.

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::generateFunctionCodeBlock): Use unique_ptr. No need to call
destroyData() explicitly: the unique_ptr destructor will do everything
we need, as Bjarne intended.

  • parser/NodeConstructors.h:

(JSC::ParserArenaRoot::ParserArenaRoot):
(JSC::ParserArenaRefCounted::ParserArenaRefCounted): Deleted.

  • parser/Nodes.cpp:

(JSC::ScopeNode::ScopeNode):
(JSC::ProgramNode::ProgramNode):
(JSC::EvalNode::EvalNode):
(JSC::FunctionNode::FunctionNode):
(JSC::ProgramNode::create): Deleted.
(JSC::EvalNode::create): Deleted.
(JSC::FunctionNode::create): Deleted. All special create semantics can
just go away now that we play by C++ constructor / destructor rules.

  • parser/Nodes.h:

(JSC::ParserArenaRoot::parserArena):
(JSC::ParserArenaRoot::~ParserArenaRoot): Just a normal class now, which
holds onto the whole parse tree by virtue of owning the arena in which
all the parsed nodes (except for itself) were allocated.

(JSC::ProgramNode::closedVariables):
(JSC::ParserArenaRefCounted::~ParserArenaRefCounted): Deleted.

(JSC::ScopeNode::destroyData): Deleted. No need to destroy anything
explicitly anymore -- we can just rely on destructors.

(JSC::ScopeNode::parserArena): Deleted.

  • parser/Parser.h:

(JSC::Parser<LexerType>::parse):
(JSC::parse): unique_ptr all the things.

  • parser/ParserArena.cpp:

(JSC::ParserArena::reset):
(JSC::ParserArena::isEmpty):
(JSC::ParserArena::contains): Deleted.
(JSC::ParserArena::last): Deleted.
(JSC::ParserArena::removeLast): Deleted.
(JSC::ParserArena::derefWithArena): Deleted.

  • parser/ParserArena.h:

(JSC::ParserArena::swap): Much delete. Such wow.

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getGlobalCodeBlock):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/Completion.cpp:

(JSC::checkSyntax):

  • runtime/Executable.cpp:

(JSC::ProgramExecutable::checkSyntax): unique_ptr all the things.

File:
1 edited

Legend:

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

    r176823 r176825  
    112112    };
    113113
    114     class ParserArenaRefCounted : public RefCounted<ParserArenaRefCounted> {
     114    class ParserArenaRoot {
    115115        WTF_MAKE_FAST_ALLOCATED;
    116116    protected:
    117         ParserArenaRefCounted(ParserArena&);
    118 
    119     public:
    120         virtual ~ParserArenaRefCounted()
    121         {
    122             ASSERT(deletionHasBegun());
    123         }
     117        ParserArenaRoot(ParserArena&);
     118
     119    public:
     120        ParserArena& parserArena() { return m_arena; }
     121        virtual ~ParserArenaRoot() { }
     122
     123    protected:
     124        ParserArena m_arena;
    124125    };
    125126
     
    14051406    };
    14061407
    1407     class ScopeNode : public StatementNode, public ParserArenaRefCounted {
     1408    class ScopeNode : public StatementNode, public ParserArenaRoot {
    14081409    public:
    14091410        typedef DeclarationStacks::VarStack VarStack;
     
    14131414        ScopeNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, const SourceCode&, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, CodeFeatures, int numConstants);
    14141415
    1415         using ParserArenaRefCounted::operator new;
    1416 
    1417         void destroyData()
    1418         {
    1419             m_arena.reset();
    1420             m_varStack.clear();
    1421             m_functionStack.clear();
    1422             m_statements = 0;
    1423             m_capturedVariables.clear();
    1424         }
    1425 
    1426         ParserArena& parserArena() { return m_arena; }
     1416        using ParserArenaRoot::operator new;
     1417
    14271418        const SourceCode& source() const { return m_source; }
    14281419        const String& sourceURL() const { return m_source.provider()->url(); }
     
    14671458
    14681459    protected:
    1469         ParserArena m_arena;
    1470 
    14711460        int m_startLineNumber;
    14721461        unsigned m_startStartOffset;
     
    14851474    class ProgramNode : public ScopeNode {
    14861475    public:
    1487         static PassRefPtr<ProgramNode> create(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
     1476        ProgramNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
    14881477
    14891478        unsigned startColumn() const { return m_startColumn; }
     
    14941483        void setClosedVariables(Vector<RefPtr<StringImpl>>&&);
    14951484        const Vector<RefPtr<StringImpl>>& closedVariables() const { return m_closedVariables; }
    1496     private:
    1497         ProgramNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
    1498 
     1485
     1486    private:
    14991487        virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
    15001488        Vector<RefPtr<StringImpl>> m_closedVariables;
     
    15051493    class EvalNode : public ScopeNode {
    15061494    public:
    1507         static PassRefPtr<EvalNode> create(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
     1495        EvalNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
    15081496
    15091497        ALWAYS_INLINE unsigned startColumn() const { return 0; }
     
    15131501
    15141502    private:
    1515         EvalNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
    1516 
    15171503        virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
    15181504
     
    15851571    class FunctionNode final : public ScopeNode {
    15861572    public:
    1587         static PassRefPtr<FunctionNode> create(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
     1573        FunctionNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
    15881574
    15891575        FunctionParameters* parameters() const { return m_parameters.get(); }
     
    16031589
    16041590    private:
    1605         FunctionNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VarStack*, FunctionStack*, IdentifierSet&, const SourceCode&, CodeFeatures, int numConstants);
    1606 
    16071591        Identifier m_ident;
    16081592        FunctionMode m_functionMode;
Note: See TracChangeset for help on using the changeset viewer.