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


Ignore:
Timestamp:
Sep 10, 2008, 2:23:35 AM (17 years ago)
Author:
[email protected]
Message:

Add optimised access to known properties on the global object.

Reviewed by Maciej Stachowiak

Improve cross scope access to the global object by emitting
code to access it directly rather than by walking the scope chain.

This is a 0.8% win in SunSpider and a 1.7% win in the v8 benchmarks.

File:
1 edited

Legend:

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

    r36316 r36317  
    629629            break;
    630630        }
     631        case op_get_global_var: {
     632            JSVariableObject* globalObject = static_cast<JSVariableObject*>(instruction[i + 2].u.jsCell);
     633            m_jit.movl_i32r(reinterpret_cast<unsigned>(globalObject), X86::eax);
     634            emitGetVariableObjectRegister(X86::eax, instruction[i + 3].u.operand, X86::eax);
     635            emitPutResult(instruction[i + 1].u.operand, X86::eax);
     636            i += 4;
     637            break;
     638        }
     639        case op_put_global_var: {
     640            JSVariableObject* globalObject = static_cast<JSVariableObject*>(instruction[i + 1].u.jsCell);
     641            m_jit.movl_i32r(reinterpret_cast<unsigned>(globalObject), X86::eax);
     642            emitGetArg(instruction[i + 3].u.operand, X86::edx);
     643            emitPutVariableObjectRegister(X86::edx, X86::eax, instruction[i + 2].u.operand);
     644            i += 4;
     645            break;
     646        }
    631647        case op_get_scoped_var: {
    632648            int skip = instruction[i + 3].u.operand + m_codeBlock->needsFullScopeChain;
     
    637653
    638654            m_jit.movl_mr(OBJECT_OFFSET(ScopeChainNode, object), X86::eax, X86::eax);
    639             m_jit.movl_mr(JSVariableObject::offsetOf_d(), X86::eax, X86::eax);
    640             m_jit.movl_mr(JSVariableObject::offsetOf_Data_registers(), X86::eax, X86::eax);
    641             m_jit.movl_mr((instruction[i + 2].u.operand) * sizeof(Register), X86::eax, X86::eax);
     655            emitGetVariableObjectRegister(X86::eax, instruction[i + 2].u.operand, X86::eax);
    642656            emitPutResult(instruction[i + 1].u.operand);
    643657            i += 4;
     
    653667
    654668            m_jit.movl_mr(OBJECT_OFFSET(ScopeChainNode, object), X86::edx, X86::edx);
    655             m_jit.movl_mr(JSVariableObject::offsetOf_d(), X86::edx, X86::edx);
    656             m_jit.movl_mr(JSVariableObject::offsetOf_Data_registers(), X86::edx, X86::edx);
    657             m_jit.movl_rm(X86::eax, (instruction[i + 1].u.operand) * sizeof(Register), X86::edx);
     669            emitPutVariableObjectRegister(X86::eax, X86::edx, instruction[i + 1].u.operand);
    658670            i += 4;
    659671            break;
     
    18311843}
    18321844
     1845void CTI::emitGetVariableObjectRegister(X86Assembler::RegisterID variableObject, int index, X86Assembler::RegisterID dst)
     1846{
     1847    m_jit.movl_mr(JSVariableObject::offsetOf_d(), variableObject, dst);
     1848    m_jit.movl_mr(JSVariableObject::offsetOf_Data_registers(), dst, dst);
     1849    m_jit.movl_mr(index * sizeof(Register), dst, dst);
     1850}
     1851
     1852void CTI::emitPutVariableObjectRegister(X86Assembler::RegisterID src, X86Assembler::RegisterID variableObject, int index)
     1853{
     1854    m_jit.movl_mr(JSVariableObject::offsetOf_d(), variableObject, variableObject);
     1855    m_jit.movl_mr(JSVariableObject::offsetOf_Data_registers(), variableObject, variableObject);
     1856    m_jit.movl_rm(src, index * sizeof(Register), variableObject);
     1857}
     1858
    18331859#if ENABLE(WREC)
    18341860
Note: See TracChangeset for help on using the changeset viewer.