Changeset 36882 in webkit for trunk/JavaScriptCore/VM/CTI.cpp


Ignore:
Timestamp:
Sep 24, 2008, 7:46:09 PM (17 years ago)
Author:
[email protected]
Message:

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

Reviewed by Maciej Stachowiak.


Move most of the return code back into the callee, now that the callee
doesn't have to calculate anything dynamically.


11.5% speedup on empty function call benchmark.


SunSpider says 0.3% faster. SunSpider --v8 says no change.

  • VM/CTI.cpp: (JSC::CTI::compileOpCall): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompileSlowCases):
File:
1 edited

Legend:

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

    r36876 r36882  
    521521    emitCall(i, X86::eax);
    522522   
    523     // In the interpreter the following actions are performed by op_ret:
    524 
    525     // Restore ExecState::m_scopeChain and CTI_ARGS_scopeChain. NOTE: After
    526     // op_ret, %edx holds the caller's scope chain.
    527     emitGetCTIParam(CTI_ARGS_exec, X86::ecx);
    528     emitPutCTIParam(X86::edx, CTI_ARGS_scopeChain);
    529     m_jit.movl_rm(X86::edx, OBJECT_OFFSET(ExecState, m_scopeChain), X86::ecx);
    530     // Restore ExecState::m_callFrame.
    531     m_jit.movl_rm(X86::edi, OBJECT_OFFSET(ExecState, m_callFrame), X86::ecx);
    532     // Restore CTI_ARGS_codeBlock.
     523    // Restore CTI_ARGS_codeBlock. In the interpreter, op_ret does this.
    533524    emitPutCTIParam(m_codeBlock, CTI_ARGS_codeBlock);
    534525
     
    538529        m_jit.link(wasEval, end);
    539530
     531    // Put the return value in dst. In the interpreter, op_ret does this.
    540532    emitPutResult(dst);
    541533}
     
    988980                emitCall(i, Machine::cti_op_ret_scopeChain);
    989981
    990             // Return the result in %eax, and the caller scope chain in %edx (this is read from the callee call frame,
    991             // but is only assigned to ExecState::m_scopeChain if returning to a JSFunction).
     982            // Return the result in %eax.
    992983            emitGetArg(instruction[i + 1].u.operand, X86::eax);
     984
     985            // Restore the scope chain.
    993986            m_jit.movl_mr(RegisterFile::CallerScopeChain * static_cast<int>(sizeof(Register)), X86::edi, X86::edx);
     987            emitGetCTIParam(CTI_ARGS_exec, X86::ecx);
     988            emitPutCTIParam(X86::edx, CTI_ARGS_scopeChain);
     989            m_jit.movl_rm(X86::edx, OBJECT_OFFSET(ExecState, m_scopeChain), X86::ecx);
     990
     991            // Restore ExecState::m_callFrame.
     992            m_jit.movl_rm(X86::edi, OBJECT_OFFSET(ExecState, m_callFrame), X86::ecx);
     993
     994            // Grab the return address.
     995            m_jit.movl_mr(RegisterFile::ReturnPC * static_cast<int>(sizeof(Register)), X86::edi, X86::ecx);
     996
    994997            // Restore the machine return addess from the callframe, roll the callframe back to the caller callframe,
    995998            // and preserve a copy of r on the stack at CTI_ARGS_r.
    996             m_jit.movl_mr(RegisterFile::ReturnPC * static_cast<int>(sizeof(Register)), X86::edi, X86::ecx);
    997999            m_jit.movl_mr(RegisterFile::CallerRegisters * static_cast<int>(sizeof(Register)), X86::edi, X86::edi);
    9981000            emitPutCTIParam(X86::edi, CTI_ARGS_r);
     
    22422244            // Instead of checking for 0 we could initialize the CodeBlock::ctiCode to point to a trampoline that would trigger the translation.
    22432245
    2244             // In the interpreter the following actions are performed by op_ret:
    2245 
    2246             // Restore ExecState::m_scopeChain and CTI_ARGS_scopeChain. NOTE: After
    2247             // op_ret, %edx holds the caller's scope chain.
    2248             emitGetCTIParam(CTI_ARGS_exec, X86::ecx);
    2249             emitPutCTIParam(X86::edx, CTI_ARGS_scopeChain);
    2250             m_jit.movl_rm(X86::edx, OBJECT_OFFSET(ExecState, m_scopeChain), X86::ecx);
    2251             // Restore ExecState::m_callFrame.
    2252             m_jit.movl_rm(X86::edi, OBJECT_OFFSET(ExecState, m_callFrame), X86::ecx);
    2253             // Restore CTI_ARGS_codeBlock.
     2246            // Restore CTI_ARGS_codeBlock. In the interpreter, op_ret does this.
    22542247            emitPutCTIParam(m_codeBlock, CTI_ARGS_codeBlock);
    22552248
     2249            // Put the return value in dst. In the interpreter, op_ret does this.
    22562250            emitPutResult(instruction[i + 1].u.operand);
    22572251            i += 7;
Note: See TracChangeset for help on using the changeset viewer.