Changeset 37366 in webkit for trunk/JavaScriptCore/VM/Machine.cpp


Ignore:
Timestamp:
Oct 6, 2008, 8:53:47 PM (17 years ago)
Author:
[email protected]
Message:

2008-10-06 Cameron Zwarich <[email protected]>

Reviewed by Oliver Hunt.

Bug 21396: Remove the OptionalCalleeActivation call frame slot
<https://bugs.webkit.org/show_bug.cgi?id=21396>

Remove the OptionalCalleeActivation call frame slot. We have to be
careful to store the activation object in a register, because objects
in the scope chain do not get marked.

This is a 0.3% speedup on both SunSpider and the V8 benchmark.

  • VM/CTI.cpp: (JSC::CTI::privateCompileMainPass):
  • VM/CodeBlock.cpp: (JSC::CodeBlock::dump):
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::CodeGenerator): (JSC::CodeGenerator::emitReturn):
  • VM/CodeGenerator.h:
  • VM/Machine.cpp: (JSC::Machine::dumpRegisters): (JSC::Machine::unwindCallFrame): (JSC::Machine::privateExecute): (JSC::Machine::cti_op_call_JSFunction): (JSC::Machine::cti_op_push_activation): (JSC::Machine::cti_op_tear_off_activation): (JSC::Machine::cti_op_construct_JSConstruct):
  • VM/Machine.h: (JSC::Machine::initializeCallFrame):
  • VM/RegisterFile.h: (JSC::RegisterFile::):
File:
1 edited

Legend:

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

    r37337 r37366  
    702702    printf("[ArgumentCount]            | %10p | %10p \n", it, (*it).v()); ++it;
    703703    printf("[Callee]                   | %10p | %10p \n", it, (*it).v()); ++it;
    704     printf("[OptionalCalleeActivation] | %10p | %10p \n", it, (*it).v()); ++it;
    705704    printf("[OptionalCalleeArguments]  | %10p | %10p \n", it, (*it).v()); ++it;
    706705    printf("----------------------------------------------------\n");
     
    776775    }
    777776
    778     if (oldCodeBlock->needsFullScopeChain)
    779         scopeChain->deref();
    780 
    781777    // If this call frame created an activation or an 'arguments' object, tear it off.
    782     if (JSActivation* activation = static_cast<JSActivation*>(r[RegisterFile::OptionalCalleeActivation].getJSValue())) {
     778    if (oldCodeBlock->codeType == FunctionCode && oldCodeBlock->needsFullScopeChain) {
     779        while (!scopeChain->object->isObject(&JSActivation::info))
     780            scopeChain = scopeChain->pop();
     781        JSActivation* activation = static_cast<JSActivation*>(scopeChain->object);
    783782        ASSERT(activation->isObject(&JSActivation::info));
     783
    784784        Arguments* arguments = static_cast<Arguments*>(r[RegisterFile::OptionalCalleeArguments].getJSValue());
    785785        ASSERT(!arguments || arguments->isObject(&Arguments::info));
     786
    786787        activation->copyRegisters(arguments);
    787788    } else if (Arguments* arguments = static_cast<Arguments*>(r[RegisterFile::OptionalCalleeArguments].getJSValue())) {
     
    790791            arguments->copyRegisters();
    791792    }
    792    
     793
     794    if (oldCodeBlock->needsFullScopeChain)
     795        scopeChain->deref();
     796
    793797    void* returnPC = r[RegisterFile::ReturnPC].v();
    794798    r = r[RegisterFile::CallerRegisters].r();
     
    33573361    }
    33583362    BEGIN_OPCODE(op_tear_off_activation) {
    3359         JSActivation* activation = static_cast<JSActivation*>(r[RegisterFile::OptionalCalleeActivation].getJSValue());
     3363        int src = (++vPC)->u.operand;
     3364        JSActivation* activation = static_cast<JSActivation*>(r[src].getJSValue());
    33603365        ASSERT(codeBlock(r)->needsFullScopeChain);
    33613366        ASSERT(activation->isObject(&JSActivation::info));
     
    34333438    }
    34343439    BEGIN_OPCODE(op_enter_with_activation) {
    3435         /* enter_with_activation
     3440        /* enter_with_activation dst(r)
    34363441
    34373442           Initializes local variables to undefined, fills constant
    34383443           registers with their values, creates an activation object,
    3439            and places the new activation both in the activation slot
    3440            in the call frame and at the top of the scope chain. If the
    3441            code block does not require an activation, enter should be
    3442            used instead.
     3444           and places the new activation both in dst and at the top
     3445           of the scope chain. If the code block does not require an
     3446           activation, enter should be used instead.
    34433447
    34443448           This opcode should only be used at the beginning of a code
     
    34553459            r[i] = codeBlock->constantRegisters[j];
    34563460
     3461        int dst = (++vPC)->u.operand;
    34573462        JSActivation* activation = new (globalData) JSActivation(exec, static_cast<FunctionBodyNode*>(codeBlock->ownerNode), r);
    3458         r[RegisterFile::OptionalCalleeActivation] = activation;
     3463        r[dst] = activation;
    34593464        r[RegisterFile::ScopeChain] = scopeChain(r)->copy()->push(activation);
    34603465
     
    45824587    r[RegisterFile::ArgumentCount] = ARG_int3; // original argument count (for the sake of the "arguments" object)
    45834588    r[RegisterFile::Callee] = ARG_src1;
    4584     r[RegisterFile::OptionalCalleeActivation] = nullJSValue;
    45854589    r[RegisterFile::OptionalCalleeArguments] = nullJSValue;
    45864590
     
    46014605}
    46024606
    4603 void Machine::cti_op_push_activation(CTI_ARGS)
     4607JSValue* Machine::cti_op_push_activation(CTI_ARGS)
    46044608{
    46054609    ExecState* exec = ARG_exec;
     
    46094613
    46104614    JSActivation* activation = new (ARG_globalData) JSActivation(exec, static_cast<FunctionBodyNode*>(codeBlock->ownerNode), r);
    4611     r[RegisterFile::OptionalCalleeActivation] = activation;
    46124615    r[RegisterFile::ScopeChain] = scopeChain->copy()->push(activation);
     4616    return activation;
    46134617}
    46144618
     
    46694673    Register* r = ARG_r;
    46704674
    4671     JSActivation* activation = static_cast<JSActivation*>(r[RegisterFile::OptionalCalleeActivation].getJSValue());
     4675    JSActivation* activation = static_cast<JSActivation*>(ARG_src1);
    46724676    ASSERT(codeBlock(r)->needsFullScopeChain);
    46734677    ASSERT(activation->isObject(&JSActivation::info));
     
    47864790    r[RegisterFile::ArgumentCount] = argCount; // original argument count (for the sake of the "arguments" object)
    47874791    r[RegisterFile::Callee] = constructor;
    4788     r[RegisterFile::OptionalCalleeActivation] = nullJSValue;
    47894792    r[RegisterFile::OptionalCalleeArguments] = nullJSValue;
    47904793
Note: See TracChangeset for help on using the changeset viewer.