37 #ifndef V8_X64_ASSEMBLER_X64_H_
38 #define V8_X64_ASSEMBLER_X64_H_
94 const char*
const names[] = {
210 return reg.code() - 1;
221 const char*
const names[] = {
268 const XMMRegister
xmm0 = { 0 };
269 const XMMRegister
xmm1 = { 1 };
270 const XMMRegister
xmm2 = { 2 };
271 const XMMRegister
xmm3 = { 3 };
272 const XMMRegister
xmm4 = { 4 };
273 const XMMRegister
xmm5 = { 5 };
274 const XMMRegister
xmm6 = { 6 };
275 const XMMRegister
xmm7 = { 7 };
445 #define ASSEMBLER_INSTRUCTION_LIST(V) \
471 #define SHIFT_INSTRUCTION_LIST(V) \
481 class Assembler :
public AssemblerBase {
492 static const int kGap = 32;
638 #define DECLARE_INSTRUCTION(instruction) \
640 void instruction##p(P1 p1) { \
641 emit_##instruction(p1, kPointerSize); \
645 void instruction##l(P1 p1) { \
646 emit_##instruction(p1, kInt32Size); \
650 void instruction##q(P1 p1) { \
651 emit_##instruction(p1, kInt64Size); \
654 template<class P1, class P2> \
655 void instruction##p(P1 p1, P2 p2) { \
656 emit_##instruction(p1, p2, kPointerSize); \
659 template<class P1, class P2> \
660 void instruction##l(P1 p1, P2 p2) { \
661 emit_##instruction(p1, p2, kInt32Size); \
664 template<class P1, class P2> \
665 void instruction##q(P1 p1, P2 p2) { \
666 emit_##instruction(p1, p2, kInt64Size); \
669 template<class P1, class P2, class P3> \
670 void instruction##p(P1 p1, P2 p2, P3 p3) { \
671 emit_##instruction(p1, p2, p3, kPointerSize); \
674 template<class P1, class P2, class P3> \
675 void instruction##l(P1 p1, P2 p2, P3 p3) { \
676 emit_##instruction(p1, p2, p3, kInt32Size); \
679 template<class P1, class P2, class P3> \
680 void instruction##q(P1 p1, P2 p2, P3 p3) { \
681 emit_##instruction(p1, p2, p3, kInt64Size); \
684 #undef DECLARE_INSTRUCTION
816 #define DECLARE_SHIFT_INSTRUCTION(instruction, subcode) \
817 void instruction##p(Register dst, Immediate imm8) { \
818 shift(dst, imm8, subcode, kPointerSize); \
821 void instruction##l(Register dst, Immediate imm8) { \
822 shift(dst, imm8, subcode, kInt32Size); \
825 void instruction##q(Register dst, Immediate imm8) { \
826 shift(dst, imm8, subcode, kInt64Size); \
829 void instruction##p_cl(Register dst) { \
830 shift(dst, subcode, kPointerSize); \
833 void instruction##l_cl(Register dst) { \
834 shift(dst, subcode, kInt32Size); \
837 void instruction##q_cl(Register dst) { \
838 shift(dst, subcode, kInt64Size); \
841 #undef DECLARE_SHIFT_INSTRUCTION
914 void jmp(Label*
L, Label::Distance distance = Label::kFar);
924 Label::Distance distance = Label::kFar);
1175 inline void emitq(uint64_t x);
1284 template<
class P1,
class P2>
1309 emit(0xC0 | reg.low_bits() << 3 | rm_reg.low_bits());
1316 emit(0xC0 | code << 3 | rm_reg.low_bits());
1585 if (assembler_->buffer_overflow()) assembler_->GrowBuffer();
1587 space_before_ = assembler_->available_space();
1593 int bytes_generated = space_before_ - assembler_->available_space();
1594 DCHECK(bytes_generated < assembler_->kGap);
1599 Assembler* assembler_;
#define DECLARE_INSTRUCTION(instruction)
#define ASSEMBLER_INSTRUCTION_LIST(V)
#define DECLARE_SHIFT_INSTRUCTION(instruction, subcode)
#define SHIFT_INSTRUCTION_LIST(V)
Isolate * isolate() const
static const int kSpecialTargetSize
void bind_to(Label *L, int pos)
static Address target_address_at(Address pc, Code *code)
void store_rax(ExternalReference ref)
void emit_add(Register dst, const Operand &src, int size)
void popq(const Operand &dst)
RelocInfoWriter reloc_info_writer
void testb(const Operand &op, Immediate mask)
void shufps(XMMRegister dst, XMMRegister src, byte imm8)
void arithmetic_op_8(byte opcode, Register reg, const Operand &rm_reg)
void immediate_arithmetic_op(byte subcode, Register dst, Immediate src, int size)
void cmovq(Condition cc, Register dst, const Operand &src)
void cvttsd2si(Register dst, const Operand &src)
void shrd(Register dst, Register src)
void subsd(XMMRegister dst, XMMRegister src)
void emit_sse_operand(XMMRegister dst, XMMRegister src)
void call(Address entry, RelocInfo::Mode rmode)
void emit_imul(Register src, int size)
void emit_sub(const Operand &dst, Register src, int size)
void cmpw(Register dst, Immediate src)
void cmpb(Register dst, Register src)
void movapd(XMMRegister dst, XMMRegister src)
void cvttss2si(Register dst, XMMRegister src)
void emit_repmovs(int size)
void emit_cmp(const Operand &dst, Register src, int size)
void psllq(XMMRegister reg, byte imm8)
void subps(XMMRegister dst, const Operand &src)
void movb(Register dst, Immediate imm)
void movdqu(XMMRegister dst, const Operand &src)
static const int kShortCallInstructionLength
void cvtlsi2sd(XMMRegister dst, Register src)
void emit_xor(Register dst, Immediate src, int size)
void emit_add(const Operand &dst, Immediate src, int size)
Address runtime_entry_at(Address pc)
static const byte kJnzShortOpcode
void immediate_arithmetic_op_8(byte subcode, Register dst, Immediate src)
void movsd(const Operand &dst, XMMRegister src)
void emit_idiv(Register src, int size)
void sqrtsd(XMMRegister dst, const Operand &src)
static Address target_address_at(Address pc, ConstantPoolArray *constant_pool)
void movsxlq(Register dst, const Operand &src)
void emit_xor(Register dst, const Operand &src, int size)
static void set_target_address_at(Address pc, ConstantPoolArray *constant_pool, Address target, ICacheFlushMode icache_flush_mode=FLUSH_ICACHE_IF_NEEDED)
void fisttp_d(const Operand &adr)
void emit_sse_operand(XMMRegister dst, Register src)
void emit_cmp(const Operand &dst, Immediate src, int size)
void movq(Register dst, XMMRegister src)
void emit_inc(Register dst, int size)
void cmpb_al(Immediate src)
void cmpw(const Operand &dst, Immediate src)
static void deserialization_set_special_target_at(Address instruction_payload, Code *code, Address target)
void movdqa(XMMRegister dst, const Operand &src)
void jmp(Address entry, RelocInfo::Mode rmode)
void shift(Register dst, int subcode, int size)
void call(const Operand &operand)
static const byte kNopByte
void emit_xor(Register dst, Register src, int size)
void ucomisd(XMMRegister dst, XMMRegister src)
void cvtlsi2ss(XMMRegister dst, Register src)
void RecordComment(const char *msg, bool force=false)
void sqrtsd(XMMRegister dst, XMMRegister src)
void orpd(XMMRegister dst, XMMRegister src)
void movmskps(Register dst, XMMRegister src)
void fild_s(const Operand &adr)
void emit_code_relative_offset(Label *label)
void emit_or(Register dst, Register src, int size)
void emit_and(Register dst, const Operand &src, int size)
void movw(const Operand &dst, Register src)
static const int kCallSequenceLength
void emit_imul(Register dst, const Operand &src, int size)
void testb(Register dst, Register src)
void andps(XMMRegister dst, const Operand &src)
void j(Condition cc, Address entry, RelocInfo::Mode rmode)
void addsd(XMMRegister dst, XMMRegister src)
void emit_movzxw(Register dst, const Operand &src, int size)
void j(Condition cc, Label *L, Label::Distance distance=Label::kFar)
void mulsd(XMMRegister dst, const Operand &src)
void emit_not(Register dst, int size)
void movd(XMMRegister dst, Register src)
void movss(const Operand &dst, XMMRegister src)
void emit_sub(Register dst, Register src, int size)
void cvttsd2siq(Register dst, const Operand &src)
void emit_and(Register dst, Register src, int size)
static const int kCallScratchRegisterInstructionLength
void GetCode(CodeDesc *desc)
void testb(Register reg, Immediate mask)
void cmovq(Condition cc, Register dst, Register src)
int available_space() const
void movsxwq(Register dst, const Operand &src)
static const int kPatchDebugBreakSlotAddressOffset
void store_rax(void *dst, RelocInfo::Mode mode)
void xorpd(XMMRegister dst, XMMRegister src)
void emit_xchg(Register dst, Register src, int size)
static const byte kJccShortPrefix
void movp(Register dst, void *ptr, RelocInfo::Mode rmode)
void emit_sse_operand(XMMRegister reg, const Operand &adr)
void emit_xor(const Operand &dst, Register src, int size)
void long_at_put(int pos, uint32_t x)
void xorps(XMMRegister dst, XMMRegister src)
void emit_add(const Operand &dst, Register src, int size)
void emit_div(Register src, int size)
void emit_optional_rex_32(Register reg, Register rm_reg)
void ucomisd(XMMRegister dst, const Operand &src)
void emit_or(const Operand &dst, Register src, int size)
static const int kPatchDebugBreakSlotReturnOffset
void emit_sse_operand(Register reg, const Operand &adr)
void emit_modrm(int code, Register rm_reg)
void cvtqsi2sd(XMMRegister dst, Register src)
List< Handle< Code > > code_targets_
static void set_target_address_at(Address pc, Code *code, Address target, ICacheFlushMode icache_flush_mode=FLUSH_ICACHE_IF_NEEDED)
void emit_and(Register dst, Immediate src, int size)
void call(Address target)
void movsd(XMMRegister dst, const Operand &src)
void emit_test(Register reg, Immediate mask, int size)
void divsd(XMMRegister dst, XMMRegister src)
void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data=0)
void shift(Register dst, Immediate shift_amount, int subcode, int size)
void testb(const Operand &op, Register reg)
void cvttss2si(Register dst, const Operand &src)
void setcc(Condition cc, Register reg)
void emit_test(Register dst, Register src, int size)
void pushq(Immediate value)
void emit_cmp(Register dst, Immediate src, int size)
void fld_d(const Operand &adr)
static const int kMaximalBufferSize
static Address break_address_from_return_address(Address pc)
void immediate_arithmetic_op_8(byte subcode, const Operand &dst, Immediate src)
void movsxwl(Register dst, const Operand &src)
void movb(const Operand &dst, Register src)
void load_rax(ExternalReference ext)
void emit_dec(Register dst, int size)
void cmpb(Register dst, Immediate src)
void jmp(Handle< Code > target, RelocInfo::Mode rmode)
void emit_inc(const Operand &dst, int size)
void emit_or(const Operand &dst, Immediate src, int size)
void arithmetic_op(byte opcode, Register reg, Register rm_reg, int size)
void cmpw(Register dst, Register src)
void cmpb(Register dst, const Operand &src)
void subb(Register dst, Immediate src)
void emit_xchg(Register dst, const Operand &src, int size)
void immediate_arithmetic_op_16(byte subcode, const Operand &dst, Immediate src)
void fld_s(const Operand &adr)
void fist_s(const Operand &adr)
uint32_t long_at(int pos)
static RelocInfo::Mode RelocInfoNone()
void fisttp_s(const Operand &adr)
void emit_test(const Operand &op, Immediate mask, int size)
void emit_cmp(Register dst, const Operand &src, int size)
static const byte kTestEaxByte
void roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode)
void movsxbq(Register dst, const Operand &src)
void movb(Register dst, const Operand &src)
void j(Condition cc, Handle< Code > target, RelocInfo::Mode rmode)
Handle< ConstantPoolArray > NewConstantPool(Isolate *isolate)
void immediate_arithmetic_op(byte subcode, const Operand &dst, Immediate src, int size)
void fistp_d(const Operand &adr)
void emit_code_target(Handle< Code > target, RelocInfo::Mode rmode, TypeFeedbackId ast_id=TypeFeedbackId::None())
void cmovl(Condition cc, Register dst, const Operand &src)
void arithmetic_op_8(byte opcode, Register reg, Register rm_reg)
void cmpw(const Operand &dst, Register src)
void cmpltsd(XMMRegister dst, XMMRegister src)
void emit_imul(Register dst, Register src, int size)
void fstp_d(const Operand &adr)
void extractps(Register dst, XMMRegister src, byte imm8)
void emit_rex_32(Register reg, Register rm_reg)
void andps(XMMRegister dst, XMMRegister src)
void adr(const Register &rd, Label *label)
void movsd(XMMRegister dst, XMMRegister src)
friend class PositionsRecorder
void pushq_imm32(int32_t imm32)
void emit_sub(Register dst, const Operand &src, int size)
void emit_imul(Register dst, Register src, Immediate imm, int size)
void emit_rex(P1 p1, P2 p2, int size)
void movaps(XMMRegister dst, XMMRegister src)
void movw(Register dst, const Operand &src)
void emit_operand(Register reg, const Operand &adr)
void load_rax(void *ptr, RelocInfo::Mode rmode)
void arithmetic_op_16(byte opcode, Register reg, const Operand &rm_reg)
void cvtss2sd(XMMRegister dst, const Operand &src)
void jmp(Label *L, Label::Distance distance=Label::kFar)
void emit_runtime_entry(Address entry, RelocInfo::Mode rmode)
void emit_imul(Register dst, const Operand &src, Immediate imm, int size)
void emit_sse_operand(Register dst, XMMRegister src)
static Address target_address_at(Address pc, ConstantPoolArray *constant_pool)
void divps(XMMRegister dst, const Operand &src)
void cvttsd2si(Register dst, XMMRegister src)
void andb(Register dst, Immediate src)
void movdqa(const Operand &dst, XMMRegister src)
static void set_target_address_at(Address pc, ConstantPoolArray *constant_pool, Address target, ICacheFlushMode icache_flush_mode=FLUSH_ICACHE_IF_NEEDED)
void cmovl(Condition cc, Register dst, Register src)
void shld(Register dst, Register src)
void emit_or(Register dst, const Operand &src, int size)
void movss(XMMRegister dst, const Operand &src)
void emit_neg(const Operand &dst, int size)
void divps(XMMRegister dst, XMMRegister src)
void addsd(XMMRegister dst, const Operand &src)
void cmpw(Register dst, const Operand &src)
void emit_sub(Register dst, Immediate src, int size)
void emit_operand(int rm, const Operand &adr)
Handle< Object > code_target_object_handle_at(Address pc)
void fisub_s(const Operand &adr)
void movb(const Operand &dst, Immediate imm)
static bool IsNop(Address addr)
void pushq(const Operand &src)
static const int kMoveAddressIntoScratchRegisterInstructionLength
void emit_modrm(Register reg, Register rm_reg)
void cvtsd2si(Register dst, XMMRegister src)
static const int kJSReturnSequenceLength
void RecordDebugBreakSlot()
void emitp(void *x, RelocInfo::Mode rmode)
void emit_dec(const Operand &dst, int size)
void emit_test(const Operand &op, Register reg, int size)
static const int kDebugBreakSlotLength
static const byte kJncShortOpcode
void emit_cmp(Register dst, Register src, int size)
void movsxbl(Register dst, const Operand &src)
void andpd(XMMRegister dst, XMMRegister src)
void movq(Register dst, uint64_t value)
void emit_farith(int b1, int b2, int i)
void bsrl(Register dst, Register src)
void cvtsd2siq(Register dst, XMMRegister src)
void set_byte_at(int pos, byte value)
void bts(const Operand &dst, Register src)
static const byte kTestAlByte
void emit_and(const Operand &dst, Immediate src, int size)
void cmpb(const Operand &dst, Register src)
static const int kRealPatchReturnSequenceAddressOffset
void mulsd(XMMRegister dst, XMMRegister src)
void cmpb(const Operand &dst, Immediate src)
void orps(XMMRegister dst, XMMRegister src)
void cvttsd2siq(Register dst, XMMRegister src)
void emit_add(Register dst, Immediate src, int size)
void enter(Immediate size)
void mulps(XMMRegister dst, XMMRegister src)
void emit_not(const Operand &dst, int size)
STATIC_ASSERT(kPointerSize==kInt64Size||kPointerSize==kInt32Size)
void movdqu(const Operand &dst, XMMRegister src)
void fstp_s(const Operand &adr)
void mulps(XMMRegister dst, const Operand &src)
static const int kCallTargetAddressOffset
void movq(Register dst, int64_t value)
static const int kPatchReturnSequenceAddressOffset
void fistp_s(const Operand &adr)
void bt(const Operand &dst, Register src)
void cvtlsi2sd(XMMRegister dst, const Operand &src)
void immediate_arithmetic_op_16(byte subcode, Register dst, Immediate src)
void emit_mov(Register dst, Register src, int size)
void movq(XMMRegister dst, Register src)
void cvtqsi2sd(XMMRegister dst, const Operand &src)
void emit_or(Register dst, Immediate src, int size)
void movmskpd(Register dst, XMMRegister src)
void emit_rex(P1 p1, int size)
void arithmetic_op(byte opcode, Register reg, const Operand &rm_reg, int size)
void emit_sbb(Register dst, Register src, int size)
void movd(Register dst, XMMRegister src)
void movsxlq(Register dst, Register src)
void cvtsd2ss(XMMRegister dst, XMMRegister src)
void emit_add(Register dst, Register src, int size)
void decb(const Operand &dst)
void call(Handle< Code > target, RelocInfo::Mode rmode=RelocInfo::CODE_TARGET, TypeFeedbackId ast_id=TypeFeedbackId::None())
static const byte kJcShortOpcode
void emit_sub(const Operand &dst, Immediate src, int size)
void addps(XMMRegister dst, XMMRegister src)
void emit_neg(Register dst, int size)
void subps(XMMRegister dst, XMMRegister src)
void emit_movzxb(Register dst, Register src, int size)
void fild_d(const Operand &adr)
void emit_xor(const Operand &dst, Immediate src, int size)
void jmp(const Operand &src)
void emit_mov(Register dst, const Operand &src, int size)
PositionsRecorder positions_recorder_
Assembler(Isolate *isolate, void *buffer, int buffer_size)
void movl(const Operand &dst, Label *src)
PositionsRecorder * positions_recorder()
static Address target_address_from_return_address(Address pc)
bool buffer_overflow() const
void emit_mov(const Operand &dst, Immediate value, int size)
void addps(XMMRegister dst, const Operand &src)
int SizeOfCodeGeneratedSince(Label *label)
void movq(XMMRegister dst, XMMRegister src)
void emit_movzxb(Register dst, const Operand &src, int size)
void emit_movzxw(Register dst, Register src, int size)
void xorps(XMMRegister dst, const Operand &src)
void emit_and(const Operand &dst, Register src, int size)
void emit_test(Register reg, const Operand &op, int size)
void emit_lea(Register dst, const Operand &src, int size)
static const byte kJzShortOpcode
void PopulateConstantPool(ConstantPoolArray *constant_pool)
void cvtss2sd(XMMRegister dst, XMMRegister src)
void emit_mov(Register dst, Immediate value, int size)
void movw(const Operand &dst, Immediate imm)
void orps(XMMRegister dst, const Operand &src)
void arithmetic_op_16(byte opcode, Register reg, Register rm_reg)
void emit_mov(const Operand &dst, Register src, int size)
void set_modrm(int mod, Register rm)
Operand(const Operand &base, int32_t offset)
bool AddressUsesRegister(Register reg) const
void set_disp32(int disp)
Operand(Register index, ScaleFactor scale, int32_t disp)
void set_sib(ScaleFactor scale, Register index, Register base)
EnsureSpace(Assembler *assembler)
bool requires_rex() const
Operand(Register base, Register index, ScaleFactor scale, int32_t disp)
Operand(Register base, int32_t disp)
ConstantPoolArray * constant_pool()
static TypeFeedbackId None()
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
Condition CommuteCondition(Condition cond)
const int kRegister_rdx_Code
const int kRegister_rbp_Code
DwVfpRegister DoubleRegister
const int kRegister_r14_Code
const int kRegister_r12_Code
const int kRegister_rdi_Code
const int kRegister_rsp_Code
const int kRegister_r13_Code
const int kRegister_r8_Code
const int kRegister_r11_Code
Condition NegateCondition(Condition cond)
const int kRegister_rax_Code
const int kRegister_r15_Code
static bool SmiValuesAre31Bits()
const int kRegister_rcx_Code
const int kRegister_r10_Code
const int kRegister_no_reg_Code
const int kRegister_r9_Code
const int kRegister_rbx_Code
const int kRegister_rsi_Code
Debugger support for the V8 JavaScript engine.
static const int kNumRegisters
static int NumAllocatableRegisters()
static Register from_code(int code)
static int ToAllocationIndex(Register reg)
bool is(Register reg) const
static const char * AllocationIndexToString(int index)
bool is_byte_register() const
static const int kMaxNumAllocatableRegisters
static const int kAllocationIndexByRegisterCode[kNumRegisters]
static const int kRegisterCodeByAllocationIndex[kMaxNumAllocatableRegisters]
static Register FromAllocationIndex(int index)
static XMMRegister FromAllocationIndex(int index)
static const int kMaxNumRegisters
static XMMRegister from_code(int code)
static const int kMaxNumAllocatableRegisters
static int NumAllocatableRegisters()
static int ToAllocationIndex(XMMRegister reg)
static const char * AllocationIndexToString(int index)
bool is(XMMRegister reg) const
static int NumAllocatableAliasedRegisters()