diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/assembler/MacroAssemblerX86.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/assembler/MacroAssemblerX86.h')
-rw-r--r-- | Source/JavaScriptCore/assembler/MacroAssemblerX86.h | 135 |
1 files changed, 65 insertions, 70 deletions
diff --git a/Source/JavaScriptCore/assembler/MacroAssemblerX86.h b/Source/JavaScriptCore/assembler/MacroAssemblerX86.h index 547158fa7..75f35456d 100644 --- a/Source/JavaScriptCore/assembler/MacroAssemblerX86.h +++ b/Source/JavaScriptCore/assembler/MacroAssemblerX86.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,21 +23,19 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MacroAssemblerX86_h -#define MacroAssemblerX86_h +#pragma once #if ENABLE(ASSEMBLER) && CPU(X86) #include "MacroAssemblerX86Common.h" -#if USE(MASM_PROBE) -#include <wtf/StdLibExtras.h> -#endif - namespace JSC { class MacroAssemblerX86 : public MacroAssemblerX86Common { public: + static const unsigned numGPRs = 8; + static const unsigned numFPRs = 8; + static const Scale ScalePtr = TimesFour; using MacroAssemblerX86Common::add32; @@ -111,6 +109,18 @@ public: m_assembler.movzbl_mr(address, dest); } + void abortWithReason(AbortReason reason) + { + move(TrustedImm32(reason), X86Registers::eax); + breakpoint(); + } + + void abortWithReason(AbortReason reason, intptr_t misc) + { + move(TrustedImm32(misc), X86Registers::edx); + abortWithReason(reason); + } + ConvertibleLoadLabel convertibleLoadPtr(Address address, RegisterID dest) { ConvertibleLoadLabel result = ConvertibleLoadLabel(this); @@ -123,11 +133,11 @@ public: m_assembler.addsd_mr(address.m_ptr, dest); } - void storeDouble(FPRegisterID src, const void* address) + void storeDouble(FPRegisterID src, TrustedImmPtr address) { ASSERT(isSSE2Present()); - ASSERT(address); - m_assembler.movsd_rm(src, address); + ASSERT(address.m_value); + m_assembler.movsd_rm(src, address.m_value); } void convertInt32ToDouble(AbsoluteAddress src, FPRegisterID dest) @@ -152,22 +162,24 @@ public: void store8(TrustedImm32 imm, void* address) { - ASSERT(-128 <= imm.m_value && imm.m_value < 128); - m_assembler.movb_i8m(imm.m_value, address); + TrustedImm32 imm8(static_cast<int8_t>(imm.m_value)); + m_assembler.movb_i8m(imm8.m_value, address); } - // Possibly clobbers src. void moveDoubleToInts(FPRegisterID src, RegisterID dest1, RegisterID dest2) { - movePackedToInt32(src, dest1); - rshiftPacked(TrustedImm32(32), src); - movePackedToInt32(src, dest2); + ASSERT(isSSE2Present()); + m_assembler.pextrw_irr(3, src, dest1); + m_assembler.pextrw_irr(2, src, dest2); + lshift32(TrustedImm32(16), dest1); + or32(dest1, dest2); + moveFloatTo32(src, dest1); } void moveIntsToDouble(RegisterID src1, RegisterID src2, FPRegisterID dest, FPRegisterID scratch) { - moveInt32ToPacked(src1, dest); - moveInt32ToPacked(src2, scratch); + move32ToFloat(src1, dest); + move32ToFloat(src2, scratch); lshiftPacked(TrustedImm32(32), scratch); orPacked(scratch, dest); } @@ -227,17 +239,18 @@ public: Jump branch8(RelationalCondition cond, AbsoluteAddress left, TrustedImm32 right) { - m_assembler.cmpb_im(right.m_value, left.m_ptr); + TrustedImm32 right8(static_cast<int8_t>(right.m_value)); + m_assembler.cmpb_im(right8.m_value, left.m_ptr); return Jump(m_assembler.jCC(x86Condition(cond))); } Jump branchTest8(ResultCondition cond, AbsoluteAddress address, TrustedImm32 mask = TrustedImm32(-1)) { - ASSERT(mask.m_value >= -128 && mask.m_value <= 255); - if (mask.m_value == -1) + TrustedImm32 mask8(static_cast<int8_t>(mask.m_value)); + if (mask8.m_value == -1) m_assembler.cmpb_im(0, address.m_ptr); else - m_assembler.testb_im(mask.m_value, address.m_ptr); + m_assembler.testb_im(mask8.m_value, address.m_ptr); return Jump(m_assembler.jCC(x86Condition(cond))); } @@ -257,6 +270,14 @@ public: return Jump(m_assembler.jCC(x86Condition(cond))); } + Jump branch32WithPatch(RelationalCondition cond, Address left, DataLabel32& dataLabel, TrustedImm32 initialRightValue = TrustedImm32(0)) + { + padBeforePatch(); + m_assembler.cmpl_im_force32(initialRightValue.m_value, left.offset, left.base); + dataLabel = DataLabel32(this); + return Jump(m_assembler.jCC(x86Condition(cond))); + } + DataLabelPtr storePtrWithPatch(TrustedImmPtr initialValue, ImplicitAddress address) { padBeforePatch(); @@ -265,7 +286,6 @@ public: } static bool supportsFloatingPoint() { return isSSE2Present(); } - // See comment on MacroAssemblerARMv7::supportsFloatingPointTruncate() static bool supportsFloatingPointTruncate() { return isSSE2Present(); } static bool supportsFloatingPointSqrt() { return isSSE2Present(); } static bool supportsFloatingPointAbs() { return isSSE2Present(); } @@ -277,6 +297,7 @@ public: } static bool canJumpReplacePatchableBranchPtrWithPatch() { return true; } + static bool canJumpReplacePatchableBranch32WithPatch() { return true; } static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label) { @@ -299,6 +320,17 @@ public: return label.labelAtOffset(-totalBytes); } + static CodeLocationLabel startOfPatchableBranch32WithPatchOnAddress(CodeLocationDataLabel32 label) + { + const int opcodeBytes = 1; + const int modRMBytes = 1; + const int offsetBytes = 0; + const int immediateBytes = 4; + const int totalBytes = opcodeBytes + modRMBytes + offsetBytes + immediateBytes; + ASSERT(totalBytes >= maxJumpReplacementSize()); + return label.labelAtOffset(-totalBytes); + } + static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID reg, void* initialValue) { X86Assembler::revertJumpTo_cmpl_ir_force32(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), reg); @@ -310,18 +342,10 @@ public: X86Assembler::revertJumpTo_cmpl_im_force32(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), 0, address.base); } -#if USE(MASM_PROBE) - // For details about probe(), see comment in MacroAssemblerX86_64.h. - void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0); -#endif // USE(MASM_PROBE) - -private: - friend class LinkBuffer; - friend class RepatchBuffer; - - static void linkCall(void* code, Call call, FunctionPtr function) + static void revertJumpReplacementToPatchableBranch32WithPatch(CodeLocationLabel instructionStart, Address address, int32_t initialValue) { - X86Assembler::linkCall(code, call.m_label, function.value()); + ASSERT(!address.offset); + X86Assembler::revertJumpTo_cmpl_im_force32(instructionStart.executableAddress(), initialValue, 0, address.base); } static void repatchCall(CodeLocationCall call, CodeLocationLabel destination) @@ -334,47 +358,18 @@ private: X86Assembler::relinkCall(call.dataLocation(), destination.executableAddress()); } -#if USE(MASM_PROBE) - inline TrustedImm32 trustedImm32FromPtr(void* ptr) - { - return TrustedImm32(TrustedImmPtr(ptr)); - } - - inline TrustedImm32 trustedImm32FromPtr(ProbeFunction function) - { - return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function))); - } +private: + friend class LinkBuffer; - inline TrustedImm32 trustedImm32FromPtr(void (*function)()) + static void linkCall(void* code, Call call, FunctionPtr function) { - return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function))); + if (call.isFlagSet(Call::Tail)) + X86Assembler::linkJump(code, call.m_label, function.value()); + else + X86Assembler::linkCall(code, call.m_label, function.value()); } -#endif }; -#if USE(MASM_PROBE) - -extern "C" void ctiMasmProbeTrampoline(); - -// For details on "What code is emitted for the probe?" and "What values are in -// the saved registers?", see comment for MacroAssemblerX86::probe() in -// MacroAssemblerX86_64.h. - -inline void MacroAssemblerX86::probe(MacroAssemblerX86::ProbeFunction function, void* arg1, void* arg2) -{ - push(RegisterID::esp); - push(RegisterID::eax); - push(trustedImm32FromPtr(arg2)); - push(trustedImm32FromPtr(arg1)); - push(trustedImm32FromPtr(function)); - - move(trustedImm32FromPtr(ctiMasmProbeTrampoline), RegisterID::eax); - call(RegisterID::eax); -} -#endif // USE(MASM_PROBE) - } // namespace JSC #endif // ENABLE(ASSEMBLER) - -#endif // MacroAssemblerX86_h |