Ignore:
Timestamp:
Jun 4, 2009, 4:00:58 AM (16 years ago)
Author:
[email protected]
Message:

2009-06-04 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Wrap the code that plants pushes/pops planted by JIT in explanatorily named
methods; move property storage reallocation into a standard stub function.

~No performance impact (possible <1% progression on x86-64, likely just noise).

  • jit/JIT.cpp: (JSC::JIT::privateCompile): (JSC::JIT::privateCompileCTIMachineTrampolines):

Wrap calls to push/pop.

  • jit/JIT.h:

Declare the new wrapper methods.

  • jit/JITInlineMethods.h: (JSC::JIT::preverveReturnAddressAfterCall): (JSC::JIT::restoreReturnAddressBeforeReturn):

Define the new wrapper methods.

  • jit/JITOpcodes.cpp: (JSC::JIT::emit_op_end): (JSC::JIT::emit_op_ret):

Wrap calls to push/pop.

  • jit/JITPropertyAccess.cpp: (JSC::JIT::privateCompilePutByIdTransition):

Move property storage reallocation into a standard stub function.

  • jit/JITStubs.cpp: (JSC::JITStubs::DEFINE_STUB_FUNCTION):
  • jit/JITStubs.h: (JSC::JITStubs::):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITPropertyAccess.cpp

    r44341 r44412  
    424424}
    425425
    426 static JSObject* resizePropertyStorage(JSObject* baseObject, int32_t oldSize, int32_t newSize)
    427 {
    428     baseObject->allocatePropertyStorage(oldSize, newSize);
    429     return baseObject;
    430 }
    431 
    432 static inline bool transitionWillNeedStorageRealloc(Structure* oldStructure, Structure* newStructure)
    433 {
    434     return oldStructure->propertyStorageCapacity() != newStructure->propertyStorageCapacity();
    435 }
    436 
    437426void JIT::privateCompilePutByIdTransition(StructureStubInfo* stubInfo, Structure* oldStructure, Structure* newStructure, size_t cachedOffset, StructureChain* chain, ProcessorReturnAddress returnAddress)
    438427{
     
    443432    JumpList successCases;
    444433
    445     //  ecx = baseObject
     434    // ecx = baseObject
    446435    loadPtr(Address(regT0, FIELD_OFFSET(JSCell, m_structure)), regT2);
    447436    // proto(ecx) = baseObject->structure()->prototype()
     
    468457
    469458    // emit a call only if storage realloc is needed
    470     bool willNeedStorageRealloc = transitionWillNeedStorageRealloc(oldStructure, newStructure);
     459    bool willNeedStorageRealloc = oldStructure->propertyStorageCapacity() != newStructure->propertyStorageCapacity();
    471460    if (willNeedStorageRealloc) {
    472         pop(X86::ebx);
    473 #if PLATFORM(X86_64)
    474         // Setup arguments in edi, esi, edx.  Since baseObject is in regT0,
    475         // regT0 had better not be any of these registers.
    476         ASSERT(regT0 != X86::edx);
    477         ASSERT(regT0 != X86::esi);
    478         ASSERT(regT0 != X86::edi);
    479         move(Imm32(newStructure->propertyStorageCapacity()), X86::edx);
    480         move(Imm32(oldStructure->propertyStorageCapacity()), X86::esi);
    481         move(regT0, X86::edi);
    482         callTarget = call();
    483 #else
    484         push(Imm32(newStructure->propertyStorageCapacity()));
    485         push(Imm32(oldStructure->propertyStorageCapacity()));
    486         push(regT0);
    487         callTarget = call();
    488         addPtr(Imm32(3 * sizeof(void*)), X86::esp);
    489 #endif
    490         emitGetJITStubArg(3, regT1);
    491         push(X86::ebx);
     461        // This trampoline was called to like a JIT stub; before we can can call again we need to
     462        // remove the return address from the stack, to prevent the stack from becoming misaligned.
     463        preverveReturnAddressAfterCall(regT3);
     464 
     465        JITStubCall stubCall(this, JITStubs::cti_op_put_by_id_transition_realloc);
     466        stubCall.addArgument(regT0);
     467        stubCall.addArgument(Imm32(oldStructure->propertyStorageCapacity()));
     468        stubCall.addArgument(Imm32(newStructure->propertyStorageCapacity()));
     469        stubCall.addArgument(regT1); // This argument is not used in the stub; we set it up on the stack so that it can be restored, below.
     470        stubCall.call(regT0);
     471        emitGetJITStubArg(4, regT1);
     472
     473        restoreReturnAddressBeforeReturn(regT3);
    492474    }
    493475
     
    512494    patchBuffer.link(failureCall, JITStubs::cti_op_put_by_id_fail);
    513495
    514     if (willNeedStorageRealloc)
    515         patchBuffer.link(callTarget, resizePropertyStorage);
     496    if (willNeedStorageRealloc) {
     497        ASSERT(m_calls.size() == 1);
     498        patchBuffer.link(m_calls[0].from, JITStubs::cti_op_put_by_id_transition_realloc);
     499    }
    516500   
    517501    CodeLocationLabel entryLabel = patchBuffer.finalizeCodeAddendum();
Note: See TracChangeset for help on using the changeset viewer.