Ignore:
Timestamp:
Apr 20, 2017, 4:55:45 PM (8 years ago)
Author:
[email protected]
Message:

Update the MASM probe to only take 1 arg instead of 2 (in addition to the callback function).
https://bugs.webkit.org/show_bug.cgi?id=171088

Reviewed by Michael Saboff and Saam Barati.

Experience shows that we never use the 2nd arg. So, let's remove it to reduce
the footprint at each probe site.

Also fix the MacroAssembler::print() function so that it is a no-op when
!ENABLE(MASM_PROBE). This will allow us to have print() statements in JIT code
without a lot of #if ENABLE(MASM_PROBE)s later.

  • assembler/AbstractMacroAssembler.h:
  • assembler/MacroAssembler.cpp:

(JSC::stdFunctionCallback):
(JSC::MacroAssembler::probe):

  • assembler/MacroAssembler.h:
  • assembler/MacroAssemblerARM.cpp:

(JSC::MacroAssemblerARM::probe):

  • assembler/MacroAssemblerARM.h:
  • assembler/MacroAssemblerARM64.cpp:

(JSC::MacroAssemblerARM64::probe):

  • assembler/MacroAssemblerARM64.h:
  • assembler/MacroAssemblerARMv7.cpp:

(JSC::MacroAssemblerARMv7::probe):

  • assembler/MacroAssemblerARMv7.h:
  • assembler/MacroAssemblerPrinter.cpp:

(JSC::MacroAssemblerPrinter::printCallback):

  • assembler/MacroAssemblerPrinter.h:

(JSC::MacroAssemblerPrinter::print):
(JSC::MacroAssembler::print):

  • assembler/MacroAssemblerX86Common.cpp:

(JSC::MacroAssemblerX86Common::probe):

  • assembler/MacroAssemblerX86Common.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp

    r215196 r215592  
    4848
    4949#define PROBE_PROBE_FUNCTION_OFFSET (0 * PTR_SIZE)
    50 #define PROBE_ARG1_OFFSET (1 * PTR_SIZE)
    51 #define PROBE_ARG2_OFFSET (2 * PTR_SIZE)
    52 
    53 #define PROBE_FIRST_GPR_OFFSET (3 * PTR_SIZE)
     50#define PROBE_ARG_OFFSET (1 * PTR_SIZE)
     51
     52#define PROBE_FIRST_GPR_OFFSET (2 * PTR_SIZE)
    5453#define PROBE_CPU_EAX_OFFSET (PROBE_FIRST_GPR_OFFSET + (0 * PTR_SIZE))
    5554#define PROBE_CPU_ECX_OFFSET (PROBE_FIRST_GPR_OFFSET + (1 * PTR_SIZE))
     
    9190#if CPU(X86)
    9291#define PROBE_SIZE (PROBE_CPU_XMM7_OFFSET + XMM_SIZE)
     92#define PROBE_ALIGNED_SIZE (PROBE_SIZE + (2 * XMM_SIZE))
    9393#else // CPU(X86_64)
    9494#define PROBE_CPU_XMM8_OFFSET (PROBE_FIRST_XMM_OFFSET + (8 * XMM_SIZE))
     
    101101#define PROBE_CPU_XMM15_OFFSET (PROBE_FIRST_XMM_OFFSET + (15 * XMM_SIZE))
    102102#define PROBE_SIZE (PROBE_CPU_XMM15_OFFSET + XMM_SIZE)
     103#define PROBE_ALIGNED_SIZE (PROBE_SIZE + (4 * XMM_SIZE))
    103104#endif // CPU(X86_64)
    104105
     
    107108#define PROBE_OFFSETOF(x) offsetof(struct ProbeContext, x)
    108109COMPILE_ASSERT(PROBE_OFFSETOF(probeFunction) == PROBE_PROBE_FUNCTION_OFFSET, ProbeContext_probeFunction_offset_matches_ctiMasmProbeTrampoline);
    109 COMPILE_ASSERT(PROBE_OFFSETOF(arg1) == PROBE_ARG1_OFFSET, ProbeContext_arg1_offset_matches_ctiMasmProbeTrampoline);
    110 COMPILE_ASSERT(PROBE_OFFSETOF(arg2) == PROBE_ARG2_OFFSET, ProbeContext_arg2_offset_matches_ctiMasmProbeTrampoline);
     110COMPILE_ASSERT(PROBE_OFFSETOF(arg) == PROBE_ARG_OFFSET, ProbeContext_arg_offset_matches_ctiMasmProbeTrampoline);
    111111
    112112COMPILE_ASSERT(PROBE_OFFSETOF(cpu.eax) == PROBE_CPU_EAX_OFFSET, ProbeContext_cpu_eax_offset_matches_ctiMasmProbeTrampoline);
     
    132132#endif // CPU(X86_64)
    133133
     134COMPILE_ASSERT(!(PROBE_CPU_XMM0_OFFSET & 0x7), ProbeContext_cpu_xmm0_offset_should_be_8_byte_aligned);
     135
    134136COMPILE_ASSERT(PROBE_OFFSETOF(cpu.xmm0) == PROBE_CPU_XMM0_OFFSET, ProbeContext_cpu_xmm0_offset_matches_ctiMasmProbeTrampoline);
    135137COMPILE_ASSERT(PROBE_OFFSETOF(cpu.xmm1) == PROBE_CPU_XMM1_OFFSET, ProbeContext_cpu_xmm1_offset_matches_ctiMasmProbeTrampoline);
     
    153155
    154156COMPILE_ASSERT(sizeof(ProbeContext) == PROBE_SIZE, ProbeContext_size_matches_ctiMasmProbeTrampoline);
     157COMPILE_ASSERT(!(PROBE_ALIGNED_SIZE & 0x1f), ProbeContext_aligned_size_offset_should_be_32_byte_aligned);
    155158
    156159#undef PROBE_OFFSETOF
     
    171174    //     esp[2 * ptrSize]: probeFunction
    172175    //     esp[3 * ptrSize]: arg1
    173     //     esp[4 * ptrSize]: arg2
    174     //     esp[5 * ptrSize]: saved eax
    175     //     esp[6 * ptrSize]: saved esp
     176    //     esp[4 * ptrSize]: saved eax
     177    //     esp[5 * ptrSize]: saved esp
    176178
    177179    "movl %esp, %eax" "\n"
    178     "subl $" STRINGIZE_VALUE_OF(PROBE_SIZE) ", %esp" "\n"
     180    "subl $" STRINGIZE_VALUE_OF(PROBE_ALIGNED_SIZE) ", %esp" "\n"
    179181
    180182    // The X86_64 ABI specifies that the worse case stack alignment requirement
     
    198200    "movl %ecx, " STRINGIZE_VALUE_OF(PROBE_PROBE_FUNCTION_OFFSET) "(%ebp)" "\n"
    199201    "movl 3 * " STRINGIZE_VALUE_OF(PTR_SIZE) "(%eax), %ecx" "\n"
    200     "movl %ecx, " STRINGIZE_VALUE_OF(PROBE_ARG1_OFFSET) "(%ebp)" "\n"
     202    "movl %ecx, " STRINGIZE_VALUE_OF(PROBE_ARG_OFFSET) "(%ebp)" "\n"
    201203    "movl 4 * " STRINGIZE_VALUE_OF(PTR_SIZE) "(%eax), %ecx" "\n"
    202     "movl %ecx, " STRINGIZE_VALUE_OF(PROBE_ARG2_OFFSET) "(%ebp)" "\n"
     204    "movl %ecx, " STRINGIZE_VALUE_OF(PROBE_CPU_EAX_OFFSET) "(%ebp)" "\n"
    203205    "movl 5 * " STRINGIZE_VALUE_OF(PTR_SIZE) "(%eax), %ecx" "\n"
    204     "movl %ecx, " STRINGIZE_VALUE_OF(PROBE_CPU_EAX_OFFSET) "(%ebp)" "\n"
    205     "movl 6 * " STRINGIZE_VALUE_OF(PTR_SIZE) "(%eax), %ecx" "\n"
    206206    "movl %ecx, " STRINGIZE_VALUE_OF(PROBE_CPU_ESP_OFFSET) "(%ebp)" "\n"
    207207
     
    264264    // Locate the "safe area" at 2x sizeof(ProbeContext) below where the new
    265265    // rsp will be. This time we don't have to 32-byte align it because we're
    266     // not using to store any xmm regs.
     266    // not using this area to store any xmm regs.
    267267    "movl " STRINGIZE_VALUE_OF(PROBE_CPU_ESP_OFFSET) "(%ebp), %eax" "\n"
    268     "subl $2 * " STRINGIZE_VALUE_OF(PROBE_SIZE) ", %eax" "\n"
     268    "subl $2 * " STRINGIZE_VALUE_OF(PROBE_ALIGNED_SIZE) ", %eax" "\n"
    269269    "movl %eax, %esp" "\n"
    270270
     
    324324    //     esp[2 * ptrSize]: probeFunction
    325325    //     esp[3 * ptrSize]: arg1
    326     //     esp[4 * ptrSize]: arg2
    327     //     esp[5 * ptrSize]: saved rax
    328     //     esp[6 * ptrSize]: saved rsp
     326    //     esp[4 * ptrSize]: saved rax
     327    //     esp[5 * ptrSize]: saved rsp
    329328
    330329    "movq %rsp, %rax" "\n"
    331     "subq $" STRINGIZE_VALUE_OF(PROBE_SIZE) ", %rsp" "\n"
     330    "subq $" STRINGIZE_VALUE_OF(PROBE_ALIGNED_SIZE) ", %rsp" "\n"
    332331
    333332    // The X86_64 ABI specifies that the worse case stack alignment requirement
     
    351350    "movq %rcx, " STRINGIZE_VALUE_OF(PROBE_PROBE_FUNCTION_OFFSET) "(%rbp)" "\n"
    352351    "movq 3 * " STRINGIZE_VALUE_OF(PTR_SIZE) "(%rax), %rcx" "\n"
    353     "movq %rcx, " STRINGIZE_VALUE_OF(PROBE_ARG1_OFFSET) "(%rbp)" "\n"
     352    "movq %rcx, " STRINGIZE_VALUE_OF(PROBE_ARG_OFFSET) "(%rbp)" "\n"
    354353    "movq 4 * " STRINGIZE_VALUE_OF(PTR_SIZE) "(%rax), %rcx" "\n"
    355     "movq %rcx, " STRINGIZE_VALUE_OF(PROBE_ARG2_OFFSET) "(%rbp)" "\n"
     354    "movq %rcx, " STRINGIZE_VALUE_OF(PROBE_CPU_EAX_OFFSET) "(%rbp)" "\n"
    356355    "movq 5 * " STRINGIZE_VALUE_OF(PTR_SIZE) "(%rax), %rcx" "\n"
    357     "movq %rcx, " STRINGIZE_VALUE_OF(PROBE_CPU_EAX_OFFSET) "(%rbp)" "\n"
    358     "movq 6 * " STRINGIZE_VALUE_OF(PTR_SIZE) "(%rax), %rcx" "\n"
    359356    "movq %rcx, " STRINGIZE_VALUE_OF(PROBE_CPU_ESP_OFFSET) "(%rbp)" "\n"
    360357
     
    449446    // not using to store any xmm regs.
    450447    "movq " STRINGIZE_VALUE_OF(PROBE_CPU_ESP_OFFSET) "(%rbp), %rax" "\n"
    451     "subq $2 * " STRINGIZE_VALUE_OF(PROBE_SIZE) ", %rax" "\n"
     448    "subq $2 * " STRINGIZE_VALUE_OF(PROBE_ALIGNED_SIZE) ", %rax" "\n"
    452449    "movq %rax, %rsp" "\n"
    453450
     
    532529// the address of the instruction immediately following the probe.
    533530
    534 void MacroAssemblerX86Common::probe(ProbeFunction function, void* arg1, void* arg2)
     531void MacroAssemblerX86Common::probe(ProbeFunction function, void* arg)
    535532{
    536533    push(RegisterID::esp);
    537534    push(RegisterID::eax);
    538     move(TrustedImmPtr(arg2), RegisterID::eax);
    539     push(RegisterID::eax);
    540     move(TrustedImmPtr(arg1), RegisterID::eax);
     535    move(TrustedImmPtr(arg), RegisterID::eax);
    541536    push(RegisterID::eax);
    542537    move(TrustedImmPtr(reinterpret_cast<void*>(function)), RegisterID::eax);
Note: See TracChangeset for help on using the changeset viewer.