diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp | |
parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp')
-rw-r--r-- | Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp | 123 |
1 files changed, 28 insertions, 95 deletions
diff --git a/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp b/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp index 0108ef4c0..0fab05fb5 100644 --- a/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp +++ b/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014 Apple Inc. All rights reserved. + * Copyright (C) 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,120 +30,53 @@ namespace JSC { -#if ENABLE(MASM_PROBE) +#if USE(MASM_PROBE) -#define INDENT printIndent(indentation) - -void MacroAssemblerX86Common::printCPURegisters(MacroAssemblerX86Common::CPUState& cpu, int indentation) +void MacroAssemblerX86Common::ProbeContext::dumpCPURegisters(const char* indentation) { #if CPU(X86) - #define PRINT_GPREGISTER(_type, _regName) { \ + #define DUMP_GPREGISTER(_type, _regName) { \ int32_t value = reinterpret_cast<int32_t>(cpu._regName); \ - INDENT, dataLogF("%6s: 0x%08x %d\n", #_regName, value, value) ; \ + dataLogF("%s %6s: 0x%08x %d\n", indentation, #_regName, value, value) ; \ } #elif CPU(X86_64) - #define PRINT_GPREGISTER(_type, _regName) { \ + #define DUMP_GPREGISTER(_type, _regName) { \ int64_t value = reinterpret_cast<int64_t>(cpu._regName); \ - INDENT, dataLogF("%6s: 0x%016llx %lld\n", #_regName, value, value) ; \ + dataLogF("%s %6s: 0x%016llx %lld\n", indentation, #_regName, value, value) ; \ } #endif - FOR_EACH_CPU_GPREGISTER(PRINT_GPREGISTER) - FOR_EACH_CPU_SPECIAL_REGISTER(PRINT_GPREGISTER) - #undef PRINT_GPREGISTER + FOR_EACH_CPU_GPREGISTER(DUMP_GPREGISTER) + FOR_EACH_CPU_SPECIAL_REGISTER(DUMP_GPREGISTER) + #undef DUMP_GPREGISTER - #define PRINT_FPREGISTER(_type, _regName) { \ - uint64_t* u = reinterpret_cast<uint64_t*>(&cpu._regName); \ + #define DUMP_FPREGISTER(_type, _regName) { \ + uint32_t* u = reinterpret_cast<uint32_t*>(&cpu._regName); \ double* d = reinterpret_cast<double*>(&cpu._regName); \ - INDENT, dataLogF("%6s: 0x%016llx %.13g\n", #_regName, *u, *d); \ + dataLogF("%s %6s: 0x%08x%08x 0x%08x%08x %12g %12g\n", \ + indentation, #_regName, u[3], u[2], u[1], u[0], d[1], d[0]); \ } - FOR_EACH_CPU_FPREGISTER(PRINT_FPREGISTER) - #undef PRINT_FPREGISTER + FOR_EACH_CPU_FPREGISTER(DUMP_FPREGISTER) + #undef DUMP_FPREGISTER } -#undef INDENT - -void MacroAssemblerX86Common::printRegister(MacroAssemblerX86Common::CPUState& cpu, RegisterID regID) +void MacroAssemblerX86Common::ProbeContext::dump(const char* indentation) { - const char* name = CPUState::registerName(regID); - union { - void* voidPtr; - intptr_t intptrValue; - } u; - u.voidPtr = cpu.registerValue(regID); - dataLogF("%s:<%p %ld>", name, u.voidPtr, u.intptrValue); -} + if (!indentation) + indentation = ""; -void MacroAssemblerX86Common::printRegister(MacroAssemblerX86Common::CPUState& cpu, FPRegisterID regID) -{ - const char* name = CPUState::registerName(regID); - union { - double doubleValue; - uint64_t uint64Value; - } u; - u.doubleValue = cpu.registerValue(regID); - dataLogF("%s:<0x%016llx %.13g>", name, u.uint64Value, u.doubleValue); -} + dataLogF("%sProbeContext %p {\n", indentation, this); + dataLogF("%s probeFunction: %p\n", indentation, probeFunction); + dataLogF("%s arg1: %p %llu\n", indentation, arg1, reinterpret_cast<int64_t>(arg1)); + dataLogF("%s arg2: %p %llu\n", indentation, arg2, reinterpret_cast<int64_t>(arg2)); + dataLogF("%s cpu: {\n", indentation); -extern "C" void ctiMasmProbeTrampoline(); + dumpCPURegisters(indentation); -// What code is emitted for the probe? -// ================================== -// We want to keep the size of the emitted probe invocation code as compact as -// possible to minimize the perturbation to the JIT generated code. However, -// we also need to preserve the CPU registers and set up the ProbeContext to be -// passed to the user probe function. -// -// Hence, we do only the minimum here to preserve a scratch register (i.e. rax -// in this case) and the stack pointer (i.e. rsp), and pass the probe arguments. -// We'll let the ctiMasmProbeTrampoline handle the rest of the probe invocation -// work i.e. saving the CPUState (and setting up the ProbeContext), calling the -// user probe function, and restoring the CPUState before returning to JIT -// generated code. -// -// What registers need to be saved? -// =============================== -// The registers are saved for 2 reasons: -// 1. To preserve their state in the JITted code. This means that all registers -// that are not callee saved needs to be saved. We also need to save the -// condition code registers because the probe can be inserted between a test -// and a branch. -// 2. To allow the probe to inspect the values of the registers for debugging -// purposes. This means all registers need to be saved. -// -// In summary, save everything. But for reasons stated above, we should do the -// minimum here and let ctiMasmProbeTrampoline do the heavy lifting to save the -// full set. -// -// What values are in the saved registers? -// ====================================== -// Conceptually, the saved registers should contain values as if the probe -// is not present in the JIT generated code. Hence, they should contain values -// that are expected at the start of the instruction immediately following the -// probe. -// -// Specifically, the saved stack pointer register will point to the stack -// position before we push the ProbeContext frame. The saved rip will point to -// the address of the instruction immediately following the probe. - -void MacroAssemblerX86Common::probe(MacroAssemblerX86Common::ProbeFunction function, void* arg1, void* arg2) -{ - push(RegisterID::esp); - push(RegisterID::eax); - move(TrustedImmPtr(arg2), RegisterID::eax); - push(RegisterID::eax); - move(TrustedImmPtr(arg1), RegisterID::eax); - push(RegisterID::eax); - move(TrustedImmPtr(reinterpret_cast<void*>(function)), RegisterID::eax); - push(RegisterID::eax); - move(TrustedImmPtr(reinterpret_cast<void*>(ctiMasmProbeTrampoline)), RegisterID::eax); - call(RegisterID::eax); + dataLogF("%s }\n", indentation); + dataLogF("%s}\n", indentation); } -#endif // ENABLE(MASM_PROBE) - -#if CPU(X86) && !OS(MAC_OS_X) -MacroAssemblerX86Common::SSE2CheckState MacroAssemblerX86Common::s_sse2CheckState = NotCheckedSSE2; -#endif +#endif // USE(MASM_PROBE) } // namespace JSC |