X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/2d39b0e377c0896910ee49ae70082ba665faf986..HEAD:/assembler/MacroAssemblerX86_64.h diff --git a/assembler/MacroAssemblerX86_64.h b/assembler/MacroAssemblerX86_64.h index 5f92261..920de74 100644 --- a/assembler/MacroAssemblerX86_64.h +++ b/assembler/MacroAssemblerX86_64.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2012, 2014 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2012, 2014, 2015 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,10 +30,6 @@ #include "MacroAssemblerX86Common.h" -#if USE(MASM_PROBE) -#include -#endif - #define REPTACH_OFFSET_CALL_R11 3 inline bool CAN_SIGN_EXTEND_32_64(int64_t value) { return value == (int64_t)(int32_t)value; } @@ -203,11 +199,11 @@ public: // Copy argument 5 load64(Address(X86Registers::esp, 4 * sizeof(int64_t)), scratchRegister); - store64(scratchRegister, Address(X86Registers::esp, -4 * sizeof(int64_t))); + store64(scratchRegister, Address(X86Registers::esp, -4 * static_cast(sizeof(int64_t)))); // Copy argument 6 load64(Address(X86Registers::esp, 5 * sizeof(int64_t)), scratchRegister); - store64(scratchRegister, Address(X86Registers::esp, -3 * sizeof(int64_t))); + store64(scratchRegister, Address(X86Registers::esp, -3 * static_cast(sizeof(int64_t)))); // We also need to allocate the shadow space on the stack for the 4 parameter registers. // Also, we should allocate 16 bytes for the frame pointer, and return address (not populated). @@ -295,7 +291,10 @@ public: void add64(TrustedImm32 imm, Address address) { - m_assembler.addq_im(imm.m_value, address.offset, address.base); + if (imm.m_value == 1) + m_assembler.incq_m(address.offset, address.base); + else + m_assembler.addq_im(imm.m_value, address.offset, address.base); } void add64(TrustedImm32 imm, AbsoluteAddress address) @@ -335,6 +334,11 @@ public: m_assembler.sarq_i8r(imm.m_value, dest); } + void urshift64(TrustedImm32 imm, RegisterID dest) + { + m_assembler.shrq_i8r(imm.m_value, dest); + } + void mul64(RegisterID src, RegisterID dest) { m_assembler.imulq_rr(src, dest); @@ -780,7 +784,6 @@ public: } static bool supportsFloatingPoint() { return true; } - // See comment on MacroAssemblerARMv7::supportsFloatingPointTruncate() static bool supportsFloatingPointTruncate() { return true; } static bool supportsFloatingPointSqrt() { return true; } static bool supportsFloatingPointAbs() { return true; } @@ -841,26 +844,6 @@ public: X86Assembler::revertJumpTo_movq_i64r(instructionStart.executableAddress(), reinterpret_cast(initialValue), scratchRegister); } -#if USE(MASM_PROBE) - // This function emits code to preserve the CPUState (e.g. registers), - // call a user supplied probe function, and restore the CPUState before - // continuing with other JIT generated code. - // - // The user supplied probe function will be called with a single pointer to - // a ProbeContext struct (defined above) which contains, among other things, - // the preserved CPUState. This allows the user probe function to inspect - // the CPUState at that point in the JIT generated code. - // - // If the user probe function alters the register values in the ProbeContext, - // the altered values will be loaded into the CPU registers when the probe - // returns. - // - // The ProbeContext is stack allocated and is only valid for the duration - // of the call to the user probe function. - - void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0); -#endif // USE(MASM_PROBE) - private: friend class LinkBuffer; friend class RepatchBuffer; @@ -882,69 +865,8 @@ private: { X86Assembler::repatchPointer(call.dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11).dataLocation(), destination.executableAddress()); } - -#if USE(MASM_PROBE) - inline TrustedImm64 trustedImm64FromPtr(void* ptr) - { - return TrustedImm64(TrustedImmPtr(ptr)); - } - - inline TrustedImm64 trustedImm64FromPtr(ProbeFunction function) - { - return TrustedImm64(TrustedImmPtr(reinterpret_cast(function))); - } - - inline TrustedImm64 trustedImm64FromPtr(void (*function)()) - { - return TrustedImm64(TrustedImmPtr(reinterpret_cast(function))); - } -#endif }; -#if USE(MASM_PROBE) - -extern "C" void ctiMasmProbeTrampoline(); - -// 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 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. -// -// Specifcally, 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. - -inline void MacroAssemblerX86_64::probe(MacroAssemblerX86_64::ProbeFunction function, void* arg1, void* arg2) -{ - push(RegisterID::esp); - push(RegisterID::eax); - move(trustedImm64FromPtr(arg2), RegisterID::eax); - push(RegisterID::eax); - move(trustedImm64FromPtr(arg1), RegisterID::eax); - push(RegisterID::eax); - move(trustedImm64FromPtr(function), RegisterID::eax); - push(RegisterID::eax); - move(trustedImm64FromPtr(ctiMasmProbeTrampoline), RegisterID::eax); - call(RegisterID::eax); -} -#endif // USE(MASM_PROBE) - } // namespace JSC #endif // ENABLE(ASSEMBLER)