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


Ignore:
Timestamp:
Sep 17, 2008, 12:29:19 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-17 Gavin Barraclough <[email protected]>

Reviewed by Geoff Garen.

Optimizations for op_call in CTI. Move check for (ctiCode == 0) into JIT code,
move copying of scopeChain for CodeBlocks that needFullScopeChain into head of
functions, instead of checking prior to making the call.

3% on v8-tests (4% on richards, 6% in delta-blue)

  • VM/CTI.cpp: (JSC::CTI::compileOpCall): (JSC::CTI::privateCompileSlowCases): (JSC::CTI::privateCompile):
  • VM/Machine.cpp: (JSC::Machine::execute): (JSC::Machine::cti_op_call_JSFunction): (JSC::Machine::cti_vm_compile): (JSC::Machine::cti_vm_updateScopeChain): (JSC::Machine::cti_op_construct_JSConstruct):
  • VM/Machine.h:
File:
1 edited

Legend:

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

    r36518 r36544  
    469469    // This handles JSFunctions
    470470    emitCall(i, ((type == OpConstruct) ? Machine::cti_op_construct_JSConstruct : Machine::cti_op_call_JSFunction));
     471    // Check the ctiCode has been generated - if not, this is handled in a slow case.
     472    m_jit.testl_rr(X86::eax, X86::eax);
     473    m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJe(), i));
    471474    m_jit.call_r(X86::eax);
    472475   
     
    19421945        }
    19431946        CTI_COMPILE_BINARY_OP_SLOW_CASE(op_mul);
     1947
     1948        case op_call:
     1949        case op_call_eval:
     1950        case op_construct: {
     1951            m_jit.link(iter->from, m_jit.label());
     1952
     1953            // We jump to this slow case if the ctiCode for the codeBlock has not yet been generated; compile it now.
     1954            emitCall(i, Machine::cti_vm_compile);
     1955            m_jit.call_r(X86::eax);
     1956           
     1957            // Instead of checking for 0 we could initialize the CodeBlock::ctiCode to point to a trampoline that would trigger the translation.
     1958
     1959            // In the interpreter the following actions are performed by op_ret:
     1960           
     1961            // Store the scope chain - returned by op_ret in %edx (see below) - to ExecState::m_scopeChain and CTI_ARGS_scopeChain on the stack.
     1962            emitGetCTIParam(CTI_ARGS_exec, X86::ecx);
     1963            emitPutCTIParam(X86::edx, CTI_ARGS_scopeChain);
     1964            m_jit.movl_rm(X86::edx, OBJECT_OFFSET(ExecState, m_scopeChain), X86::ecx);
     1965            // Restore ExecState::m_callFrame.
     1966            m_jit.leal_mr(-(m_codeBlock->numLocals + RegisterFile::CallFrameHeaderSize) * sizeof(Register), X86::edi, X86::edx);
     1967            m_jit.movl_rm(X86::edx, OBJECT_OFFSET(ExecState, m_callFrame), X86::ecx);
     1968            // Restore CTI_ARGS_codeBlock.
     1969            emitPutCTIParam(m_codeBlock, CTI_ARGS_codeBlock);
     1970
     1971            emitPutResult(instruction[i + 1].u.operand);
     1972            i += 6;
     1973            break;
     1974        }
     1975
    19441976        default:
    19451977            ASSERT_NOT_REACHED();
     
    19591991    emitGetCTIParam(CTI_ARGS_r, X86::edi); // edi := r
    19601992    emitPutToCallFrameHeader(X86::ecx, RegisterFile::CTIReturnEIP);
     1993
     1994    // Lazy copy of the scopeChain
     1995    X86Assembler::JmpSrc callToUpdateScopeChain;
     1996    if ((m_codeBlock->codeType == FunctionCode) && m_codeBlock->needsFullScopeChain)
     1997        callToUpdateScopeChain = m_jit.emitCall();
    19611998
    19621999    privateCompileMainPass();
     
    20082045    }
    20092046
     2047    if ((m_codeBlock->codeType == FunctionCode) && m_codeBlock->needsFullScopeChain)
     2048        X86Assembler::link(code, callToUpdateScopeChain, (void*)Machine::cti_vm_updateScopeChain);
     2049
    20102050    // Link absolute addresses for jsr
    20112051    for (Vector<JSRInfo>::iterator iter = m_jsrSites.begin(); iter != m_jsrSites.end(); ++iter)
     
    20172057        info.hotPathBegin = X86Assembler::getRelocatedAddress(code, m_structureStubCompilationInfo[i].hotPathBegin);
    20182058    }
    2019 
    20202059
    20212060    m_codeBlock->ctiCode = code;
Note: See TracChangeset for help on using the changeset viewer.