Changeset 27032 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Oct 25, 2007, 2:25:17 AM (18 years ago)
Author:
ggaren
Message:

Reviewed by Eric Seidel.


Slightly elaborated the differences between declaration procesing in
Function Code and Program Code.


.3% speedup on SunSpider.

  • kjs/nodes.cpp: (KJS::FunctionBodyNode::processDeclarationsFunctionCode): (KJS::FunctionBodyNode::processDeclarationsProgramCode): Store a minimum set of attributes instead of recomputing all the time. Also, ignore m_parameters, since programs don't have arguments.
File:
1 edited

Legend:

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

    r27028 r27032  
    26182618    JSObject* variableObject = context->variableObject();
    26192619
     2620    int minAttributes = Internal | DontDelete;
     2621
    26202622    // The order of additions to the variable object here implicitly enforces the mutual exclusion described in ECMA 10.1.3.
    26212623    for (i = 0, size = m_varStack.size(); i < size; ++i) {
    26222624        VarDeclNode* node = m_varStack[i];
    2623         int flags = Internal | DontDelete;
     2625        int attributes = minAttributes;
    26242626        if (node->varType == VarDeclNode::Constant)
    2625             flags |= ReadOnly;
    2626         variableObject->put(exec, node->ident, jsUndefined(), flags);
     2627            attributes |= ReadOnly;
     2628        variableObject->put(exec, node->ident, jsUndefined(), attributes);
    26272629    }
    26282630
     
    26332635    for (i = 0, size = m_functionStack.size(); i < size; ++i) {
    26342636        FuncDeclNode* node = m_functionStack[i];
    2635         variableObject->put(exec, node->ident, node->makeFunction(exec), Internal | DontDelete);
     2637        variableObject->put(exec, node->ident, node->makeFunction(exec), minAttributes);
    26362638    }
    26372639}
     
    26432645    Context* context = exec->context();
    26442646    JSObject* variableObject = context->variableObject();
    2645 
    2646     // The order of additions to the variable object here implicitly enforces the mutual exclusion described in ECMA 10.1.3.
     2647   
     2648    int minAttributes = Internal | (exec->context()->codeType() != EvalCode ? DontDelete : 0);
     2649
    26472650    for (i = 0, size = m_varStack.size(); i < size; ++i) {
    26482651        VarDeclNode* node = m_varStack[i];
    2649         if (!variableObject->hasProperty(exec, node->ident)) {
    2650             int flags = Internal;
    2651             if (context->codeType() != EvalCode)
    2652                 flags |= DontDelete;
    2653             if (node->varType == VarDeclNode::Constant)
    2654                 flags |= ReadOnly;
    2655             variableObject->put(exec, node->ident, jsUndefined(), flags);
    2656         }
     2652        if (variableObject->hasProperty(exec, node->ident))
     2653            continue;
     2654        int attributes = minAttributes;
     2655        if (node->varType == VarDeclNode::Constant)
     2656            attributes |= ReadOnly;
     2657        variableObject->put(exec, node->ident, jsUndefined(), attributes);
    26572658    }
    2658    
    2659     const List& args = *context->arguments();
    2660     for (i = 0, size = m_parameters.size(); i < size; ++i)
    2661         variableObject->put(exec, m_parameters[i], args[i], DontDelete);
     2659
     2660    ASSERT(!m_parameters.size());
    26622661
    26632662    for (i = 0, size = m_functionStack.size(); i < size; ++i) {
    26642663        FuncDeclNode* node = m_functionStack[i];
    2665         variableObject->put(exec, node->ident, node->makeFunction(exec), Internal | (context->codeType() == EvalCode ? 0 : DontDelete));
     2664        variableObject->put(exec, node->ident, node->makeFunction(exec), minAttributes);
    26662665    }
    26672666}
Note: See TracChangeset for help on using the changeset viewer.