Changeset 28854 in webkit for trunk/JavaScriptCore/kjs/nodes.h


Ignore:
Timestamp:
Dec 18, 2007, 11:42:29 PM (17 years ago)
Author:
[email protected]
Message:

Replace post-parse pass to find declarations with logic in the parser itself

Reviewed by Geoff.

Instead of finding declarations in a pass following the initial parsing of
a program, we incorporate the logic directly into the parser. This lays
the groundwork for further optimisations (such as improving performance in
declaration expressions -- var x = y; -- to match that of standard assignment)
in addition to providing a 0.4% performance improvement in SunSpider.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.h

    r28608 r28854  
    112112  };
    113113
    114   class Node : Noncopyable {
    115   public:
    116     Node() KJS_FAST_CALL;
    117     Node(PlacementNewAdoptType) KJS_FAST_CALL { }
    118     virtual ~Node();
    119 
    120     UString toString() const KJS_FAST_CALL;
    121     int lineNo() const KJS_FAST_CALL { return m_line; }
     114  class ParserRefCounted : Noncopyable {
     115  protected:
     116    ParserRefCounted() KJS_FAST_CALL;
     117    ParserRefCounted(PlacementNewAdoptType) KJS_FAST_CALL { }
     118   
     119  public:
    122120    void ref() KJS_FAST_CALL;
    123121    void deref() KJS_FAST_CALL;
    124122    unsigned refcount() KJS_FAST_CALL;
    125     static void clearNewNodes() KJS_FAST_CALL;
     123   
     124    static void deleteNewObjects() KJS_FAST_CALL;
     125 
     126    virtual ~ParserRefCounted();
     127  };
     128
     129  class Node : public ParserRefCounted {
     130  public:
     131    Node() KJS_FAST_CALL;
     132    Node(PlacementNewAdoptType placementAdopt) KJS_FAST_CALL
     133    : ParserRefCounted(placementAdopt) { }
     134
     135    UString toString() const KJS_FAST_CALL;
     136    int lineNo() const KJS_FAST_CALL { return m_line; }
    126137
    127138    // Serialization.
     
    18451856    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    18461857    virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
     1858    VarDeclNode* getVarDecl() { return varDecl.get(); }
    18471859  private:
    18481860    Identifier ident;
     
    19521964  class ScopeNode : public BlockNode {
    19531965  public:
    1954     ScopeNode(SourceElements*) KJS_FAST_CALL;
     1966    ScopeNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    19551967
    19561968    int sourceId() KJS_FAST_CALL { return m_sourceId; }
     
    19581970
    19591971  protected:
    1960     void initializeDeclarationStacks(ExecState*) KJS_FAST_CALL;
    19611972
    19621973    DeclarationStacks::VarStack m_varStack;
     
    19701981  class ProgramNode : public ScopeNode {
    19711982  public:
    1972     ProgramNode(SourceElements*) KJS_FAST_CALL;
     1983    ProgramNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    19731984    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    19741985   
     
    19791990  class EvalNode : public ScopeNode {
    19801991  public:
    1981     EvalNode(SourceElements*) KJS_FAST_CALL;
     1992    EvalNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    19821993    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    19831994   
     
    19881999  class FunctionBodyNode : public ScopeNode {
    19892000  public:
    1990     FunctionBodyNode(SourceElements*) KJS_FAST_CALL;
     2001    FunctionBodyNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    19912002
    19922003    virtual Completion execute(ExecState*) KJS_FAST_CALL;
     
    19982009
    19992010  private:
    2000     void initializeSymbolTable() KJS_FAST_CALL;
     2011    void initializeSymbolTable(ExecState*) KJS_FAST_CALL;
    20012012    void optimizeVariableAccess() KJS_FAST_CALL;
    20022013    ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL;
Note: See TracChangeset for help on using the changeset viewer.