Changeset 45106 in webkit for trunk/JavaScriptCore/parser


Ignore:
Timestamp:
Jun 24, 2009, 3:01:34 PM (16 years ago)
Author:
[email protected]
Message:

<rdar://problem/6940519> REGRESSION (Safari 4 Public Beta - TOT): google.com/adplanner shows blank page instead of site details in "basic research'

Reviewed by Darin Adler.

The problem was caused by the page returned with a function using a
var declaration list containing around ~3000 variables. The solution
to this is to flatten the comma expression representation and make
codegen comma expressions and initializer lists iterative rather than
recursive.

Location:
trunk/JavaScriptCore/parser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/Grammar.y

    r44224 r45106  
    8181static ExpressionNode* makeRightShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
    8282static StatementNode* makeVarStatementNode(void*, ExpressionNode*);
    83 static ExpressionNode* combineVarInitializers(void*, ExpressionNode* list, AssignResolveNode* init);
     83static ExpressionNode* combineCommaNodes(void*, ExpressionNode* list, ExpressionNode* init);
    8484
    8585#if COMPILER(MSVC)
     
    779779Expr:
    780780    AssignmentExpr
    781   | Expr ',' AssignmentExpr             { $$ = createNodeInfo<ExpressionNode*>(new (GLOBAL_DATA) CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
     781  | Expr ',' AssignmentExpr             { $$ = createNodeInfo<ExpressionNode*>(combineCommaNodes(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
    782782;
    783783
    784784ExprNoIn:
    785785    AssignmentExprNoIn
    786   | ExprNoIn ',' AssignmentExprNoIn     { $$ = createNodeInfo<ExpressionNode*>(new (GLOBAL_DATA) CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
     786  | ExprNoIn ',' AssignmentExprNoIn     { $$ = createNodeInfo<ExpressionNode*>(combineCommaNodes(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
    787787;
    788788
    789789ExprNoBF:
    790790    AssignmentExprNoBF
    791   | ExprNoBF ',' AssignmentExpr         { $$ = createNodeInfo<ExpressionNode*>(new (GLOBAL_DATA) CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
     791  | ExprNoBF ',' AssignmentExpr         { $$ = createNodeInfo<ExpressionNode*>(combineCommaNodes(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
    792792;
    793793
     
    855855                                        { AssignResolveNode* node = new (GLOBAL_DATA) AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
    856856                                          SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
    857                                           $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
     857                                          $$.m_node = combineCommaNodes(GLOBAL_DATA, $1.m_node, node);
    858858                                          $$.m_varDeclarations = $1.m_varDeclarations;
    859859                                          appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
     
    892892                                        { AssignResolveNode* node = new (GLOBAL_DATA) AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
    893893                                          SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
    894                                           $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
     894                                          $$.m_node = combineCommaNodes(GLOBAL_DATA, $1.m_node, node);
    895895                                          $$.m_varDeclarations = $1.m_varDeclarations;
    896896                                          appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
     
    20722072}
    20732073
    2074 static ExpressionNode* combineVarInitializers(void* globalPtr, ExpressionNode* list, AssignResolveNode* init)
     2074static ExpressionNode* combineCommaNodes(void* globalPtr, ExpressionNode* list, ExpressionNode* init)
    20752075{
    20762076    if (!list)
    20772077        return init;
     2078    if (list->isCommaNode()) {
     2079        static_cast<CommaNode*>(list)->append(init);
     2080        return list;
     2081    }
    20782082    return new (GLOBAL_DATA) CommaNode(GLOBAL_DATA, list, init);
    20792083}
  • trunk/JavaScriptCore/parser/NodeConstructors.h

    r44224 r45106  
    660660    inline CommaNode::CommaNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2)
    661661        : ExpressionNode(globalData)
    662         , m_expr1(expr1)
    663         , m_expr2(expr2)
    664     {
     662    {
     663        m_expressions.append(expr1);
     664        m_expressions.append(expr2);
    665665    }
    666666
  • trunk/JavaScriptCore/parser/Nodes.cpp

    r45066 r45106  
    11871187RegisterID* CommaNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
    11881188{
    1189     generator.emitNode(generator.ignoredResult(), m_expr1);
    1190     return generator.emitNode(dst, m_expr2);
     1189    ASSERT(m_expressions.size() > 1);
     1190    for (size_t i = 0; i < m_expressions.size() - 1; i++)
     1191        generator.emitNode(generator.ignoredResult(), m_expressions[i]);
     1192    return generator.emitNode(dst, m_expressions.last());
    11911193}
    11921194
  • trunk/JavaScriptCore/parser/Nodes.h

    r44844 r45106  
    170170        virtual bool isBracketAccessorNode() const { return false; }
    171171        virtual bool isDotAccessorNode() const { return false; }
    172         virtual bool isFuncExprNode() const { return false; }
     172        virtual bool isFuncExprNode() const { return false; }
     173        virtual bool isCommaNode() const { return false; }
    173174        virtual bool isSimpleArray() const { return false; }
    174175        virtual bool isAdd() const { return false; }
     
    10881089        ExpressionNode* m_right;
    10891090    };
     1091   
     1092    typedef Vector<ExpressionNode*, 8> ExpressionVector;
    10901093
    10911094    class CommaNode : public ExpressionNode {
     
    10931096        CommaNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2);
    10941097
    1095     private:
    1096         virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
    1097 
    1098         ExpressionNode* m_expr1;
    1099         ExpressionNode* m_expr2;
     1098        void append(ExpressionNode* expr) { m_expressions.append(expr); }
     1099
     1100    private:
     1101        virtual bool isCommaNode() const { return true; }
     1102        virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
     1103
     1104        ExpressionVector m_expressions;
    11001105    };
    11011106   
Note: See TracChangeset for help on using the changeset viewer.