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:
Location:
trunk/Source/JavaScriptCore/assembler
Files:
9 edited
1 copied

Legend:

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

    r149601 r153197  
    5151            r10,
    5252            r11,
    53             r12, S1 = r12,
     53            r12, ip = r12, S1 = r12,
    5454            r13, sp = r13,
    5555            r14, lr = r14,
     
    9292        } FPRegisterID;
    9393
     94#if USE(MASM_PROBE)
     95    #define FOR_EACH_CPU_REGISTER(V) \
     96        FOR_EACH_CPU_GPREGISTER(V) \
     97        FOR_EACH_CPU_SPECIAL_REGISTER(V) \
     98        FOR_EACH_CPU_FPREGISTER(V)
     99
     100    #define FOR_EACH_CPU_GPREGISTER(V) \
     101        V(void*, r0) \
     102        V(void*, r1) \
     103        V(void*, r2) \
     104        V(void*, r3) \
     105        V(void*, r4) \
     106        V(void*, r5) \
     107        V(void*, r6) \
     108        V(void*, r7) \
     109        V(void*, r8) \
     110        V(void*, r9) \
     111        V(void*, r10) \
     112        V(void*, r11) \
     113        V(void*, ip) \
     114        V(void*, sp) \
     115        V(void*, lr) \
     116        V(void*, pc)
     117
     118    #define FOR_EACH_CPU_SPECIAL_REGISTER(V) \
     119        V(void*, apsr) \
     120        V(void*, fpscr) \
     121
     122    #define FOR_EACH_CPU_FPREGISTER(V) \
     123        V(double, d0) \
     124        V(double, d1) \
     125        V(double, d2) \
     126        V(double, d3) \
     127        V(double, d4) \
     128        V(double, d5) \
     129        V(double, d6) \
     130        V(double, d7) \
     131        V(double, d8) \
     132        V(double, d9) \
     133        V(double, d10) \
     134        V(double, d11) \
     135        V(double, d12) \
     136        V(double, d13) \
     137        V(double, d14) \
     138        V(double, d15)
     139#endif // USE(MASM_PROBE)
    94140    } // namespace ARMRegisters
    95141
  • trunk/Source/JavaScriptCore/assembler/ARMv7Assembler.h

    r149395 r153197  
    173173        return (FPDoubleRegisterID)(reg >> 1);
    174174    }
     175
     176#if USE(MASM_PROBE)
     177    #define FOR_EACH_CPU_REGISTER(V) \
     178        FOR_EACH_CPU_GPREGISTER(V) \
     179        FOR_EACH_CPU_SPECIAL_REGISTER(V) \
     180        FOR_EACH_CPU_FPREGISTER(V)
     181
     182    #define FOR_EACH_CPU_GPREGISTER(V) \
     183        V(void*, r0) \
     184        V(void*, r1) \
     185        V(void*, r2) \
     186        V(void*, r3) \
     187        V(void*, r4) \
     188        V(void*, r5) \
     189        V(void*, r6) \
     190        V(void*, r7) \
     191        V(void*, r8) \
     192        V(void*, r9) \
     193        V(void*, r10) \
     194        V(void*, r11) \
     195        V(void*, ip) \
     196        V(void*, sp) \
     197        V(void*, lr) \
     198        V(void*, pc)
     199
     200    #define FOR_EACH_CPU_SPECIAL_REGISTER(V) \
     201        V(void*, apsr) \
     202        V(void*, fpscr) \
     203
     204    #define FOR_EACH_CPU_FPREGISTER(V) \
     205        V(double, d0) \
     206        V(double, d1) \
     207        V(double, d2) \
     208        V(double, d3) \
     209        V(double, d4) \
     210        V(double, d5) \
     211        V(double, d6) \
     212        V(double, d7) \
     213        V(double, d8) \
     214        V(double, d9) \
     215        V(double, d10) \
     216        V(double, d11) \
     217        V(double, d12) \
     218        V(double, d13) \
     219        V(double, d14) \
     220        V(double, d15) \
     221        FOR_EACH_CPU_FPREGISTER_EXTENSION(V)
     222
     223#if CPU(APPLE_ARMV7S)
     224    #define FOR_EACH_CPU_FPREGISTER_EXTENSION(V) \
     225        V(double, d16) \
     226        V(double, d17) \
     227        V(double, d18) \
     228        V(double, d19) \
     229        V(double, d20) \
     230        V(double, d21) \
     231        V(double, d22) \
     232        V(double, d23) \
     233        V(double, d24) \
     234        V(double, d25) \
     235        V(double, d26) \
     236        V(double, d27) \
     237        V(double, d28) \
     238        V(double, d29) \
     239        V(double, d30) \
     240        V(double, d31)
     241#else
     242    #define FOR_EACH_CPU_FPREGISTER_EXTENSION(V) // Nothing to add.
     243#endif // CPU(APPLE_ARMV7S)
     244
     245#endif // USE(MASM_PROBE)
    175246}
    176247
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM.cpp

    r125541 r153197  
    11/*
     2 * Copyright (C) 2013 Apple Inc.
    23 * Copyright (C) 2009 University of Szeged
    34 * All rights reserved.
     
    3132#include "MacroAssemblerARM.h"
    3233
     34#if USE(MASM_PROBE)
     35#include <wtf/StdLibExtras.h>
     36#endif
     37
    3338#if OS(LINUX)
    3439#include <sys/types.h>
     
    5661        close(fd);
    5762    }
    58 #endif
     63#endif // OS(LINUX)
    5964
    6065#if (COMPILER(RVCT) && defined(__TARGET_FPU_VFP)) || (COMPILER(GCC) && defined(__VFP_FP__))
     
    9398    m_assembler.orr(dest, dest, m_assembler.lsl(ARMRegisters::S0, 16));
    9499}
    95 #endif
     100#endif // CPU(ARMV5_OR_LOWER)
     101
     102#if USE(MASM_PROBE)
     103
     104void MacroAssemblerARM::ProbeContext::dumpCPURegisters(const char* indentation)
     105{
     106    #define DUMP_GPREGISTER(_type, _regName) { \
     107        int32_t value = reinterpret_cast<int32_t>(cpu._regName); \
     108        dataLogF("%s    %5s: 0x%08x   %d\n", indentation, #_regName, value, value) ; \
     109    }
     110    FOR_EACH_CPU_GPREGISTER(DUMP_GPREGISTER)
     111    FOR_EACH_CPU_SPECIAL_REGISTER(DUMP_GPREGISTER)
     112    #undef DUMP_GPREGISTER
     113
     114    #define DUMP_FPREGISTER(_type, _regName) { \
     115        uint32_t* u = reinterpret_cast<uint32_t*>(&cpu._regName); \
     116        double* d = reinterpret_cast<double*>(&cpu._regName); \
     117        dataLogF("%s    %5s: 0x %08x %08x   %12g\n", \
     118            indentation, #_regName, u[1], u[0], d[0]); \
     119    }
     120    FOR_EACH_CPU_FPREGISTER(DUMP_FPREGISTER)
     121    #undef DUMP_FPREGISTER
     122}
     123
     124void MacroAssemblerARM::ProbeContext::dump(const char* indentation)
     125{
     126    if (!indentation)
     127        indentation = "";
     128
     129    dataLogF("%sProbeContext %p {\n", indentation, this);
     130    dataLogF("%s  probeFunction: %p\n", indentation, probeFunction);
     131    dataLogF("%s  arg1: %p %llu\n", indentation, arg1, reinterpret_cast<int64_t>(arg1));
     132    dataLogF("%s  arg2: %p %llu\n", indentation, arg2, reinterpret_cast<int64_t>(arg2));
     133    dataLogF("%s  jitStackFrame: %p\n", indentation, jitStackFrame);
     134    dataLogF("%s  cpu: {\n", indentation);
     135
     136    dumpCPURegisters(indentation);
     137
     138    dataLogF("%s  }\n", indentation);
     139    dataLogF("%s}\n", indentation);
     140}
     141
     142
     143extern "C" void ctiMasmProbeTrampoline();
     144
     145// For details on "What code is emitted for the probe?" and "What values are in
     146// the saved registers?", see comment for MacroAssemblerX86::probe() in
     147// MacroAssemblerX86_64.h.
     148
     149void MacroAssemblerARM::probe(MacroAssemblerARM::ProbeFunction function, void* arg1, void* arg2)
     150{
     151    push(RegisterID::sp);
     152    push(RegisterID::lr);
     153    push(RegisterID::ip);
     154    push(RegisterID::S0);
     155    // The following uses RegisterID::S0. So, they must come after we push S0 above.
     156    push(trustedImm32FromPtr(arg2));
     157    push(trustedImm32FromPtr(arg1));
     158    push(trustedImm32FromPtr(function));
     159
     160    move(trustedImm32FromPtr(ctiMasmProbeTrampoline), RegisterID::S0);
     161    m_assembler.blx(RegisterID::S0);
    96162
    97163}
     164#endif // USE(MASM_PROBE)
     165
     166} // namespace JSC
    98167
    99168#endif // ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM.h

    r150748 r153197  
    11/*
    2  * Copyright (C) 2008 Apple Inc.
     2 * Copyright (C) 2008, 2013 Apple Inc.
    33 * Copyright (C) 2009, 2010 University of Szeged
    44 * All rights reserved.
     
    3636namespace JSC {
    3737
     38struct JITStackFrame;
     39
    3840class MacroAssemblerARM : public AbstractMacroAssembler<ARMAssembler> {
    3941    static const int DoubleConditionMask = 0x0f;
     
    13291331    }
    13301332
     1333#if USE(MASM_PROBE)
     1334    struct CPUState {
     1335        #define DECLARE_REGISTER(_type, _regName) \
     1336            _type _regName;
     1337        FOR_EACH_CPU_REGISTER(DECLARE_REGISTER)
     1338        #undef DECLARE_REGISTER
     1339    };
     1340
     1341    struct ProbeContext;
     1342    typedef void (*ProbeFunction)(struct ProbeContext*);
     1343
     1344    struct ProbeContext {
     1345        ProbeFunction probeFunction;
     1346        void* arg1;
     1347        void* arg2;
     1348        JITStackFrame* jitStackFrame;
     1349        CPUState cpu;
     1350
     1351        void dump(const char* indentation = 0);
     1352    private:
     1353        void dumpCPURegisters(const char* indentation);
     1354    };
     1355
     1356    // For details about probe(), see comment in MacroAssemblerX86_64.h.
     1357    void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0);
     1358#endif // USE(MASM_PROBE)
     1359
    13311360protected:
    13321361    ARMAssembler::Condition ARMCondition(RelationalCondition cond)
     
    13841413    }
    13851414
     1415#if USE(MASM_PROBE)
     1416    inline TrustedImm32 trustedImm32FromPtr(void* ptr)
     1417    {
     1418        return TrustedImm32(TrustedImmPtr(ptr));
     1419    }
     1420
     1421    inline TrustedImm32 trustedImm32FromPtr(ProbeFunction function)
     1422    {
     1423        return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function)));
     1424    }
     1425
     1426    inline TrustedImm32 trustedImm32FromPtr(void (*function)())
     1427    {
     1428        return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function)));
     1429    }
     1430#endif
     1431
    13861432    static const bool s_isVFPPresent;
    13871433};
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.cpp

    r153196 r153197  
    2525
    2626#include "config.h"
    27 #include "MacroAssemblerX86Common.h"
     27
     28#if ENABLE(ASSEMBLER) && CPU(ARM_THUMB2)
     29#include "MacroAssemblerARMv7.h"
     30
     31#if USE(MASM_PROBE)
     32#include <wtf/StdLibExtras.h>
     33#endif
    2834
    2935namespace JSC {
     
    3137#if USE(MASM_PROBE)
    3238
    33 void MacroAssemblerX86Common::ProbeContext::dumpCPURegisters(const char* indentation)
     39void MacroAssemblerARMv7::ProbeContext::dumpCPURegisters(const char* indentation)
    3440{
    35 #if CPU(X86)
    3641    #define DUMP_GPREGISTER(_type, _regName) { \
    3742        int32_t value = reinterpret_cast<int32_t>(cpu._regName); \
    38         dataLogF("%s    %4s: 0x%08x   %d\n", indentation, #_regName, value, value) ; \
     43        dataLogF("%s    %5s: 0x%08x   %d\n", indentation, #_regName, value, value) ; \
    3944    }
    40 #elif CPU(X86_64)
    41     #define DUMP_GPREGISTER(_type, _regName) { \
    42         int64_t value = reinterpret_cast<int64_t>(cpu._regName); \
    43         dataLogF("%s    %4s: 0x%016llx   %lld\n", indentation, #_regName, value, value) ; \
    44     }
    45 #endif
    4645    FOR_EACH_CPU_GPREGISTER(DUMP_GPREGISTER)
     46    FOR_EACH_CPU_SPECIAL_REGISTER(DUMP_GPREGISTER)
    4747    #undef DUMP_GPREGISTER
    4848
     
    5050        uint32_t* u = reinterpret_cast<uint32_t*>(&cpu._regName); \
    5151        double* d = reinterpret_cast<double*>(&cpu._regName); \
    52         dataLogF("%s    %s: 0x%08x%08x 0x%08x%08x   %12g %12g\n", \
    53             indentation, #_regName, u[3], u[2], u[1], u[0], d[1], d[0]); \
     52        dataLogF("%s    %5s: 0x %08x %08x  %12g\n", \
     53            indentation, #_regName, u[1], u[0], d[0]); \
    5454    }
    5555    FOR_EACH_CPU_FPREGISTER(DUMP_FPREGISTER)
     
    5757}
    5858
    59 void MacroAssemblerX86Common::ProbeContext::dump(const char* indentation)
     59void MacroAssemblerARMv7::ProbeContext::dump(const char* indentation)
    6060{
    6161    if (!indentation)
     
    7575}
    7676
     77
     78extern "C" void ctiMasmProbeTrampoline();
     79
     80// For details on "What code is emitted for the probe?" and "What values are in
     81// the saved registers?", see comment for MacroAssemblerX86::probe() in
     82// MacroAssemblerX86_64.h.
     83
     84void MacroAssemblerARMv7::probe(MacroAssemblerARMv7::ProbeFunction function, void* arg1, void* arg2)
     85{
     86    push(RegisterID::sp);
     87    push(RegisterID::lr);
     88    push(RegisterID::ip);
     89    push(RegisterID::r0);
     90    // The following uses RegisterID::ip. So, they must come after we push ip above.
     91    push(trustedImm32FromPtr(arg2));
     92    push(trustedImm32FromPtr(arg1));
     93    push(trustedImm32FromPtr(function));
     94
     95    move(trustedImm32FromPtr(ctiMasmProbeTrampoline), RegisterID::ip);
     96    m_assembler.blx(RegisterID::ip);
     97}
    7798#endif // USE(MASM_PROBE)
    7899
    79100} // namespace JSC
     101
     102#endif // ENABLE(ASSEMBLER)
     103
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r149395 r153197  
    3535namespace JSC {
    3636
     37struct JITStackFrame;
     38
    3739class MacroAssemblerARMv7 : public AbstractMacroAssembler<ARMv7Assembler> {
    3840    // FIXME: switch dataTempRegister & addressTempRegister, or possibly use r7?
     
    17971799    }
    17981800
     1801#if USE(MASM_PROBE)
     1802    struct CPUState {
     1803        #define DECLARE_REGISTER(_type, _regName) \
     1804            _type _regName;
     1805        FOR_EACH_CPU_REGISTER(DECLARE_REGISTER)
     1806        #undef DECLARE_REGISTER
     1807    };
     1808
     1809    struct ProbeContext;
     1810    typedef void (*ProbeFunction)(struct ProbeContext*);
     1811
     1812    struct ProbeContext {
     1813        ProbeFunction probeFunction;
     1814        void* arg1;
     1815        void* arg2;
     1816        JITStackFrame* jitStackFrame;
     1817        CPUState cpu;
     1818
     1819        void dump(const char* indentation = 0);
     1820    private:
     1821        void dumpCPURegisters(const char* indentation);
     1822    };
     1823
     1824    // For details about probe(), see comment in MacroAssemblerX86_64.h.
     1825    void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0);
     1826#endif // USE(MASM_PROBE)
     1827
    17991828protected:
    18001829    ALWAYS_INLINE Jump jump()
     
    19071936    }
    19081937
     1938#if USE(MASM_PROBE)
     1939    inline TrustedImm32 trustedImm32FromPtr(void* ptr)
     1940    {
     1941        return TrustedImm32(TrustedImmPtr(ptr));
     1942    }
     1943
     1944    inline TrustedImm32 trustedImm32FromPtr(ProbeFunction function)
     1945    {
     1946        return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function)));
     1947    }
     1948
     1949    inline TrustedImm32 trustedImm32FromPtr(void (*function)())
     1950    {
     1951        return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function)));
     1952    }
     1953#endif
     1954
    19091955    bool m_makeJumpPatchable;
    19101956};
  • 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)
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp

    r153162 r153197  
    2525
    2626#include "config.h"
     27
     28#if ENABLE(ASSEMBLER) && (CPU(X86) || CPU(X86_64))
    2729#include "MacroAssemblerX86Common.h"
    2830
     
    3638    #define DUMP_GPREGISTER(_type, _regName) { \
    3739        int32_t value = reinterpret_cast<int32_t>(cpu._regName); \
    38         dataLogF("%s    %4s: 0x%08x   %d\n", indentation, #_regName, value, value) ; \
     40        dataLogF("%s    %6s: 0x%08x   %d\n", indentation, #_regName, value, value) ; \
    3941    }
    4042#elif CPU(X86_64)
    4143    #define DUMP_GPREGISTER(_type, _regName) { \
    4244        int64_t value = reinterpret_cast<int64_t>(cpu._regName); \
    43         dataLogF("%s    %4s: 0x%016llx   %lld\n", indentation, #_regName, value, value) ; \
     45        dataLogF("%s    %6s: 0x%016llx   %lld\n", indentation, #_regName, value, value) ; \
    4446    }
    4547#endif
    4648    FOR_EACH_CPU_GPREGISTER(DUMP_GPREGISTER)
     49    FOR_EACH_CPU_SPECIAL_REGISTER(DUMP_GPREGISTER)
    4750    #undef DUMP_GPREGISTER
    4851
     
    5053        uint32_t* u = reinterpret_cast<uint32_t*>(&cpu._regName); \
    5154        double* d = reinterpret_cast<double*>(&cpu._regName); \
    52         dataLogF("%s    %s: 0x%08x%08x 0x%08x%08x   %12g %12g\n", \
     55        dataLogF("%s    %6s: 0x%08x%08x 0x%08x%08x   %12g %12g\n", \
    5356            indentation, #_regName, u[3], u[2], u[1], u[0], d[1], d[0]); \
    5457    }
     
    7881
    7982} // namespace JSC
     83
     84#endif // ENABLE(ASSEMBLER) && (CPU(X86) || CPU(X86_64))
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h

    r153162 r153197  
    688688// passed to the user probe function.
    689689//
    690 // Hence, we do only the minimum here to preserve the rax (to be used as a
    691 // scratch register) and rsp registers, and pass the probe arguments. We'll let
    692 // the ctiMasmProbeTrampoline handle the rest of the probe invocation work
    693 // i.e. saving the CPUState (and setting up the ProbeContext), calling the user
    694 // probe function, and restoring the CPUState before returning to JIT generated
    695 // code.
     690// Hence, we do only the minimum here to preserve a scratch register (i.e. rax
     691// in this case) and the stack pointer (i.e. rsp), and pass the probe arguments.
     692// We'll let the ctiMasmProbeTrampoline handle the rest of the probe invocation
     693// work i.e. saving the CPUState (and setting up the ProbeContext), calling the
     694// user probe function, and restoring the CPUState before returning to JIT
     695// generated code.
    696696//
    697697// What values are in the saved registers?
     
    702702// probe.
    703703//
    704 // Specifcally, the saved rsp will point to the stack position before we
    705 // push the ProbeContext frame. The saved rip will point to the address of
    706 // the instruction immediately following the probe.
     704// Specifcally, the saved stack pointer register will point to the stack
     705// position before we push the ProbeContext frame. The saved rip will point to
     706// the address of the instruction immediately following the probe.
    707707
    708708inline void MacroAssemblerX86_64::probe(MacroAssemblerX86_64::ProbeFunction function, void* arg1, void* arg2)
    709709{
    710     RegisterID esp = RegisterID::esp;
    711     #define probeContextField(field) Address(esp, offsetof(ProbeContext, field))
    712 
    713     // The X86_64 ABI specifies that the worse case stack alignment requirement
    714     // is 32 bytes.
    715     const int probeFrameSize = WTF::roundUpToMultipleOf(32, sizeof(ProbeContext));
    716     sub64(TrustedImm32(probeFrameSize), esp);
    717 
    718     store64(RegisterID::eax, probeContextField(cpu.eax));
    719 
    720     move(TrustedImm32(probeFrameSize), RegisterID::eax);
    721     add64(esp, RegisterID::eax);
    722     store64(RegisterID::eax, probeContextField(cpu.esp));
    723 
    724     store64(trustedImm64FromPtr(function), probeContextField(probeFunction));
    725     store64(trustedImm64FromPtr(arg1), probeContextField(arg1));
    726     store64(trustedImm64FromPtr(arg2), probeContextField(arg2));
    727 
     710    push(RegisterID::esp);
     711    push(RegisterID::eax);
     712    move(trustedImm64FromPtr(arg2), RegisterID::eax);
     713    push(RegisterID::eax);
     714    move(trustedImm64FromPtr(arg1), RegisterID::eax);
     715    push(RegisterID::eax);
     716    move(trustedImm64FromPtr(function), RegisterID::eax);
     717    push(RegisterID::eax);
    728718    move(trustedImm64FromPtr(ctiMasmProbeTrampoline), RegisterID::eax);
    729719    call(RegisterID::eax);
    730 
    731     #undef probeContextField
    732720}
    733721#endif // USE(MASM_PROBE)
  • trunk/Source/JavaScriptCore/assembler/X86Assembler.h

    r153162 r153197  
    8080    #define FOR_EACH_CPU_REGISTER(V) \
    8181        FOR_EACH_CPU_GPREGISTER(V) \
     82        FOR_EACH_CPU_SPECIAL_REGISTER(V) \
    8283        FOR_EACH_CPU_FPREGISTER(V)
    8384
    8485    #define FOR_EACH_CPU_GPREGISTER(V) \
    8586        V(void*, eax) \
     87        V(void*, ebx) \
    8688        V(void*, ecx) \
    8789        V(void*, edx) \
    88         V(void*, ebx) \
    89         V(void*, esp) \
    90         V(void*, ebp) \
    9190        V(void*, esi) \
    9291        V(void*, edi) \
    93         FOR_EACH_X86_64_CPU_GPREGISTER(V) \
    94         V(void*, eip)
     92        V(void*, ebp) \
     93        V(void*, esp) \
     94        FOR_EACH_X86_64_CPU_GPREGISTER(V)
     95
     96    #define FOR_EACH_CPU_SPECIAL_REGISTER(V) \
     97        V(void*, eip) \
     98        V(void*, eflags) \
    9599
    96100    #define FOR_EACH_CPU_FPREGISTER(V) \
Note: See TracChangeset for help on using the changeset viewer.