Ignore:
Timestamp:
Jun 4, 2008, 10:36:55 PM (17 years ago)
Author:
[email protected]
Message:

2008-06-04 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak.

Big cleanup of formatting and whitespace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CodeGenerator.cpp

    r34319 r34372  
    4040/*
    4141    The layout of a register frame looks like this:
    42    
    43     For 
    44    
     42
     43    For
     44
    4545    function f(x, y) {
    4646        var v1;
     
    4949        return (x) * (y);
    5050    }
    51    
     51
    5252    assuming (x) and (y) generated temporaries t1 and t2, you would have
    5353
     
    5858    ------------------------------------
    5959    | params->|<-locals      | temps->
    60    
     60
    6161    Because temporary registers are allocated in a stack-like fashion, we
    6262    can reclaim them with a simple popping algorithm. The same goes for labels.
    6363    (We never reclaim parameter or local registers, because parameters and
    6464    locals are DontDelete.)
    65    
     65
    6666    The register layout before a function call looks like this:
    67    
     67
    6868    For
    69    
     69
    7070    function f(x, y)
    7171    {
    7272    }
    73    
     73
    7474    f(1);
    75    
     75
    7676    >                        <------------------------------
    7777    <                        >  reserved: call frame  |  1 | <-- value held
     
    7979    <                        > +0 | +1 | +2 | +3 | +4 | +5 | <-- register index
    8080    >                        <------------------------------
    81     | params->|<-locals      | temps->   
    82    
     81    | params->|<-locals      | temps->
     82
    8383    The call instruction fills in the "call frame" registers. It also pads
    8484    missing arguments at the end of the call:
    85    
     85
    8686    >                        <-----------------------------------
    8787    <                        >  reserved: call frame  |  1 |  ? | <-- value held ("?" stands for "undefined")
     
    9090    >                        <-----------------------------------
    9191    | params->|<-locals      | temps->
    92    
     92
    9393    After filling in missing arguments, the call instruction sets up the new
    9494    stack frame to overlap the end of the old stack frame:
     
    100100                             |---------------------------------->                        <
    101101                             |                        | params->|<-locals       | temps->
    102    
     102
    103103    That way, arguments are "copied" into the callee's stack frame for free.
    104    
     104
    105105    If the caller supplies too many arguments, this trick doesn't work. The
    106106    extra arguments protrude into space reserved for locals and temporaries.
     
    111111    This copying strategy ensures that all named values will be at the indices
    112112    expected by the callee.
    113 
    114113*/
    115114
     
    133132    if (m_shouldEmitDebugHooks)
    134133        m_codeBlock->needsFullScopeChain = true;
    135    
     134
    136135    m_scopeNode->emitCode(*this);
    137136
     
    196195
    197196    JSGlobalObject* globalObject = scopeChain.globalObject();
    198    
     197
    199198    ExecState* exec = globalObject->globalExec();
    200199   
     
    207206            emitNewFunction(addVar(funcDecl->m_ident, false), funcDecl);
    208207        }
    209        
     208
    210209        for (size_t i = 0; i < varStack.size(); ++i) {
    211210            if (!globalObject->hasProperty(exec, varStack[i].first))
     
    245244        FuncDeclNode* funcDecl = functionStack[i].get();
    246245        const Identifier& ident = funcDecl->m_ident;
    247        
     246
    248247        m_functions.add(ident.ustring().rep());
    249248        emitNewFunction(addVar(ident, false), funcDecl);
     
    255254        if (ident == m_propertyNames->arguments)
    256255            continue;
    257        
     256
    258257        RegisterID* r0;
    259258        if (addVar(ident, r0, varStack[i].second & DeclarationStacks::IsConstant))
     
    306305        result = &(m_locals[localsIndex(m_nextParameter)]);
    307306    }
    308    
     307
    309308    // To maintain the calling convention, we have to allocate unique space for
    310309    // each parameter, even if the parameter doesn't make it into the symbol table.
     
    336335    if (m_codeType == EvalCode)
    337336        return 0;
    338    
     337
    339338    SymbolTableEntry entry = symbolTable().get(ident.ustring().rep());
    340339    ASSERT(!entry.isEmpty());
    341    
     340
    342341    return &m_locals[localsIndex(entry.getIndex())];
    343342}
     
    430429    if (result.second) // new entry
    431430        m_codeBlock->identifiers.append(rep);
    432    
     431
    433432    return result.first->second;
    434433}
     
    439438    if (result.second) // new entry
    440439        m_codeBlock->jsValues.append(v);
    441    
     440
    442441    return result.first->second;
    443442}
     
    752751    for (; iter != end; ++iter, ++depth) {
    753752        JSObject* currentScope = *iter;
    754         if (!currentScope->isVariableObject()) 
     753        if (!currentScope->isVariableObject())
    755754            break;
    756755        JSVariableObject* currentVariableObject = static_cast<JSVariableObject*>(currentScope);
     
    798797    return emitGetScopedVar(dst, depth, index);
    799798}
    800    
     799
    801800RegisterID* CodeGenerator::emitGetScopedVar(RegisterID* dst, size_t depth, int index)
    802801{
     
    807806    return dst;
    808807}
    809    
     808
    810809RegisterID* CodeGenerator::emitPutScopedVar(size_t depth, int index, RegisterID* value)
    811810{
     
    824823    return dst;
    825824}
    826    
     825
    827826RegisterID* CodeGenerator::emitResolveWithBase(RegisterID* baseDst, RegisterID* propDst, const Identifier& property)
    828827{
     
    965964    RefPtr<RegisterID> refFunc = func;
    966965    RefPtr<RegisterID> refBase = base;
    967    
     966
    968967    // Reserve space for call frame.
    969968    Vector<RefPtr<RegisterID>, Machine::CallFrameHeaderSize> callFrame;
     
    11071106        return 0;
    11081107    }
    1109    
     1108
    11101109    for (int i = m_jumpContextStack.size() - 1; i >= 0; i--) {
    11111110        JumpContext* scope = &m_jumpContextStack[i];
     
    11291128        return 0;
    11301129    }
    1131    
     1130
    11321131    for (int i = m_jumpContextStack.size() - 1; i >= 0; i--) {
    11331132        JumpContext* scope = &m_jumpContextStack[i];
     
    11521151
    11531152        if (nNormalScopes) {
    1154             // We need to remove a number of dynamic scopes to get to the next 
     1153            // We need to remove a number of dynamic scopes to get to the next
    11551154            // finally block
    11561155            instructions().append(machine().getOpcode(op_jmp_scopes));
    11571156            instructions().append(nNormalScopes);
    1158            
     1157
    11591158            // If topScope == bottomScope then there isn't actually a finally block
    11601159            // left to emit, so make the jmp_scopes jump directly to the target label
     
    11641163            }
    11651164
    1166             // Otherwise we just use jmp_scopes to pop a group of scopes and go 
     1165            // Otherwise we just use jmp_scopes to pop a group of scopes and go
    11671166            // to the next instruction
    11681167            RefPtr<LabelID> nextInsn = newLabel();
     
    12261225    return targetRegister;
    12271226}
    1228    
     1227
    12291228void CodeGenerator::emitThrow(RegisterID* exception)
    12301229{
Note: See TracChangeset for help on using the changeset viewer.