Changeset 28855 in webkit for trunk/JavaScriptCore/kjs


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

Remove dead code due to removal of post-parse declaration discovery.

RS=Geoff.

Due to the removal of the declaration discovery pass after parsing we
no longer need any of the logic used for that discovery.

Location:
trunk/JavaScriptCore/kjs
Files:
2 edited

Legend:

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

    r28854 r28855  
    210210
    211211Node::Node()
    212     : m_mayHaveDeclarations(false)
    213     , m_expectedReturnType(ObjectType)
     212    : m_expectedReturnType(ObjectType)
    214213{
    215214  m_line = lexer().lineNo();
     
    217216
    218217Node::Node(JSType expectedReturn)
    219     : m_mayHaveDeclarations(false)
    220     , m_expectedReturnType(expectedReturn)
     218    : m_expectedReturnType(expectedReturn)
    221219{
    222220    m_line = lexer().lineNo();
     
    34513449    , init(in)
    34523450{
    3453     m_mayHaveDeclarations = true;
    34543451}
    34553452
     
    34603457    if (init)
    34613458        nodeStack.append(init.get());
    3462 }
    3463 
    3464 void VarDeclNode::getDeclarations(DeclarationStacks& stacks)
    3465 {
    3466     if (next) {
    3467         ASSERT(next->mayHaveDeclarations());
    3468         stacks.nodeStack.append(next.get());
    3469     }
    3470 
    3471     // The normal check to avoid overwriting pre-existing values with variable
    3472     // declarations doesn't work for the "arguments" property because we
    3473     // instantiate it lazily. So we need to check here instead.
    3474     if (ident == stacks.exec->propertyNames().arguments)
    3475         return;
    3476 
    3477     stacks.varStack.append(this);
    34783459}
    34793460
     
    35763557}
    35773558
    3578 void VarStatementNode::getDeclarations(DeclarationStacks& stacks)
    3579 {
    3580     ASSERT(next->mayHaveDeclarations());
    3581     stacks.nodeStack.append(next.get());
    3582 }
    3583 
    35843559// ------------------------------ Helper functions for handling Vectors of StatementNode -------------------------------
    35853560
     
    35923567        stack.append((*it).get());
    35933568    }
    3594 }
    3595 
    3596 static inline void statementListGetDeclarations(SourceElements& statements, DeclarationStacks& stacks)
    3597 {
    3598     SourceElements::iterator it = statements.end();
    3599     SourceElements::iterator begin = statements.begin();
    3600     while (it != begin) {
    3601         --it;
    3602         if ((*it)->mayHaveDeclarations())
    3603             stacks.nodeStack.append((*it).get());
    3604     }
    3605 }
    3606 
    3607 static inline Node* statementListInitializeDeclarationStack(SourceElements& statements, DeclarationStacks::NodeStack& stack)
    3608 {
    3609     ASSERT(!stack.size()); // Otherwise, the removeLast() call might remove someone else's node.
    3610    
    3611     SourceElements::iterator it = statements.end();
    3612     SourceElements::iterator begin = statements.begin();
    3613    
    3614     while (it != begin) {
    3615         --it;
    3616         if ((*it)->mayHaveDeclarations())
    3617              stack.append((*it).get());
    3618     }
    3619 
    3620     if (!stack.size())
    3621         return 0;
    3622 
    3623     Node* n = stack.last();
    3624     stack.removeLast();
    3625     return n;
    36263569}
    36273570
     
    36673610{
    36683611    ASSERT(m_children);
    3669     m_mayHaveDeclarations = true;
    36703612}
    36713613
     
    36733615{
    36743616    statementListPushFIFO(*m_children, nodeStack);
    3675 }
    3676 
    3677 void BlockNode::getDeclarations(DeclarationStacks& stacks)
    3678 {
    3679     statementListGetDeclarations(*m_children, stacks);
    36803617}
    36813618
     
    37453682}
    37463683
    3747 void IfNode::getDeclarations(DeclarationStacks& stacks)
    3748 {
    3749     if (statement2 && statement2->mayHaveDeclarations())
    3750         stacks.nodeStack.append(statement2.get());
    3751     if (statement1->mayHaveDeclarations())
    3752         stacks.nodeStack.append(statement1.get());
    3753 }
    3754 
    37553684// ------------------------------ DoWhileNode ----------------------------------
    37563685
     
    37933722
    37943723    return Completion(); // work around gcc 4.0 bug
    3795 }
    3796 
    3797 void DoWhileNode::getDeclarations(DeclarationStacks& stacks)
    3798 {
    3799     if (statement->mayHaveDeclarations())
    3800         stacks.nodeStack.append(statement.get());
    38013724}
    38023725
     
    38413764
    38423765    return Completion(); // work around gcc 4.0 bug
    3843 }
    3844 
    3845 void WhileNode::getDeclarations(DeclarationStacks& stacks)
    3846 {
    3847     if (statement->mayHaveDeclarations())
    3848         stacks.nodeStack.append(statement.get());
    38493766}
    38503767
     
    39043821}
    39053822
    3906 void ForNode::getDeclarations(DeclarationStacks& stacks)
    3907 {
    3908     if (statement->mayHaveDeclarations())
    3909         stacks.nodeStack.append(statement.get());
    3910     if (expr1 && expr1->mayHaveDeclarations())
    3911         stacks.nodeStack.append(expr1.get());
    3912 }
    3913 
    39143823// ------------------------------ ForInNode ------------------------------------
    39153824
     
    39173826  : init(0L), lexpr(l), expr(e), varDecl(0L), statement(s)
    39183827{
    3919     m_mayHaveDeclarations = true;
    39203828}
    39213829
     
    39233831  : ident(i), init(in), expr(e), statement(s)
    39243832{
    3925   m_mayHaveDeclarations = true;
    3926 
    39273833  // for( var foo = bar in baz )
    39283834  varDecl = new VarDeclNode(ident, init.get(), VarDeclNode::Variable);
     
    39373843    if (varDecl)
    39383844        nodeStack.append(varDecl.get());
    3939 }
    3940 
    3941 void ForInNode::getDeclarations(DeclarationStacks& stacks)
    3942 {
    3943     if (statement->mayHaveDeclarations())
    3944         stacks.nodeStack.append(statement.get());
    3945     if (varDecl && varDecl->mayHaveDeclarations())
    3946         stacks.nodeStack.append(varDecl.get());
    39473845}
    39483846
     
    41034001// ------------------------------ WithNode -------------------------------------
    41044002
    4105 void WithNode::getDeclarations(DeclarationStacks& stacks)
    4106 {
    4107     if (statement->mayHaveDeclarations())
    4108         stacks.nodeStack.append(statement.get());
    4109 }
    4110 
    41114003void WithNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack& nodeStack)
    41124004{
     
    41414033}
    41424034
    4143 void CaseClauseNode::getDeclarations(DeclarationStacks& stacks)
    4144 {
    4145     if (m_children)
    4146         statementListGetDeclarations(*m_children, stacks);
    4147 }
    4148 
    41494035// ECMA 12.11
    41504036JSValue *CaseClauseNode::evaluate(ExecState *exec)
     
    41744060}
    41754061
    4176 void ClauseListNode::getDeclarations(DeclarationStacks& stacks)
    4177 {
    4178     if (next && next->mayHaveDeclarations())
    4179         stacks.nodeStack.append(next.get());
    4180     if (clause->mayHaveDeclarations())
    4181         stacks.nodeStack.append(clause.get());
    4182 }
    4183 
    41844062// ------------------------------ CaseBlockNode --------------------------------
    41854063
     
    41894067    , list2(l2)
    41904068{
    4191     m_mayHaveDeclarations = true;
    41924069}
    41934070 
     
    42004077    if (list1)
    42014078        nodeStack.append(list1.get());
    4202 }
    4203 
    4204 void CaseBlockNode::getDeclarations(DeclarationStacks& stacks)
    4205 {
    4206     if (list2 && list2->mayHaveDeclarations())
    4207         stacks.nodeStack.append(list2.get());
    4208     if (def && def->mayHaveDeclarations())
    4209         stacks.nodeStack.append(def.get());
    4210     if (list1 && list1->mayHaveDeclarations())
    4211         stacks.nodeStack.append(list1.get());
    42124079}
    42134080
     
    42834150}
    42844151
    4285 void SwitchNode::getDeclarations(DeclarationStacks& stacks)
    4286 {
    4287     if (block->mayHaveDeclarations())
    4288         stacks.nodeStack.append(block.get());
    4289 }
    4290 
    42914152// ECMA 12.11
    42924153Completion SwitchNode::execute(ExecState *exec)
     
    43114172{
    43124173    nodeStack.append(statement.get());
    4313 }
    4314 
    4315 void LabelNode::getDeclarations(DeclarationStacks& stacks)
    4316 {
    4317     if (statement->mayHaveDeclarations())
    4318         stacks.nodeStack.append(statement.get());
    43194174}
    43204175
     
    43594214        nodeStack.append(finallyBlock.get());
    43604215    nodeStack.append(tryBlock.get());
    4361 }
    4362 
    4363 void TryNode::getDeclarations(DeclarationStacks& stacks)
    4364 {
    4365     if (finallyBlock && finallyBlock->mayHaveDeclarations())
    4366         stacks.nodeStack.append(finallyBlock.get());
    4367     if (catchBlock && catchBlock->mayHaveDeclarations())
    4368         stacks.nodeStack.append(catchBlock.get());
    4369     if (tryBlock->mayHaveDeclarations())
    4370         stacks.nodeStack.append(tryBlock.get());
    43714216}
    43724217
     
    46124457}
    46134458
    4614 void FuncDeclNode::getDeclarations(DeclarationStacks& stacks)
    4615 {
    4616     stacks.functionStack.append(this);
    4617 }
    4618 
    46194459FunctionImp* FuncDeclNode::makeFunction(ExecState* exec)
    46204460{
  • trunk/JavaScriptCore/kjs/nodes.h

    r28854 r28855  
    139139    virtual void streamTo(SourceStream&) const KJS_FAST_CALL = 0;
    140140    virtual Precedence precedence() const = 0;
    141 
    142     // Used for iterative, depth-first traversal of the node tree. Does not cross function call boundaries.
    143     bool mayHaveDeclarations() const { return m_mayHaveDeclarations; }
    144     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL { ASSERT_NOT_REACHED(); }
    145141   
    146142    // Used for iterative, depth-first traversal of the node tree. Does not cross function call boundaries.
     
    168164
    169165    int m_line : 28;
    170     bool m_mayHaveDeclarations : 1;
    171166    unsigned m_expectedReturnType : 3; // JSType
    172167  };
     
    17151710    void evaluateSingle(ExecState*) KJS_FAST_CALL;
    17161711    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1717     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    17181712    virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
    17191713    PassRefPtr<VarDeclNode> releaseNext() KJS_FAST_CALL { return next.release(); }
     
    17291723  class VarStatementNode : public StatementNode {
    17301724  public:
    1731     VarStatementNode(VarDeclNode* l) KJS_FAST_CALL : next(l) { m_mayHaveDeclarations = true; }
     1725    VarStatementNode(VarDeclNode* l) KJS_FAST_CALL : next(l) { }
    17321726    virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    17331727    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    17341728    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1735     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    17361729  private:
    17371730    RefPtr<VarDeclNode> next;
     
    17531746    virtual Completion execute(ExecState*) KJS_FAST_CALL  { ASSERT_NOT_REACHED(); return Completion(); }
    17541747    virtual void streamTo(SourceStream&) const KJS_FAST_CALL  { ASSERT_NOT_REACHED(); }
    1755     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL  { ASSERT_NOT_REACHED(); }
    17561748    virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
    17571749  private:
     
    17651757    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    17661758    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1767     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    17681759  protected:
    17691760    OwnPtr<SourceElements> m_children;
     
    17901781  public:
    17911782    IfNode(ExpressionNode* e, StatementNode *s1, StatementNode *s2) KJS_FAST_CALL
    1792       : expr(e), statement1(s1), statement2(s2) { m_mayHaveDeclarations = statement1->mayHaveDeclarations() || (statement2 && statement2->mayHaveDeclarations()); }
     1783      : expr(e), statement1(s1), statement2(s2) { }
    17931784    virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    17941785    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    17951786    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1796     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    17971787  private:
    17981788    RefPtr<ExpressionNode> expr;
     
    18031793  class DoWhileNode : public StatementNode {
    18041794  public:
    1805     DoWhileNode(StatementNode *s, ExpressionNode* e) KJS_FAST_CALL : statement(s), expr(e) { m_mayHaveDeclarations = true; }
     1795    DoWhileNode(StatementNode *s, ExpressionNode* e) KJS_FAST_CALL : statement(s), expr(e) { }
    18061796    virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    18071797    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    18081798    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1809     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    18101799  private:
    18111800    RefPtr<StatementNode> statement;
     
    18151804  class WhileNode : public StatementNode {
    18161805  public:
    1817     WhileNode(ExpressionNode* e, StatementNode *s) KJS_FAST_CALL : expr(e), statement(s) { m_mayHaveDeclarations = true; }
     1806    WhileNode(ExpressionNode* e, StatementNode *s) KJS_FAST_CALL : expr(e), statement(s) { }
    18181807    virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    18191808    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    18201809    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1821     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    18221810  private:
    18231811    RefPtr<ExpressionNode> expr;
     
    18301818      expr1(e1), expr2(e2), expr3(e3), statement(s)
    18311819    {
    1832         m_mayHaveDeclarations = true;
    18331820        if (expr1)
    18341821            expr1->optimizeForUnnecessaryResult();
     
    18401827    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    18411828    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1842     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    18431829  private:
    18441830    RefPtr<ExpressionNode> expr1;
     
    18551841    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    18561842    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1857     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    18581843    VarDeclNode* getVarDecl() { return varDecl.get(); }
    18591844  private:
     
    18981883  class WithNode : public StatementNode {
    18991884  public:
    1900     WithNode(ExpressionNode* e, StatementNode* s) KJS_FAST_CALL : expr(e), statement(s) { m_mayHaveDeclarations = true; }
     1885    WithNode(ExpressionNode* e, StatementNode* s) KJS_FAST_CALL : expr(e), statement(s) { }
    19011886    virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    19021887    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    19031888    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1904     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    19051889  private:
    19061890    RefPtr<ExpressionNode> expr;
     
    19101894  class LabelNode : public StatementNode {
    19111895  public:
    1912     LabelNode(const Identifier &l, StatementNode *s) KJS_FAST_CALL : label(l), statement(s) { m_mayHaveDeclarations = true; }
     1896    LabelNode(const Identifier &l, StatementNode *s) KJS_FAST_CALL : label(l), statement(s) { }
    19131897    virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    19141898    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    19151899    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1916     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    19171900  private:
    19181901    Identifier label;
     
    19331916  public:
    19341917    TryNode(StatementNode *b, const Identifier &e, StatementNode *c, StatementNode *f) KJS_FAST_CALL
    1935       : tryBlock(b), exceptionIdent(e), catchBlock(c), finallyBlock(f) { m_mayHaveDeclarations = true; }
     1918      : tryBlock(b), exceptionIdent(e), catchBlock(c), finallyBlock(f) { }
    19361919    virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    19371920    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    19381921    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    1939     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    19401922  private:
    19411923    RefPtr<StatementNode> tryBlock;
     
    20372019  public:
    20382020    FuncDeclNode(const Identifier& i, FunctionBodyNode* b) KJS_FAST_CALL
    2039       : ident(i), body(b) { addParams(); m_mayHaveDeclarations = true; }
     2021      : ident(i), body(b) { addParams(); }
    20402022    FuncDeclNode(const Identifier& i, ParameterNode* p, FunctionBodyNode* b) KJS_FAST_CALL
    2041       : ident(i), param(p), body(b) { addParams(); m_mayHaveDeclarations = true; }
     2023      : ident(i), param(p), body(b) { addParams(); }
    20422024    virtual Completion execute(ExecState*) KJS_FAST_CALL;
    20432025    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    2044     virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    20452026    ALWAYS_INLINE FunctionImp* makeFunction(ExecState*) KJS_FAST_CALL;
    20462027    Identifier ident;
     
    20532034    class CaseClauseNode : public Node {
    20542035  public:
    2055       CaseClauseNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) { m_mayHaveDeclarations = true; }
     2036      CaseClauseNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) { }
    20562037      CaseClauseNode(ExpressionNode* e, SourceElements* children) KJS_FAST_CALL
    2057       : expr(e), m_children(children) { m_mayHaveDeclarations = true; }
     2038      : expr(e), m_children(children) { }
    20582039      virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    20592040      virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    2060       virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    20612041      virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
    20622042
     
    20712051    class ClauseListNode : public Node {
    20722052  public:
    2073       ClauseListNode(CaseClauseNode* c) KJS_FAST_CALL : clause(c) { m_mayHaveDeclarations = true; }
     2053      ClauseListNode(CaseClauseNode* c) KJS_FAST_CALL : clause(c) { }
    20742054      ClauseListNode(ClauseListNode* n, CaseClauseNode* c) KJS_FAST_CALL
    2075       : clause(c) { n->next = this; m_mayHaveDeclarations = true; }
     2055      : clause(c) { n->next = this; }
    20762056      virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    20772057      CaseClauseNode* getClause() const KJS_FAST_CALL { return clause.get(); }
     
    20792059      virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    20802060      PassRefPtr<ClauseListNode> releaseNext() KJS_FAST_CALL { return next.release(); }
    2081       virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    20822061      virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
    20832062  private:
     
    20932072      Completion evalBlock(ExecState *exec, JSValue *input) KJS_FAST_CALL;
    20942073      virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    2095       virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    20962074      virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
    20972075  private:
     
    21032081  class SwitchNode : public StatementNode {
    21042082  public:
    2105       SwitchNode(ExpressionNode* e, CaseBlockNode *b) KJS_FAST_CALL : expr(e), block(b) { m_mayHaveDeclarations = true; }
     2083      SwitchNode(ExpressionNode* e, CaseBlockNode *b) KJS_FAST_CALL : expr(e), block(b) { }
    21062084      virtual void optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
    21072085      virtual Completion execute(ExecState*) KJS_FAST_CALL;
    21082086      virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    2109       virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
    21102087  private:
    21112088      RefPtr<ExpressionNode> expr;
Note: See TracChangeset for help on using the changeset viewer.