X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/4e4e5a6f2694187498445a6ac6f1634ce8141119..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/assembler/RepatchBuffer.h diff --git a/assembler/RepatchBuffer.h b/assembler/RepatchBuffer.h index 72cf6b2..241ce14 100644 --- a/assembler/RepatchBuffer.h +++ b/assembler/RepatchBuffer.h @@ -26,8 +26,9 @@ #ifndef RepatchBuffer_h #define RepatchBuffer_h -#if ENABLE(ASSEMBLER) +#if ENABLE(JIT) +#include "CodeBlock.h" #include #include @@ -44,18 +45,25 @@ class RepatchBuffer { public: RepatchBuffer(CodeBlock* codeBlock) + : m_codeBlock(codeBlock) { - JITCode& code = codeBlock->getJITCode(); - m_start = code.start(); - m_size = code.size(); +#if ENABLE(ASSEMBLER_WX_EXCLUSIVE) + RefPtr code = codeBlock->jitCode(); + m_start = code->start(); + m_size = code->size(); ExecutableAllocator::makeWritable(m_start, m_size); +#endif } ~RepatchBuffer() { +#if ENABLE(ASSEMBLER_WX_EXCLUSIVE) ExecutableAllocator::makeExecutable(m_start, m_size); +#endif } + + CodeBlock* codeBlock() const { return m_codeBlock; } void relink(CodeLocationJump jump, CodeLocationLabel destination) { @@ -87,14 +95,14 @@ public: MacroAssembler::repatchInt32(dataLabel32, value); } - void repatch(CodeLocationDataLabelPtr dataLabelPtr, void* value) + void repatch(CodeLocationDataLabelCompact dataLabelCompact, int32_t value) { - MacroAssembler::repatchPointer(dataLabelPtr, value); + MacroAssembler::repatchCompact(dataLabelCompact, value); } - void repatchLoadPtrToLEA(CodeLocationInstruction instruction) + void repatch(CodeLocationDataLabelPtr dataLabelPtr, void* value) { - MacroAssembler::repatchLoadPtrToLEA(instruction); + MacroAssembler::repatchPointer(dataLabelPtr, value); } void relinkCallerToTrampoline(ReturnAddressPtr returnAddress, CodeLocationLabel label) @@ -121,10 +129,69 @@ public: { relinkNearCallerToTrampoline(returnAddress, CodeLocationLabel(newCalleeFunction)); } + + void replaceWithLoad(CodeLocationConvertibleLoad label) + { + MacroAssembler::replaceWithLoad(label); + } + + void replaceWithAddressComputation(CodeLocationConvertibleLoad label) + { + MacroAssembler::replaceWithAddressComputation(label); + } + + void setLoadInstructionIsActive(CodeLocationConvertibleLoad label, bool isActive) + { + if (isActive) + replaceWithLoad(label); + else + replaceWithAddressComputation(label); + } + + static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label) + { + return MacroAssembler::startOfBranchPtrWithPatchOnRegister(label); + } + + static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label) + { + return MacroAssembler::startOfPatchableBranchPtrWithPatchOnAddress(label); + } + + static CodeLocationLabel startOfPatchableBranch32WithPatchOnAddress(CodeLocationDataLabel32 label) + { + return MacroAssembler::startOfPatchableBranch32WithPatchOnAddress(label); + } + + void replaceWithJump(CodeLocationLabel instructionStart, CodeLocationLabel destination) + { + MacroAssembler::replaceWithJump(instructionStart, destination); + } + + // This is a *bit* of a silly API, since we currently always also repatch the + // immediate after calling this. But I'm fine with that, since this just feels + // less yucky. + void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, MacroAssembler::RegisterID reg, void* value) + { + MacroAssembler::revertJumpReplacementToBranchPtrWithPatch(instructionStart, reg, value); + } + + void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, MacroAssembler::Address address, void* value) + { + MacroAssembler::revertJumpReplacementToPatchableBranchPtrWithPatch(instructionStart, address, value); + } + + void revertJumpReplacementToPatchableBranch32WithPatch(CodeLocationLabel instructionStart, MacroAssembler::Address address, int32_t value) + { + MacroAssembler::revertJumpReplacementToPatchableBranch32WithPatch(instructionStart, address, value); + } private: + CodeBlock* m_codeBlock; +#if ENABLE(ASSEMBLER_WX_EXCLUSIVE) void* m_start; size_t m_size; +#endif }; } // namespace JSC