Ignore:
Timestamp:
Jul 24, 2013, 9:01:38 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: Misc JIT probe enhacements.
https://bugs.webkit.org/show_bug.cgi?id=116586.

Reviewed by Michael Saboff.

  1. Added JIT probe support for ARMv7 and traditional ARM. Built and tested on ARMv7. ARM version not tested nor built.
  2. Fix the following bugs in the X86 and X86_64 probes:
    1. Cannot assume that the stack pointer is already aligned when we push args for the probe. Instead, we ensure the stack alignment at runtime when we set up the probe call. This is now done in the ctiMasmProbeTrampoline.
    2. On return, the user probe function may have altered the stack pointer value to be restored. Previously, if the sp restore value points to some of the other register restore values in the ProbeContext record, we will fail to return from the probe having those user specified value as we're expected to do. This is now fixed.
  3. Rearranged the X86/X86_64 registers order to organize them like gdb expects on X86_64.
  4. We also now preserve the condition code registers.
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • assembler/ARMAssembler.h:
  • assembler/ARMv7Assembler.h:

(ARMRegisters):

  • assembler/MacroAssemblerARM.cpp:

(JSC::isVFPPresent):
(JSC::MacroAssemblerARM::ProbeContext::dumpCPURegisters):
(JSC::MacroAssemblerARM::ProbeContext::dump):
(JSC::MacroAssemblerARM::probe):

  • assembler/MacroAssemblerARM.h:

(MacroAssemblerARM):
(CPUState):
(ProbeContext):
(JSC::MacroAssemblerARM::trustedImm32FromPtr):

  • assembler/MacroAssemblerARMv7.h:

(MacroAssemblerARMv7):
(CPUState):
(ProbeContext):
(JSC::MacroAssemblerARMv7::trustedImm32FromPtr):

  • assembler/MacroAssemblerX86.h:

(MacroAssemblerX86):
(JSC::MacroAssemblerX86::probe):

  • assembler/MacroAssemblerX86Common.cpp:

(JSC::MacroAssemblerX86Common::ProbeContext::dumpCPURegisters):

  • assembler/MacroAssemblerX86_64.h:

(JSC::MacroAssemblerX86_64::probe):

  • assembler/X86Assembler.h:
  • config.h:
  • jit/JITStubsARM.h:
  • jit/JITStubsARMv7.h:
  • jit/JITStubsX86.h:
  • jit/JITStubsX86Common.h:
  • jit/JITStubsX86_64.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86.h

    r153162 r153197  
    293293
    294294#if USE(MASM_PROBE)
    295     // This function emits code to preserve the CPUState (e.g. registers),
    296     // call a user supplied probe function, and restore the CPUState before
    297     // continuing with other JIT generated code.
    298     //
    299     // The user supplied probe function will be called with a single pointer to
    300     // a ProbeContext struct (defined above) which contains, among other things,
    301     // the preserved CPUState. This allows the user probe function to inspect
    302     // the CPUState at that point in the JIT generated code.
    303     //
    304     // If the user probe function alters the register values in the ProbeContext,
    305     // the altered values will be loaded into the CPU registers when the probe
    306     // returns.
    307     //
    308     // The ProbeContext is stack allocated and is only valid for the duration
    309     // of the call to the user probe function.
    310 
     295    // For details about probe(), see comment in MacroAssemblerX86_64.h.
    311296    void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0);
    312297#endif // USE(MASM_PROBE)
     
    353338extern "C" void ctiMasmProbeTrampoline();
    354339
    355 // What code is emitted for the probe?
    356 // ==================================
    357 // We want to keep the size of the emitted probe invocation code as compact as
    358 // possible to minimize the perturbation to the JIT generated code. However,
    359 // we also need to preserve the CPU registers and set up the ProbeContext to be
    360 // passed to the user probe function.
    361 //
    362 // Hence, we do only the minimum here to preserve the eax (to be used as a
    363 // scratch register) and esp registers, and pass the probe arguments. We'll let
    364 // the ctiMasmProbeTrampoline handle the rest of the probe invocation work
    365 // i.e. saving the CPUState (and setting up the ProbeContext), calling the user
    366 // probe function, and restoring the CPUState before returning to JIT generated
    367 // code.
    368 //
    369 // What values are in the saved registers?
    370 // ======================================
    371 // Conceptually, the saved registers should contain values as if the probe
    372 // is not present in the JIT generated code. Hence, they should contain values
    373 // that are expected at the start of the instruction immediately following the
    374 // probe.
    375 //
    376 // Specifcally, the saved esp will point to the stack position before we
    377 // push the ProbeContext frame. The saved eip will point to the address of
    378 // the instruction immediately following the probe.
     340// For details on "What code is emitted for the probe?" and "What values are in
     341// the saved registers?", see comment for MacroAssemblerX86::probe() in
     342// MacroAssemblerX86_64.h.
    379343
    380344inline void MacroAssemblerX86::probe(MacroAssemblerX86::ProbeFunction function, void* arg1, void* arg2)
    381345{
    382     RegisterID esp = RegisterID::esp;
    383     #define probeContextField(field) Address(esp, offsetof(ProbeContext, field))
    384 
    385     // The X86_64 ABI specifies that the worse case stack alignment requirement
    386     // is 32 bytes.
    387     const int probeFrameSize = WTF::roundUpToMultipleOf(32, sizeof(ProbeContext));
    388     sub32(TrustedImm32(probeFrameSize), esp);
    389 
    390     store32(RegisterID::eax, probeContextField(cpu.eax));
    391 
    392     move(TrustedImm32(probeFrameSize), RegisterID::eax);
    393     add32(esp, RegisterID::eax);
    394     store32(RegisterID::eax, probeContextField(cpu.esp));
    395 
    396     store32(trustedImm32FromPtr(function), probeContextField(probeFunction));
    397     store32(trustedImm32FromPtr(arg1), probeContextField(arg1));
    398     store32(trustedImm32FromPtr(arg2), probeContextField(arg2));
     346    push(RegisterID::esp);
     347    push(RegisterID::eax);
     348    push(trustedImm32FromPtr(arg2));
     349    push(trustedImm32FromPtr(arg1));
     350    push(trustedImm32FromPtr(function));
    399351
    400352    move(trustedImm32FromPtr(ctiMasmProbeTrampoline), RegisterID::eax);
    401353    call(RegisterID::eax);
    402 
    403     #undef probeContextField
    404354}
    405355#endif // USE(MASM_PROBE)
Note: See TracChangeset for help on using the changeset viewer.