Changeset 36695 in webkit for trunk/JavaScriptCore/VM


Ignore:
Timestamp:
Sep 19, 2008, 8:00:43 PM (17 years ago)
Author:
[email protected]
Message:

Improve peformance of local variable initialisation.

Reviewed by Maciej Stachowiak

Pull local and constant initialisation out of slideRegisterWindowForCall
and into its own opcode. This allows the JIT to generate the initialisation
code for a function directly into the instruction stream and so avoids a few
branches on function entry.

Results a 1% progression in SunSpider, particularly in a number of the bitop
tests where the called functions are very fast.

Location:
trunk/JavaScriptCore/VM
Files:
6 edited

Legend:

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

    r36605 r36695  
    178178{
    179179    m_jit.movl_rm(from, dst * sizeof(Register), X86::edi);
     180    // FIXME: #ifndef NDEBUG, Write the correct m_type to the register.
     181}
     182
     183ALWAYS_INLINE void CTI::emitInitialiseRegister(unsigned dst)
     184{
     185    m_jit.movl_i32m(reinterpret_cast<unsigned>(jsUndefined()), dst * sizeof(Register), X86::edi);
    180186    // FIXME: #ifndef NDEBUG, Write the correct m_type to the register.
    181187}
     
    526532void CTI::privateCompileMainPass()
    527533{
     534    if (m_codeBlock->codeType == FunctionCode) {
     535        for (int i = -m_codeBlock->numVars; i < 0; i++)
     536            emitInitialiseRegister(i);
     537    }
     538    for (size_t i = 0; i < m_codeBlock->constantRegisters.size(); ++i)
     539        emitInitialiseRegister(i);
     540
    528541    Instruction* instruction = m_codeBlock->instructions.begin();
    529542    unsigned instructionCount = m_codeBlock->instructions.size();
     
    15221535            break;
    15231536        }
     1537        case op_initialise_locals: {
     1538            i++;
     1539            break;
     1540        }
    15241541        case op_get_array_length:
    15251542        case op_get_by_id_chain:
  • trunk/JavaScriptCore/VM/CTI.h

    r36514 r36695  
    346346        void emitPutResult(unsigned dst, X86Assembler::RegisterID from = X86::eax);
    347347
     348        void emitInitialiseRegister(unsigned dst);
     349
    348350        void emitPutCTIParam(void* value, unsigned name);
    349351        void emitPutCTIParam(X86Assembler::RegisterID from, unsigned name);
  • trunk/JavaScriptCore/VM/CodeBlock.cpp

    r36480 r36695  
    352352    int location = it - begin;
    353353    switch (exec->machine()->getOpcodeID(it->u.opcode)) {
     354        case op_initialise_locals: {
     355            printf("[%4d] initialise_locals\n", location);
     356            break;
     357        }
    354358        case op_unexpected_load: {
    355359            int r0 = (++it)->u.operand;
  • trunk/JavaScriptCore/VM/CodeGenerator.cpp

    r36660 r36695  
    269269    , m_lastOpcodeID(op_end)
    270270{
     271    emitOpcode(op_initialise_locals);
    271272    codeBlock->globalData = m_globalData;
    272273
     
    317318    , m_lastOpcodeID(op_end)
    318319{
     320    emitOpcode(op_initialise_locals);
    319321    codeBlock->globalData = m_globalData;
    320322
  • trunk/JavaScriptCore/VM/Machine.cpp

    r36604 r36695  
    544544   
    545545    // initialize local variable slots
    546     for (Register* it = r - newCodeBlock->numVars; it != r; ++it)
    547         (*it) = jsUndefined();
    548 
    549     for (size_t i = 0; i < newCodeBlock->constantRegisters.size(); ++i)
    550         r[i] = newCodeBlock->constantRegisters[i];
     546#if ENABLE(CTI)
     547    if (!newCodeBlock->ctiCode)
     548#endif
     549    {
     550
     551    }
    551552
    552553    return r;
     
    33443345        NEXT_OPCODE;
    33453346    }
     3347    BEGIN_OPCODE(op_initialise_locals) {
     3348        for (Register* it = r - codeBlock->numVars + (codeBlock->codeType == EvalCode); it < r; ++it)
     3349            (*it) = jsUndefined();
     3350        for (size_t i = 0; i < codeBlock->constantRegisters.size(); ++i)
     3351            r[i] = codeBlock->constantRegisters[i];
     3352        ++vPC;
     3353        NEXT_OPCODE;
     3354    }
    33463355    BEGIN_OPCODE(op_construct) {
    33473356        /* construct dst(r) constr(r) constrProto(r) firstArg(r) argCount(n)
  • trunk/JavaScriptCore/VM/Opcode.h

    r36480 r36695  
    4141
    4242    #define FOR_EACH_OPCODE_ID(macro) \
     43        macro(op_initialise_locals) \
    4344        macro(op_unexpected_load) \
    4445        macro(op_new_object) \
Note: See TracChangeset for help on using the changeset viewer.