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


Ignore:
Timestamp:
Sep 26, 2008, 3:40:26 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-26 Geoffrey Garen <[email protected]>

Reviewed by Maciej Stachowiak.


Removed dynamic check for whether the callee needs an activation object.
Replaced with callee code to create the activation object.

0.5% speedup on SunSpider.
No change on v8 benchmark. (Might be a speedup, but it's in range of the
variance.)

0.7% speedup on v8 benchmark in bytecode.
1.3% speedup on empty call benchmark in bytecode.

  • VM/CTI.cpp: (JSC::CTI::privateCompileMainPass): Added support for op_init_activation, the new opcode that specifies that the callee's initialization should create an activation object. (JSC::CTI::privateCompile): Removed previous code that did a similar thing in an ad-hoc way.
  • VM/CodeBlock.cpp: (JSC::CodeBlock::dump): Added a case for dumping op_init_activation.
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::generate): Added fixup code to change op_init to op_init_activation if necessary. (With a better parser, we would know which to use from the beginning.)
  • VM/Instruction.h: (JSC::Instruction::Instruction): (WTF::): Faster traits for the instruction vector. An earlier version of this patch relied on inserting at the beginning of the vector, and depended on this change for speed.
  • VM/Machine.cpp: (JSC::Machine::execute): Removed clients of setScopeChain, the old abstraction for dynamically checking for whether an activation object needed to be created. (JSC::Machine::privateExecute): ditto

(JSC::Machine::cti_op_push_activation): Renamed this function from
cti_vm_updateScopeChain, and made it faster by removing the call to
setScopeChain.

  • VM/Machine.h:
  • VM/Opcode.h: Declared op_init_activation.
File:
1 edited

Legend:

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

    r36876 r36972  
    980980    JSValue* result = CTI::execute(newCodeBlock->ctiCode, &newExec, &m_registerFile, r, scopeChain, newCodeBlock, exception);
    981981#else
    982     setScopeChain(&newExec, scopeChain, scopeChainForCall(exec, functionBodyNode, newCodeBlock, scopeChain, r));
     982    setScopeChain(&newExec, scopeChain, scopeChain);
    983983    JSValue* result = privateExecute(Normal, &newExec, &m_registerFile, r, scopeChain, newCodeBlock, exception);
    984984#endif
     
    32993299
    33003300            codeBlock = newCodeBlock;
    3301             setScopeChain(exec, scopeChain, scopeChainForCall(exec, functionBodyNode, codeBlock, callDataScopeChain, r));
     3301            setScopeChain(exec, scopeChain, callDataScopeChain);
    33023302            vPC = codeBlock->instructions.begin();
    33033303
     
    33903390        NEXT_OPCODE;
    33913391    }
     3392    BEGIN_OPCODE(op_init_activation) {
     3393        size_t i = 0;
     3394
     3395        for (size_t count = codeBlock->numVars; i < count; ++i)
     3396            r[i] = jsUndefined();
     3397
     3398        for (size_t count = codeBlock->constantRegisters.size(), j = 0; j < count; ++i, ++j)
     3399            r[i] = codeBlock->constantRegisters[j];
     3400
     3401        JSActivation* activation = new (exec) JSActivation(exec, static_cast<FunctionBodyNode*>(codeBlock->ownerNode), r);
     3402        r[RegisterFile::OptionalCalleeActivation] = activation;
     3403        setScopeChain(exec, scopeChain, scopeChain->copy()->push(activation));
     3404
     3405        ++vPC;
     3406        NEXT_OPCODE;
     3407    }
    33923408    BEGIN_OPCODE(op_construct) {
    33933409        /* construct dst(r) constr(r) constrProto(r) firstArg(r) argCount(n) registerOffset(n)
     
    34483464
    34493465            codeBlock = newCodeBlock;
    3450             setScopeChain(exec, scopeChain, scopeChainForCall(exec, functionBodyNode, codeBlock, callDataScopeChain, r));
     3466            setScopeChain(exec, scopeChain, callDataScopeChain);
    34513467            vPC = codeBlock->instructions.begin();
    34523468
     
    44714487}
    44724488
    4473 void Machine::cti_vm_updateScopeChain(CTI_ARGS)
     4489void Machine::cti_op_push_activation(CTI_ARGS)
    44744490{
    44754491    ExecState* exec = ARG_exec;
    44764492    CodeBlock* codeBlock = ARG_codeBlock;
    44774493    ScopeChainNode* scopeChain = ARG_scopeChain;
    4478 
    4479     exec->machine()->setScopeChain(exec, scopeChain, scopeChainForCall(exec, static_cast<FunctionBodyNode*>(codeBlock->ownerNode), codeBlock, scopeChain, ARG_r));
    4480 
     4494    Register* r = ARG_r;
     4495
     4496    JSActivation* activation = new (exec) JSActivation(exec, static_cast<FunctionBodyNode*>(codeBlock->ownerNode), r);
     4497    r[RegisterFile::OptionalCalleeActivation] = activation;
     4498
     4499    setScopeChain(exec, scopeChain, scopeChain->copy()->push(activation));
    44814500    ARG_setScopeChain(scopeChain);
    44824501}
Note: See TracChangeset for help on using the changeset viewer.