21 CHECK(cpu.has_sse2());
22 CHECK(cpu.has_cmov());
25 if (cross_compile)
return;
47 CodePatcher patcher(
pc_, code_size);
52 patcher.masm()->bind(&check_codesize);
62 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize));
65 for (
int i = 0;
i < guard_bytes;
i++) {
66 patcher.masm()->int3();
73 for (
int i = 0;
i < instruction_count;
i++) {
74 *(
pc_ +
i) = *(instructions +
i);
88 0, 3, 2, 1, 6, 7, 8, 9, 11, 14, 15
92 0, 3, 2, 1, -1, -1, 4, 5, 6, 7, -1, 8, -1, -1, 9, 10
101 if (base.is(
rsp) || base.is(
r12)) {
106 if (disp == 0 && !base.is(
rbp) && !base.is(
r13)) {
108 }
else if (is_int8(disp)) {
118 Operand::Operand(Register base,
124 set_sib(scale, index, base);
125 if (disp == 0 && !base.is(
rbp) && !base.is(
r13)) {
129 }
else if (is_int8(disp)) {
139 Operand::Operand(Register index,
145 set_sib(scale, index,
rbp);
150 Operand::Operand(
const Operand& operand,
int32_t offset) {
151 DCHECK(operand.len_ >= 1);
153 byte modrm = operand.buf_[0];
155 bool has_sib = ((modrm & 0x07) == 0x04);
156 byte mode = modrm & 0xC0;
157 int disp_offset = has_sib ? 2 : 1;
158 int base_reg = (has_sib ? operand.buf_[1] : modrm) & 0x07;
161 bool is_baseless = (
mode == 0) && (base_reg == 0x05);
163 if (
mode == 0x80 || is_baseless) {
165 disp_value = *bit_cast<const int32_t*>(&operand.buf_[disp_offset]);
166 }
else if (
mode == 0x40) {
168 disp_value =
static_cast<signed char>(operand.buf_[disp_offset]);
172 DCHECK(offset >= 0 ? disp_value + offset > disp_value
173 : disp_value + offset < disp_value);
174 disp_value += offset;
176 if (!is_int8(disp_value) || is_baseless) {
178 buf_[0] = (modrm & 0x3f) | (is_baseless ? 0x00 : 0x80);
179 len_ = disp_offset + 4;
180 Memory::int32_at(&buf_[disp_offset]) = disp_value;
181 }
else if (disp_value != 0 || (base_reg == 0x05)) {
183 buf_[0] = (modrm & 0x3f) | 0x40;
184 len_ = disp_offset + 1;
185 buf_[disp_offset] =
static_cast<byte>(disp_value);
188 buf_[0] = (modrm & 0x3f);
192 buf_[1] = operand.buf_[1];
197 bool Operand::AddressUsesRegister(Register reg)
const {
198 int code = reg.code();
199 DCHECK((buf_[0] & 0xC0) != 0xC0);
202 int base_code = buf_[0] & 0x07;
206 int index_code = ((buf_[1] >> 3) & 0x07) | ((rex_ & 0x02) << 2);
208 if (index_code !=
rsp.
code() && index_code == code)
return true;
210 base_code = (buf_[1] & 0x07) | ((rex_ & 0x01) << 3);
212 if (base_code ==
rbp.
code() && ((buf_[0] & 0xC0) == 0))
return false;
213 return code == base_code;
217 if (base_code ==
rbp.
code() && ((buf_[0] & 0xC0) == 0))
return false;
218 base_code |= ((rex_ & 0x01) << 3);
219 return code == base_code;
227 #ifdef GENERATED_CODE_COVERAGE
228 static void InitCoverageLog();
231 Assembler::Assembler(Isolate* isolate,
void* buffer,
int buffer_size)
232 : AssemblerBase(isolate, buffer, buffer_size),
234 positions_recorder_(this) {
240 memset(buffer_, 0xCC, buffer_size_);
244 reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_);
247 #ifdef GENERATED_CODE_COVERAGE
253 void Assembler::GetCode(CodeDesc* desc) {
256 DCHECK(pc_ <= reloc_info_writer.pos());
258 desc->buffer = buffer_;
259 desc->buffer_size = buffer_size_;
260 desc->instr_size = pc_offset();
261 DCHECK(desc->instr_size > 0);
263 static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos());
270 int delta = (m - (pc_offset() & (m - 1))) & (m - 1);
275 void Assembler::CodeTargetAlign() {
280 bool Assembler::IsNop(
Address addr) {
282 while (*a == 0x66) a++;
283 if (*a == 0x90)
return true;
284 if (a[0] == 0xf && a[1] == 0x1f)
return true;
289 void Assembler::bind_to(Label*
L,
int pos) {
291 DCHECK(0 <= pos && pos <= pc_offset());
292 if (
L->is_linked()) {
293 int current =
L->pos();
294 int next = long_at(current);
295 while (next != current) {
297 int imm32 = pos - (current +
sizeof(
int32_t));
298 long_at_put(current, imm32);
300 next = long_at(next);
303 int last_imm32 = pos - (current +
sizeof(
int32_t));
304 long_at_put(current, last_imm32);
306 while (
L->is_near_linked()) {
307 int fixup_pos =
L->near_link_pos();
309 static_cast<int>(*
reinterpret_cast<int8_t*
>(addr_at(fixup_pos)));
310 DCHECK(offset_to_next <= 0);
311 int disp = pos - (fixup_pos +
sizeof(int8_t));
312 CHECK(is_int8(disp));
313 set_byte_at(fixup_pos, disp);
314 if (offset_to_next < 0) {
315 L->link_to(fixup_pos + offset_to_next, Label::kNear);
324 void Assembler::bind(Label*
L) {
325 bind_to(
L, pc_offset());
329 void Assembler::GrowBuffer() {
330 DCHECK(buffer_overflow());
331 if (!own_buffer_)
FATAL(
"external code buffer is too small");
335 desc.buffer_size = 2 * buffer_size_;
339 if ((desc.buffer_size > kMaximalBufferSize) ||
340 (desc.buffer_size > isolate()->heap()->MaxOldGenerationSize())) {
345 desc.buffer = NewArray<byte>(desc.buffer_size);
346 desc.instr_size = pc_offset();
348 static_cast<int>((buffer_ + buffer_size_) - (reloc_info_writer.pos()));
353 memset(desc.buffer, 0xCC, desc.buffer_size);
357 intptr_t pc_delta = desc.buffer - buffer_;
358 intptr_t rc_delta = (desc.buffer + desc.buffer_size) -
359 (buffer_ + buffer_size_);
360 MemMove(desc.buffer, buffer_, desc.instr_size);
361 MemMove(rc_delta + reloc_info_writer.pos(), reloc_info_writer.pos(),
366 buffer_ = desc.buffer;
367 buffer_size_ = desc.buffer_size;
369 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta,
370 reloc_info_writer.last_pc() + pc_delta);
373 for (RelocIterator it(desc); !it.done(); it.next()) {
374 RelocInfo::Mode rmode = it.rinfo()->rmode();
375 if (rmode == RelocInfo::INTERNAL_REFERENCE) {
376 intptr_t* p =
reinterpret_cast<intptr_t*
>(it.rinfo()->pc());
383 DCHECK(!buffer_overflow());
387 void Assembler::emit_operand(
int code,
const Operand& adr) {
389 const unsigned length = adr.len_;
393 DCHECK((adr.buf_[0] & 0x38) == 0);
394 pc_[0] = adr.buf_[0] | code << 3;
397 for (
unsigned i = 1;
i < length;
i++) pc_[
i] = adr.buf_[
i];
404 void Assembler::arithmetic_op(
byte opcode,
408 EnsureSpace ensure_space(
this);
409 emit_rex(reg, op,
size);
411 emit_operand(reg, op);
415 void Assembler::arithmetic_op(
byte opcode,
419 EnsureSpace ensure_space(
this);
420 DCHECK((opcode & 0xC6) == 2);
421 if (rm_reg.low_bits() == 4) {
423 emit_rex(rm_reg, reg,
size);
425 emit_modrm(rm_reg, reg);
427 emit_rex(reg, rm_reg,
size);
429 emit_modrm(reg, rm_reg);
434 void Assembler::arithmetic_op_16(
byte opcode, Register reg, Register rm_reg) {
435 EnsureSpace ensure_space(
this);
436 DCHECK((opcode & 0xC6) == 2);
437 if (rm_reg.low_bits() == 4) {
440 emit_optional_rex_32(rm_reg, reg);
442 emit_modrm(rm_reg, reg);
445 emit_optional_rex_32(reg, rm_reg);
447 emit_modrm(reg, rm_reg);
452 void Assembler::arithmetic_op_16(
byte opcode,
454 const Operand& rm_reg) {
455 EnsureSpace ensure_space(
this);
457 emit_optional_rex_32(reg, rm_reg);
459 emit_operand(reg, rm_reg);
463 void Assembler::arithmetic_op_8(
byte opcode, Register reg,
const Operand& op) {
464 EnsureSpace ensure_space(
this);
465 if (!reg.is_byte_register()) {
470 emit_operand(reg, op);
474 void Assembler::arithmetic_op_8(
byte opcode, Register reg, Register rm_reg) {
475 EnsureSpace ensure_space(
this);
476 DCHECK((opcode & 0xC6) == 2);
477 if (rm_reg.low_bits() == 4) {
479 if (!rm_reg.is_byte_register() || !reg.is_byte_register()) {
481 emit_rex_32(rm_reg, reg);
484 emit_modrm(rm_reg, reg);
486 if (!reg.is_byte_register() || !rm_reg.is_byte_register()) {
488 emit_rex_32(reg, rm_reg);
491 emit_modrm(reg, rm_reg);
496 void Assembler::immediate_arithmetic_op(
byte subcode,
500 EnsureSpace ensure_space(
this);
502 if (is_int8(src.value_)) {
504 emit_modrm(subcode, dst);
506 }
else if (dst.is(
rax)) {
507 emit(0x05 | (subcode << 3));
511 emit_modrm(subcode, dst);
516 void Assembler::immediate_arithmetic_op(
byte subcode,
520 EnsureSpace ensure_space(
this);
522 if (is_int8(src.value_)) {
524 emit_operand(subcode, dst);
528 emit_operand(subcode, dst);
534 void Assembler::immediate_arithmetic_op_16(
byte subcode,
537 EnsureSpace ensure_space(
this);
539 emit_optional_rex_32(dst);
540 if (is_int8(src.value_)) {
542 emit_modrm(subcode, dst);
544 }
else if (dst.is(
rax)) {
545 emit(0x05 | (subcode << 3));
549 emit_modrm(subcode, dst);
555 void Assembler::immediate_arithmetic_op_16(
byte subcode,
558 EnsureSpace ensure_space(
this);
560 emit_optional_rex_32(dst);
561 if (is_int8(src.value_)) {
563 emit_operand(subcode, dst);
567 emit_operand(subcode, dst);
573 void Assembler::immediate_arithmetic_op_8(
byte subcode,
576 EnsureSpace ensure_space(
this);
577 emit_optional_rex_32(dst);
578 DCHECK(is_int8(src.value_) || is_uint8(src.value_));
580 emit_operand(subcode, dst);
585 void Assembler::immediate_arithmetic_op_8(
byte subcode,
588 EnsureSpace ensure_space(
this);
589 if (!dst.is_byte_register()) {
593 DCHECK(is_int8(src.value_) || is_uint8(src.value_));
595 emit_modrm(subcode, dst);
601 Immediate shift_amount,
604 EnsureSpace ensure_space(
this);
606 : is_uint5(shift_amount.value_));
607 if (shift_amount.value_ == 1) {
610 emit_modrm(subcode, dst);
614 emit_modrm(subcode, dst);
615 emit(shift_amount.value_);
621 EnsureSpace ensure_space(
this);
624 emit_modrm(subcode, dst);
628 void Assembler::bt(
const Operand& dst, Register src) {
629 EnsureSpace ensure_space(
this);
630 emit_rex_64(src, dst);
633 emit_operand(src, dst);
637 void Assembler::bts(
const Operand& dst, Register src) {
638 EnsureSpace ensure_space(
this);
639 emit_rex_64(src, dst);
642 emit_operand(src, dst);
646 void Assembler::bsrl(Register dst, Register src) {
647 EnsureSpace ensure_space(
this);
648 emit_optional_rex_32(dst, src);
651 emit_modrm(dst, src);
655 void Assembler::call(Label*
L) {
656 positions_recorder()->WriteRecordedPositions();
657 EnsureSpace ensure_space(
this);
661 int offset =
L->pos() - pc_offset() -
sizeof(
int32_t);
664 }
else if (
L->is_linked()) {
666 L->link_to(pc_offset() -
sizeof(
int32_t));
676 void Assembler::call(
Address entry, RelocInfo::Mode rmode) {
677 DCHECK(RelocInfo::IsRuntimeEntry(rmode));
678 positions_recorder()->WriteRecordedPositions();
679 EnsureSpace ensure_space(
this);
682 emit_runtime_entry(entry, rmode);
686 void Assembler::call(Handle<Code> target,
687 RelocInfo::Mode rmode,
688 TypeFeedbackId ast_id) {
689 positions_recorder()->WriteRecordedPositions();
690 EnsureSpace ensure_space(
this);
693 emit_code_target(target, rmode, ast_id);
697 void Assembler::call(Register adr) {
698 positions_recorder()->WriteRecordedPositions();
699 EnsureSpace ensure_space(
this);
701 emit_optional_rex_32(adr);
703 emit_modrm(0x2, adr);
707 void Assembler::call(
const Operand& op) {
708 positions_recorder()->WriteRecordedPositions();
709 EnsureSpace ensure_space(
this);
711 emit_optional_rex_32(op);
713 emit_operand(0x2, op);
721 void Assembler::call(
Address target) {
722 positions_recorder()->WriteRecordedPositions();
723 EnsureSpace ensure_space(
this);
727 intptr_t displacement = target - source;
728 DCHECK(is_int32(displacement));
729 emitl(
static_cast<int32_t>(displacement));
733 void Assembler::clc() {
734 EnsureSpace ensure_space(
this);
739 void Assembler::cld() {
740 EnsureSpace ensure_space(
this);
745 void Assembler::cdq() {
746 EnsureSpace ensure_space(
this);
751 void Assembler::cmovq(
Condition cc, Register dst, Register src) {
760 EnsureSpace ensure_space(
this);
762 emit_rex_64(dst, src);
765 emit_modrm(dst, src);
769 void Assembler::cmovq(
Condition cc, Register dst,
const Operand& src) {
776 EnsureSpace ensure_space(
this);
778 emit_rex_64(dst, src);
781 emit_operand(dst, src);
785 void Assembler::cmovl(
Condition cc, Register dst, Register src) {
792 EnsureSpace ensure_space(
this);
794 emit_optional_rex_32(dst, src);
797 emit_modrm(dst, src);
801 void Assembler::cmovl(
Condition cc, Register dst,
const Operand& src) {
808 EnsureSpace ensure_space(
this);
810 emit_optional_rex_32(dst, src);
813 emit_operand(dst, src);
817 void Assembler::cmpb_al(Immediate imm8) {
818 DCHECK(is_int8(imm8.value_) || is_uint8(imm8.value_));
819 EnsureSpace ensure_space(
this);
825 void Assembler::cpuid() {
826 EnsureSpace ensure_space(
this);
832 void Assembler::cqo() {
833 EnsureSpace ensure_space(
this);
839 void Assembler::emit_dec(Register dst,
int size) {
840 EnsureSpace ensure_space(
this);
843 emit_modrm(0x1, dst);
847 void Assembler::emit_dec(
const Operand& dst,
int size) {
848 EnsureSpace ensure_space(
this);
851 emit_operand(1, dst);
855 void Assembler::decb(Register dst) {
856 EnsureSpace ensure_space(
this);
857 if (!dst.is_byte_register()) {
862 emit_modrm(0x1, dst);
866 void Assembler::decb(
const Operand& dst) {
867 EnsureSpace ensure_space(
this);
868 emit_optional_rex_32(dst);
870 emit_operand(1, dst);
874 void Assembler::enter(Immediate
size) {
875 EnsureSpace ensure_space(
this);
882 void Assembler::hlt() {
883 EnsureSpace ensure_space(
this);
888 void Assembler::emit_idiv(Register src,
int size) {
889 EnsureSpace ensure_space(
this);
892 emit_modrm(0x7, src);
896 void Assembler::emit_div(Register src,
int size) {
897 EnsureSpace ensure_space(
this);
900 emit_modrm(0x6, src);
904 void Assembler::emit_imul(Register src,
int size) {
905 EnsureSpace ensure_space(
this);
908 emit_modrm(0x5, src);
912 void Assembler::emit_imul(Register dst, Register src,
int size) {
913 EnsureSpace ensure_space(
this);
914 emit_rex(dst, src,
size);
917 emit_modrm(dst, src);
921 void Assembler::emit_imul(Register dst,
const Operand& src,
int size) {
922 EnsureSpace ensure_space(
this);
923 emit_rex(dst, src,
size);
926 emit_operand(dst, src);
930 void Assembler::emit_imul(Register dst, Register src, Immediate imm,
int size) {
931 EnsureSpace ensure_space(
this);
932 emit_rex(dst, src,
size);
933 if (is_int8(imm.value_)) {
935 emit_modrm(dst, src);
939 emit_modrm(dst, src);
945 void Assembler::emit_imul(Register dst,
const Operand& src, Immediate imm,
947 EnsureSpace ensure_space(
this);
948 emit_rex(dst, src,
size);
949 if (is_int8(imm.value_)) {
954 emit_operand(dst, src);
959 void Assembler::emit_inc(Register dst,
int size) {
960 EnsureSpace ensure_space(
this);
963 emit_modrm(0x0, dst);
967 void Assembler::emit_inc(
const Operand& dst,
int size) {
968 EnsureSpace ensure_space(
this);
971 emit_operand(0, dst);
975 void Assembler::int3() {
976 EnsureSpace ensure_space(
this);
981 void Assembler::j(
Condition cc, Label*
L, Label::Distance distance) {
988 EnsureSpace ensure_space(
this);
991 const int short_size = 2;
992 const int long_size = 6;
993 int offs =
L->pos() - pc_offset();
1004 if (is_int8(offs - short_size) && !predictable_code_size()) {
1007 emit((offs - short_size) & 0xFF);
1012 emitl(offs - long_size);
1014 }
else if (distance == Label::kNear) {
1018 if (
L->is_near_linked()) {
1019 int offset =
L->near_link_pos() - pc_offset();
1021 disp =
static_cast<byte>(offset & 0xFF);
1023 L->link_to(pc_offset(), Label::kNear);
1025 }
else if (
L->is_linked()) {
1030 L->link_to(pc_offset() -
sizeof(
int32_t));
1035 int32_t current = pc_offset();
1037 L->link_to(current);
1043 DCHECK(RelocInfo::IsRuntimeEntry(rmode));
1044 EnsureSpace ensure_space(
this);
1048 emit_runtime_entry(entry, rmode);
1053 Handle<Code> target,
1054 RelocInfo::Mode rmode) {
1055 EnsureSpace ensure_space(
this);
1060 emit_code_target(target, rmode);
1064 void Assembler::jmp(Label*
L, Label::Distance distance) {
1065 EnsureSpace ensure_space(
this);
1066 const int short_size =
sizeof(int8_t);
1067 const int long_size =
sizeof(
int32_t);
1068 if (
L->is_bound()) {
1069 int offs =
L->pos() - pc_offset() - 1;
1071 if (is_int8(offs - short_size) && !predictable_code_size()) {
1074 emit((offs - short_size) & 0xFF);
1078 emitl(offs - long_size);
1080 }
else if (distance == Label::kNear) {
1083 if (
L->is_near_linked()) {
1084 int offset =
L->near_link_pos() - pc_offset();
1086 disp =
static_cast<byte>(offset & 0xFF);
1088 L->link_to(pc_offset(), Label::kNear);
1090 }
else if (
L->is_linked()) {
1094 L->link_to(pc_offset() - long_size);
1099 int32_t current = pc_offset();
1101 L->link_to(current);
1106 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) {
1107 EnsureSpace ensure_space(
this);
1110 emit_code_target(target, rmode);
1114 void Assembler::jmp(
Address entry, RelocInfo::Mode rmode) {
1115 DCHECK(RelocInfo::IsRuntimeEntry(rmode));
1116 EnsureSpace ensure_space(
this);
1117 DCHECK(RelocInfo::IsRuntimeEntry(rmode));
1119 emit_runtime_entry(entry, rmode);
1123 void Assembler::jmp(Register target) {
1124 EnsureSpace ensure_space(
this);
1126 emit_optional_rex_32(target);
1128 emit_modrm(0x4, target);
1132 void Assembler::jmp(
const Operand& src) {
1133 EnsureSpace ensure_space(
this);
1135 emit_optional_rex_32(src);
1137 emit_operand(0x4, src);
1141 void Assembler::emit_lea(Register dst,
const Operand& src,
int size) {
1142 EnsureSpace ensure_space(
this);
1143 emit_rex(dst, src,
size);
1145 emit_operand(dst, src);
1149 void Assembler::load_rax(
void* value, RelocInfo::Mode
mode) {
1150 EnsureSpace ensure_space(
this);
1167 void Assembler::load_rax(ExternalReference ref) {
1168 load_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE);
1172 void Assembler::leave() {
1173 EnsureSpace ensure_space(
this);
1178 void Assembler::movb(Register dst,
const Operand& src) {
1179 EnsureSpace ensure_space(
this);
1180 if (!dst.is_byte_register()) {
1182 emit_rex_32(dst, src);
1184 emit_optional_rex_32(dst, src);
1187 emit_operand(dst, src);
1191 void Assembler::movb(Register dst, Immediate imm) {
1192 EnsureSpace ensure_space(
this);
1193 if (!dst.is_byte_register()) {
1197 emit(0xB0 + dst.low_bits());
1202 void Assembler::movb(
const Operand& dst, Register src) {
1203 EnsureSpace ensure_space(
this);
1204 if (!src.is_byte_register()) {
1206 emit_rex_32(src, dst);
1208 emit_optional_rex_32(src, dst);
1211 emit_operand(src, dst);
1215 void Assembler::movb(
const Operand& dst, Immediate imm) {
1216 EnsureSpace ensure_space(
this);
1217 emit_optional_rex_32(dst);
1219 emit_operand(0x0, dst);
1220 emit(
static_cast<byte>(imm.value_));
1224 void Assembler::movw(Register dst,
const Operand& src) {
1225 EnsureSpace ensure_space(
this);
1227 emit_optional_rex_32(dst, src);
1229 emit_operand(dst, src);
1233 void Assembler::movw(
const Operand& dst, Register src) {
1234 EnsureSpace ensure_space(
this);
1236 emit_optional_rex_32(src, dst);
1238 emit_operand(src, dst);
1242 void Assembler::movw(
const Operand& dst, Immediate imm) {
1243 EnsureSpace ensure_space(
this);
1245 emit_optional_rex_32(dst);
1247 emit_operand(0x0, dst);
1248 emit(
static_cast<byte>(imm.value_ & 0xff));
1249 emit(
static_cast<byte>(imm.value_ >> 8));
1253 void Assembler::emit_mov(Register dst,
const Operand& src,
int size) {
1254 EnsureSpace ensure_space(
this);
1255 emit_rex(dst, src,
size);
1257 emit_operand(dst, src);
1261 void Assembler::emit_mov(Register dst, Register src,
int size) {
1262 EnsureSpace ensure_space(
this);
1263 if (src.low_bits() == 4) {
1264 emit_rex(src, dst,
size);
1266 emit_modrm(src, dst);
1268 emit_rex(dst, src,
size);
1270 emit_modrm(dst, src);
1275 void Assembler::emit_mov(
const Operand& dst, Register src,
int size) {
1276 EnsureSpace ensure_space(
this);
1277 emit_rex(src, dst,
size);
1279 emit_operand(src, dst);
1283 void Assembler::emit_mov(Register dst, Immediate value,
int size) {
1284 EnsureSpace ensure_space(
this);
1285 emit_rex(dst,
size);
1288 emit_modrm(0x0, dst);
1291 emit(0xB8 + dst.low_bits());
1297 void Assembler::emit_mov(
const Operand& dst, Immediate value,
int size) {
1298 EnsureSpace ensure_space(
this);
1299 emit_rex(dst,
size);
1301 emit_operand(0x0, dst);
1306 void Assembler::movp(Register dst,
void* value, RelocInfo::Mode rmode) {
1307 EnsureSpace ensure_space(
this);
1309 emit(0xB8 | dst.low_bits());
1310 emitp(value, rmode);
1314 void Assembler::movq(Register dst, int64_t value) {
1315 EnsureSpace ensure_space(
this);
1317 emit(0xB8 | dst.low_bits());
1322 void Assembler::movq(Register dst, uint64_t value) {
1323 movq(dst,
static_cast<int64_t
>(value));
1329 void Assembler::movl(
const Operand& dst, Label* src) {
1330 EnsureSpace ensure_space(
this);
1331 emit_optional_rex_32(dst);
1333 emit_operand(0, dst);
1334 if (src->is_bound()) {
1335 int offset = src->pos() - pc_offset() -
sizeof(
int32_t);
1338 }
else if (src->is_linked()) {
1340 src->link_to(pc_offset() -
sizeof(
int32_t));
1342 DCHECK(src->is_unused());
1343 int32_t current = pc_offset();
1345 src->link_to(current);
1350 void Assembler::movsxbl(Register dst,
const Operand& src) {
1351 EnsureSpace ensure_space(
this);
1352 emit_optional_rex_32(dst, src);
1355 emit_operand(dst, src);
1359 void Assembler::movsxbq(Register dst,
const Operand& src) {
1360 EnsureSpace ensure_space(
this);
1361 emit_rex_64(dst, src);
1364 emit_operand(dst, src);
1368 void Assembler::movsxwl(Register dst,
const Operand& src) {
1369 EnsureSpace ensure_space(
this);
1370 emit_optional_rex_32(dst, src);
1373 emit_operand(dst, src);
1377 void Assembler::movsxwq(Register dst,
const Operand& src) {
1378 EnsureSpace ensure_space(
this);
1379 emit_rex_64(dst, src);
1382 emit_operand(dst, src);
1386 void Assembler::movsxlq(Register dst, Register src) {
1387 EnsureSpace ensure_space(
this);
1388 emit_rex_64(dst, src);
1390 emit_modrm(dst, src);
1394 void Assembler::movsxlq(Register dst,
const Operand& src) {
1395 EnsureSpace ensure_space(
this);
1396 emit_rex_64(dst, src);
1398 emit_operand(dst, src);
1402 void Assembler::emit_movzxb(Register dst,
const Operand& src,
int size) {
1403 EnsureSpace ensure_space(
this);
1406 emit_optional_rex_32(dst, src);
1409 emit_operand(dst, src);
1413 void Assembler::emit_movzxb(Register dst, Register src,
int size) {
1414 EnsureSpace ensure_space(
this);
1417 if (!src.is_byte_register()) {
1419 emit_rex_32(dst, src);
1421 emit_optional_rex_32(dst, src);
1425 emit_modrm(dst, src);
1429 void Assembler::emit_movzxw(Register dst,
const Operand& src,
int size) {
1430 EnsureSpace ensure_space(
this);
1433 emit_optional_rex_32(dst, src);
1436 emit_operand(dst, src);
1440 void Assembler::emit_movzxw(Register dst, Register src,
int size) {
1441 EnsureSpace ensure_space(
this);
1444 emit_optional_rex_32(dst, src);
1447 emit_modrm(dst, src);
1451 void Assembler::repmovsb() {
1452 EnsureSpace ensure_space(
this);
1458 void Assembler::repmovsw() {
1459 EnsureSpace ensure_space(
this);
1466 void Assembler::emit_repmovs(
int size) {
1467 EnsureSpace ensure_space(
this);
1474 void Assembler::mul(Register src) {
1475 EnsureSpace ensure_space(
this);
1478 emit_modrm(0x4, src);
1482 void Assembler::emit_neg(Register dst,
int size) {
1483 EnsureSpace ensure_space(
this);
1484 emit_rex(dst,
size);
1486 emit_modrm(0x3, dst);
1490 void Assembler::emit_neg(
const Operand& dst,
int size) {
1491 EnsureSpace ensure_space(
this);
1494 emit_operand(3, dst);
1498 void Assembler::nop() {
1499 EnsureSpace ensure_space(
this);
1504 void Assembler::emit_not(Register dst,
int size) {
1505 EnsureSpace ensure_space(
this);
1506 emit_rex(dst,
size);
1508 emit_modrm(0x2, dst);
1512 void Assembler::emit_not(
const Operand& dst,
int size) {
1513 EnsureSpace ensure_space(
this);
1514 emit_rex(dst,
size);
1516 emit_operand(2, dst);
1520 void Assembler::Nop(
int n) {
1535 EnsureSpace ensure_space(
this);
1597 void Assembler::popq(Register dst) {
1598 EnsureSpace ensure_space(
this);
1599 emit_optional_rex_32(dst);
1600 emit(0x58 | dst.low_bits());
1604 void Assembler::popq(
const Operand& dst) {
1605 EnsureSpace ensure_space(
this);
1606 emit_optional_rex_32(dst);
1608 emit_operand(0, dst);
1612 void Assembler::popfq() {
1613 EnsureSpace ensure_space(
this);
1618 void Assembler::pushq(Register src) {
1619 EnsureSpace ensure_space(
this);
1620 emit_optional_rex_32(src);
1621 emit(0x50 | src.low_bits());
1625 void Assembler::pushq(
const Operand& src) {
1626 EnsureSpace ensure_space(
this);
1627 emit_optional_rex_32(src);
1629 emit_operand(6, src);
1633 void Assembler::pushq(Immediate value) {
1634 EnsureSpace ensure_space(
this);
1635 if (is_int8(value.value_)) {
1640 emitl(value.value_);
1645 void Assembler::pushq_imm32(
int32_t imm32) {
1646 EnsureSpace ensure_space(
this);
1652 void Assembler::pushfq() {
1653 EnsureSpace ensure_space(
this);
1658 void Assembler::ret(
int imm16) {
1659 EnsureSpace ensure_space(
this);
1660 DCHECK(is_uint16(imm16));
1666 emit((imm16 >> 8) & 0xFF);
1671 void Assembler::setcc(
Condition cc, Register reg) {
1673 movb(reg, Immediate(
cc ==
always ? 1 : 0));
1676 EnsureSpace ensure_space(
this);
1678 if (!reg.is_byte_register()) {
1684 emit_modrm(0x0, reg);
1688 void Assembler::shld(Register dst, Register src) {
1689 EnsureSpace ensure_space(
this);
1690 emit_rex_64(src, dst);
1693 emit_modrm(src, dst);
1697 void Assembler::shrd(Register dst, Register src) {
1698 EnsureSpace ensure_space(
this);
1699 emit_rex_64(src, dst);
1702 emit_modrm(src, dst);
1706 void Assembler::emit_xchg(Register dst, Register src,
int size) {
1707 EnsureSpace ensure_space(
this);
1708 if (src.is(
rax) || dst.is(
rax)) {
1709 Register other = src.is(
rax) ? dst : src;
1710 emit_rex(other,
size);
1711 emit(0x90 | other.low_bits());
1712 }
else if (dst.low_bits() == 4) {
1713 emit_rex(dst, src,
size);
1715 emit_modrm(dst, src);
1717 emit_rex(src, dst,
size);
1719 emit_modrm(src, dst);
1724 void Assembler::emit_xchg(Register dst,
const Operand& src,
int size) {
1725 EnsureSpace ensure_space(
this);
1726 emit_rex(dst, src,
size);
1728 emit_operand(dst, src);
1732 void Assembler::store_rax(
void* dst, RelocInfo::Mode
mode) {
1733 EnsureSpace ensure_space(
this);
1750 void Assembler::store_rax(ExternalReference ref) {
1751 store_rax(ref.address(), RelocInfo::EXTERNAL_REFERENCE);
1755 void Assembler::testb(Register dst, Register src) {
1756 EnsureSpace ensure_space(
this);
1757 if (src.low_bits() == 4) {
1758 emit_rex_32(src, dst);
1760 emit_modrm(src, dst);
1762 if (!dst.is_byte_register() || !src.is_byte_register()) {
1764 emit_rex_32(dst, src);
1767 emit_modrm(dst, src);
1772 void Assembler::testb(Register reg, Immediate mask) {
1773 DCHECK(is_int8(mask.value_) || is_uint8(mask.value_));
1774 EnsureSpace ensure_space(
this);
1779 if (!reg.is_byte_register()) {
1784 emit_modrm(0x0, reg);
1790 void Assembler::testb(
const Operand& op, Immediate mask) {
1791 DCHECK(is_int8(mask.value_) || is_uint8(mask.value_));
1792 EnsureSpace ensure_space(
this);
1793 emit_optional_rex_32(
rax, op);
1795 emit_operand(
rax, op);
1800 void Assembler::testb(
const Operand& op, Register reg) {
1801 EnsureSpace ensure_space(
this);
1802 if (!reg.is_byte_register()) {
1804 emit_rex_32(reg, op);
1806 emit_optional_rex_32(reg, op);
1809 emit_operand(reg, op);
1813 void Assembler::emit_test(Register dst, Register src,
int size) {
1814 EnsureSpace ensure_space(
this);
1815 if (src.low_bits() == 4) {
1816 emit_rex(src, dst,
size);
1818 emit_modrm(src, dst);
1820 emit_rex(dst, src,
size);
1822 emit_modrm(dst, src);
1827 void Assembler::emit_test(Register reg, Immediate mask,
int size) {
1829 if (is_uint8(mask.value_)) {
1833 EnsureSpace ensure_space(
this);
1839 emit_rex(reg,
size);
1841 emit_modrm(0x0, reg);
1847 void Assembler::emit_test(
const Operand& op, Immediate mask,
int size) {
1849 if (is_uint8(mask.value_)) {
1853 EnsureSpace ensure_space(
this);
1856 emit_operand(
rax, op);
1861 void Assembler::emit_test(
const Operand& op, Register reg,
int size) {
1862 EnsureSpace ensure_space(
this);
1863 emit_rex(reg, op,
size);
1865 emit_operand(reg, op);
1872 void Assembler::fld(
int i) {
1873 EnsureSpace ensure_space(
this);
1874 emit_farith(0xD9, 0xC0,
i);
1878 void Assembler::fld1() {
1879 EnsureSpace ensure_space(
this);
1885 void Assembler::fldz() {
1886 EnsureSpace ensure_space(
this);
1892 void Assembler::fldpi() {
1893 EnsureSpace ensure_space(
this);
1899 void Assembler::fldln2() {
1900 EnsureSpace ensure_space(
this);
1906 void Assembler::fld_s(
const Operand& adr) {
1907 EnsureSpace ensure_space(
this);
1908 emit_optional_rex_32(adr);
1910 emit_operand(0, adr);
1914 void Assembler::fld_d(
const Operand& adr) {
1915 EnsureSpace ensure_space(
this);
1916 emit_optional_rex_32(adr);
1918 emit_operand(0, adr);
1922 void Assembler::fstp_s(
const Operand& adr) {
1923 EnsureSpace ensure_space(
this);
1924 emit_optional_rex_32(adr);
1926 emit_operand(3, adr);
1930 void Assembler::fstp_d(
const Operand& adr) {
1931 EnsureSpace ensure_space(
this);
1932 emit_optional_rex_32(adr);
1934 emit_operand(3, adr);
1938 void Assembler::fstp(
int index) {
1940 EnsureSpace ensure_space(
this);
1941 emit_farith(0xDD, 0xD8, index);
1945 void Assembler::fild_s(
const Operand& adr) {
1946 EnsureSpace ensure_space(
this);
1947 emit_optional_rex_32(adr);
1949 emit_operand(0, adr);
1953 void Assembler::fild_d(
const Operand& adr) {
1954 EnsureSpace ensure_space(
this);
1955 emit_optional_rex_32(adr);
1957 emit_operand(5, adr);
1961 void Assembler::fistp_s(
const Operand& adr) {
1962 EnsureSpace ensure_space(
this);
1963 emit_optional_rex_32(adr);
1965 emit_operand(3, adr);
1969 void Assembler::fisttp_s(
const Operand& adr) {
1971 EnsureSpace ensure_space(
this);
1972 emit_optional_rex_32(adr);
1974 emit_operand(1, adr);
1978 void Assembler::fisttp_d(
const Operand& adr) {
1980 EnsureSpace ensure_space(
this);
1981 emit_optional_rex_32(adr);
1983 emit_operand(1, adr);
1987 void Assembler::fist_s(
const Operand& adr) {
1988 EnsureSpace ensure_space(
this);
1989 emit_optional_rex_32(adr);
1991 emit_operand(2, adr);
1995 void Assembler::fistp_d(
const Operand& adr) {
1996 EnsureSpace ensure_space(
this);
1997 emit_optional_rex_32(adr);
1999 emit_operand(7, adr);
2003 void Assembler::fabs() {
2004 EnsureSpace ensure_space(
this);
2010 void Assembler::fchs() {
2011 EnsureSpace ensure_space(
this);
2017 void Assembler::fcos() {
2018 EnsureSpace ensure_space(
this);
2024 void Assembler::fsin() {
2025 EnsureSpace ensure_space(
this);
2031 void Assembler::fptan() {
2032 EnsureSpace ensure_space(
this);
2038 void Assembler::fyl2x() {
2039 EnsureSpace ensure_space(
this);
2045 void Assembler::f2xm1() {
2046 EnsureSpace ensure_space(
this);
2052 void Assembler::fscale() {
2053 EnsureSpace ensure_space(
this);
2059 void Assembler::fninit() {
2060 EnsureSpace ensure_space(
this);
2066 void Assembler::fadd(
int i) {
2067 EnsureSpace ensure_space(
this);
2068 emit_farith(0xDC, 0xC0,
i);
2072 void Assembler::fsub(
int i) {
2073 EnsureSpace ensure_space(
this);
2074 emit_farith(0xDC, 0xE8,
i);
2078 void Assembler::fisub_s(
const Operand& adr) {
2079 EnsureSpace ensure_space(
this);
2080 emit_optional_rex_32(adr);
2082 emit_operand(4, adr);
2086 void Assembler::fmul(
int i) {
2087 EnsureSpace ensure_space(
this);
2088 emit_farith(0xDC, 0xC8,
i);
2092 void Assembler::fdiv(
int i) {
2093 EnsureSpace ensure_space(
this);
2094 emit_farith(0xDC, 0xF8,
i);
2098 void Assembler::faddp(
int i) {
2099 EnsureSpace ensure_space(
this);
2100 emit_farith(0xDE, 0xC0,
i);
2104 void Assembler::fsubp(
int i) {
2105 EnsureSpace ensure_space(
this);
2106 emit_farith(0xDE, 0xE8,
i);
2110 void Assembler::fsubrp(
int i) {
2111 EnsureSpace ensure_space(
this);
2112 emit_farith(0xDE, 0xE0,
i);
2116 void Assembler::fmulp(
int i) {
2117 EnsureSpace ensure_space(
this);
2118 emit_farith(0xDE, 0xC8,
i);
2122 void Assembler::fdivp(
int i) {
2123 EnsureSpace ensure_space(
this);
2124 emit_farith(0xDE, 0xF8,
i);
2128 void Assembler::fprem() {
2129 EnsureSpace ensure_space(
this);
2135 void Assembler::fprem1() {
2136 EnsureSpace ensure_space(
this);
2142 void Assembler::fxch(
int i) {
2143 EnsureSpace ensure_space(
this);
2144 emit_farith(0xD9, 0xC8,
i);
2148 void Assembler::fincstp() {
2149 EnsureSpace ensure_space(
this);
2155 void Assembler::ffree(
int i) {
2156 EnsureSpace ensure_space(
this);
2157 emit_farith(0xDD, 0xC0,
i);
2161 void Assembler::ftst() {
2162 EnsureSpace ensure_space(
this);
2168 void Assembler::fucomp(
int i) {
2169 EnsureSpace ensure_space(
this);
2170 emit_farith(0xDD, 0xE8,
i);
2174 void Assembler::fucompp() {
2175 EnsureSpace ensure_space(
this);
2181 void Assembler::fucomi(
int i) {
2182 EnsureSpace ensure_space(
this);
2188 void Assembler::fucomip() {
2189 EnsureSpace ensure_space(
this);
2195 void Assembler::fcompp() {
2196 EnsureSpace ensure_space(
this);
2202 void Assembler::fnstsw_ax() {
2203 EnsureSpace ensure_space(
this);
2209 void Assembler::fwait() {
2210 EnsureSpace ensure_space(
this);
2215 void Assembler::frndint() {
2216 EnsureSpace ensure_space(
this);
2222 void Assembler::fnclex() {
2223 EnsureSpace ensure_space(
this);
2229 void Assembler::sahf() {
2233 EnsureSpace ensure_space(
this);
2238 void Assembler::emit_farith(
int b1,
int b2,
int i) {
2239 DCHECK(is_uint8(b1) && is_uint8(b2));
2248 void Assembler::andps(XMMRegister dst, XMMRegister src) {
2249 EnsureSpace ensure_space(
this);
2250 emit_optional_rex_32(dst, src);
2253 emit_sse_operand(dst, src);
2257 void Assembler::andps(XMMRegister dst,
const Operand& src) {
2258 EnsureSpace ensure_space(
this);
2259 emit_optional_rex_32(dst, src);
2262 emit_sse_operand(dst, src);
2266 void Assembler::orps(XMMRegister dst, XMMRegister src) {
2267 EnsureSpace ensure_space(
this);
2268 emit_optional_rex_32(dst, src);
2271 emit_sse_operand(dst, src);
2275 void Assembler::orps(XMMRegister dst,
const Operand& src) {
2276 EnsureSpace ensure_space(
this);
2277 emit_optional_rex_32(dst, src);
2280 emit_sse_operand(dst, src);
2284 void Assembler::xorps(XMMRegister dst, XMMRegister src) {
2285 EnsureSpace ensure_space(
this);
2286 emit_optional_rex_32(dst, src);
2289 emit_sse_operand(dst, src);
2293 void Assembler::xorps(XMMRegister dst,
const Operand& src) {
2294 EnsureSpace ensure_space(
this);
2295 emit_optional_rex_32(dst, src);
2298 emit_sse_operand(dst, src);
2302 void Assembler::addps(XMMRegister dst, XMMRegister src) {
2303 EnsureSpace ensure_space(
this);
2304 emit_optional_rex_32(dst, src);
2307 emit_sse_operand(dst, src);
2311 void Assembler::addps(XMMRegister dst,
const Operand& src) {
2312 EnsureSpace ensure_space(
this);
2313 emit_optional_rex_32(dst, src);
2316 emit_sse_operand(dst, src);
2320 void Assembler::subps(XMMRegister dst, XMMRegister src) {
2321 EnsureSpace ensure_space(
this);
2322 emit_optional_rex_32(dst, src);
2325 emit_sse_operand(dst, src);
2329 void Assembler::subps(XMMRegister dst,
const Operand& src) {
2330 EnsureSpace ensure_space(
this);
2331 emit_optional_rex_32(dst, src);
2334 emit_sse_operand(dst, src);
2338 void Assembler::mulps(XMMRegister dst, XMMRegister src) {
2339 EnsureSpace ensure_space(
this);
2340 emit_optional_rex_32(dst, src);
2343 emit_sse_operand(dst, src);
2347 void Assembler::mulps(XMMRegister dst,
const Operand& src) {
2348 EnsureSpace ensure_space(
this);
2349 emit_optional_rex_32(dst, src);
2352 emit_sse_operand(dst, src);
2356 void Assembler::divps(XMMRegister dst, XMMRegister src) {
2357 EnsureSpace ensure_space(
this);
2358 emit_optional_rex_32(dst, src);
2361 emit_sse_operand(dst, src);
2365 void Assembler::divps(XMMRegister dst,
const Operand& src) {
2366 EnsureSpace ensure_space(
this);
2367 emit_optional_rex_32(dst, src);
2370 emit_sse_operand(dst, src);
2376 void Assembler::movd(XMMRegister dst, Register src) {
2377 EnsureSpace ensure_space(
this);
2379 emit_optional_rex_32(dst, src);
2382 emit_sse_operand(dst, src);
2386 void Assembler::movd(Register dst, XMMRegister src) {
2387 EnsureSpace ensure_space(
this);
2389 emit_optional_rex_32(src, dst);
2392 emit_sse_operand(src, dst);
2396 void Assembler::movq(XMMRegister dst, Register src) {
2397 EnsureSpace ensure_space(
this);
2399 emit_rex_64(dst, src);
2402 emit_sse_operand(dst, src);
2406 void Assembler::movq(Register dst, XMMRegister src) {
2407 EnsureSpace ensure_space(
this);
2409 emit_rex_64(src, dst);
2412 emit_sse_operand(src, dst);
2416 void Assembler::movq(XMMRegister dst, XMMRegister src) {
2417 EnsureSpace ensure_space(
this);
2418 if (dst.low_bits() == 4) {
2421 emit_optional_rex_32(dst, src);
2424 emit_sse_operand(dst, src);
2427 emit_optional_rex_32(src, dst);
2430 emit_sse_operand(src, dst);
2435 void Assembler::movdqa(
const Operand& dst, XMMRegister src) {
2436 EnsureSpace ensure_space(
this);
2438 emit_rex_64(src, dst);
2441 emit_sse_operand(src, dst);
2445 void Assembler::movdqa(XMMRegister dst,
const Operand& src) {
2446 EnsureSpace ensure_space(
this);
2448 emit_rex_64(dst, src);
2451 emit_sse_operand(dst, src);
2455 void Assembler::movdqu(
const Operand& dst, XMMRegister src) {
2456 EnsureSpace ensure_space(
this);
2458 emit_rex_64(src, dst);
2461 emit_sse_operand(src, dst);
2465 void Assembler::movdqu(XMMRegister dst,
const Operand& src) {
2466 EnsureSpace ensure_space(
this);
2468 emit_rex_64(dst, src);
2471 emit_sse_operand(dst, src);
2475 void Assembler::extractps(Register dst, XMMRegister src,
byte imm8) {
2478 EnsureSpace ensure_space(
this);
2480 emit_optional_rex_32(src, dst);
2484 emit_sse_operand(src, dst);
2489 void Assembler::movsd(
const Operand& dst, XMMRegister src) {
2490 EnsureSpace ensure_space(
this);
2492 emit_optional_rex_32(src, dst);
2495 emit_sse_operand(src, dst);
2499 void Assembler::movsd(XMMRegister dst, XMMRegister src) {
2500 EnsureSpace ensure_space(
this);
2502 emit_optional_rex_32(dst, src);
2505 emit_sse_operand(dst, src);
2509 void Assembler::movsd(XMMRegister dst,
const Operand& src) {
2510 EnsureSpace ensure_space(
this);
2512 emit_optional_rex_32(dst, src);
2515 emit_sse_operand(dst, src);
2519 void Assembler::movaps(XMMRegister dst, XMMRegister src) {
2520 EnsureSpace ensure_space(
this);
2521 if (src.low_bits() == 4) {
2523 emit_optional_rex_32(src, dst);
2526 emit_sse_operand(src, dst);
2528 emit_optional_rex_32(dst, src);
2531 emit_sse_operand(dst, src);
2536 void Assembler::shufps(XMMRegister dst, XMMRegister src,
byte imm8) {
2538 EnsureSpace ensure_space(
this);
2539 emit_optional_rex_32(src, dst);
2542 emit_sse_operand(dst, src);
2547 void Assembler::movapd(XMMRegister dst, XMMRegister src) {
2548 EnsureSpace ensure_space(
this);
2549 if (src.low_bits() == 4) {
2552 emit_optional_rex_32(src, dst);
2555 emit_sse_operand(src, dst);
2558 emit_optional_rex_32(dst, src);
2561 emit_sse_operand(dst, src);
2566 void Assembler::movss(XMMRegister dst,
const Operand& src) {
2567 EnsureSpace ensure_space(
this);
2569 emit_optional_rex_32(dst, src);
2572 emit_sse_operand(dst, src);
2576 void Assembler::movss(
const Operand& src, XMMRegister dst) {
2577 EnsureSpace ensure_space(
this);
2579 emit_optional_rex_32(dst, src);
2582 emit_sse_operand(dst, src);
2586 void Assembler::psllq(XMMRegister reg,
byte imm8) {
2587 EnsureSpace ensure_space(
this);
2591 emit_sse_operand(
rsi, reg);
2596 void Assembler::cvttss2si(Register dst,
const Operand& src) {
2597 EnsureSpace ensure_space(
this);
2599 emit_optional_rex_32(dst, src);
2602 emit_operand(dst, src);
2606 void Assembler::cvttss2si(Register dst, XMMRegister src) {
2607 EnsureSpace ensure_space(
this);
2609 emit_optional_rex_32(dst, src);
2612 emit_sse_operand(dst, src);
2616 void Assembler::cvttsd2si(Register dst,
const Operand& src) {
2617 EnsureSpace ensure_space(
this);
2619 emit_optional_rex_32(dst, src);
2622 emit_operand(dst, src);
2626 void Assembler::cvttsd2si(Register dst, XMMRegister src) {
2627 EnsureSpace ensure_space(
this);
2629 emit_optional_rex_32(dst, src);
2632 emit_sse_operand(dst, src);
2636 void Assembler::cvttsd2siq(Register dst, XMMRegister src) {
2637 EnsureSpace ensure_space(
this);
2639 emit_rex_64(dst, src);
2642 emit_sse_operand(dst, src);
2646 void Assembler::cvttsd2siq(Register dst,
const Operand& src) {
2647 EnsureSpace ensure_space(
this);
2649 emit_rex_64(dst, src);
2652 emit_sse_operand(dst, src);
2656 void Assembler::cvtlsi2sd(XMMRegister dst,
const Operand& src) {
2657 EnsureSpace ensure_space(
this);
2659 emit_optional_rex_32(dst, src);
2662 emit_sse_operand(dst, src);
2666 void Assembler::cvtlsi2sd(XMMRegister dst, Register src) {
2667 EnsureSpace ensure_space(
this);
2669 emit_optional_rex_32(dst, src);
2672 emit_sse_operand(dst, src);
2676 void Assembler::cvtlsi2ss(XMMRegister dst, Register src) {
2677 EnsureSpace ensure_space(
this);
2679 emit_optional_rex_32(dst, src);
2682 emit_sse_operand(dst, src);
2686 void Assembler::cvtqsi2sd(XMMRegister dst, Register src) {
2687 EnsureSpace ensure_space(
this);
2689 emit_rex_64(dst, src);
2692 emit_sse_operand(dst, src);
2696 void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) {
2697 EnsureSpace ensure_space(
this);
2699 emit_optional_rex_32(dst, src);
2702 emit_sse_operand(dst, src);
2706 void Assembler::cvtss2sd(XMMRegister dst,
const Operand& src) {
2707 EnsureSpace ensure_space(
this);
2709 emit_optional_rex_32(dst, src);
2712 emit_sse_operand(dst, src);
2716 void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) {
2717 EnsureSpace ensure_space(
this);
2719 emit_optional_rex_32(dst, src);
2722 emit_sse_operand(dst, src);
2726 void Assembler::cvtsd2si(Register dst, XMMRegister src) {
2727 EnsureSpace ensure_space(
this);
2729 emit_optional_rex_32(dst, src);
2732 emit_sse_operand(dst, src);
2736 void Assembler::cvtsd2siq(Register dst, XMMRegister src) {
2737 EnsureSpace ensure_space(
this);
2739 emit_rex_64(dst, src);
2742 emit_sse_operand(dst, src);
2746 void Assembler::addsd(XMMRegister dst, XMMRegister src) {
2747 EnsureSpace ensure_space(
this);
2749 emit_optional_rex_32(dst, src);
2752 emit_sse_operand(dst, src);
2756 void Assembler::addsd(XMMRegister dst,
const Operand& src) {
2757 EnsureSpace ensure_space(
this);
2759 emit_optional_rex_32(dst, src);
2762 emit_sse_operand(dst, src);
2766 void Assembler::mulsd(XMMRegister dst, XMMRegister src) {
2767 EnsureSpace ensure_space(
this);
2769 emit_optional_rex_32(dst, src);
2772 emit_sse_operand(dst, src);
2776 void Assembler::mulsd(XMMRegister dst,
const Operand& src) {
2777 EnsureSpace ensure_space(
this);
2779 emit_optional_rex_32(dst, src);
2782 emit_sse_operand(dst, src);
2786 void Assembler::subsd(XMMRegister dst, XMMRegister src) {
2787 EnsureSpace ensure_space(
this);
2789 emit_optional_rex_32(dst, src);
2792 emit_sse_operand(dst, src);
2796 void Assembler::divsd(XMMRegister dst, XMMRegister src) {
2797 EnsureSpace ensure_space(
this);
2799 emit_optional_rex_32(dst, src);
2802 emit_sse_operand(dst, src);
2806 void Assembler::andpd(XMMRegister dst, XMMRegister src) {
2807 EnsureSpace ensure_space(
this);
2809 emit_optional_rex_32(dst, src);
2812 emit_sse_operand(dst, src);
2816 void Assembler::orpd(XMMRegister dst, XMMRegister src) {
2817 EnsureSpace ensure_space(
this);
2819 emit_optional_rex_32(dst, src);
2822 emit_sse_operand(dst, src);
2826 void Assembler::xorpd(XMMRegister dst, XMMRegister src) {
2827 EnsureSpace ensure_space(
this);
2829 emit_optional_rex_32(dst, src);
2832 emit_sse_operand(dst, src);
2836 void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) {
2837 EnsureSpace ensure_space(
this);
2839 emit_optional_rex_32(dst, src);
2842 emit_sse_operand(dst, src);
2846 void Assembler::sqrtsd(XMMRegister dst,
const Operand& src) {
2847 EnsureSpace ensure_space(
this);
2849 emit_optional_rex_32(dst, src);
2852 emit_sse_operand(dst, src);
2856 void Assembler::ucomisd(XMMRegister dst, XMMRegister src) {
2857 EnsureSpace ensure_space(
this);
2859 emit_optional_rex_32(dst, src);
2862 emit_sse_operand(dst, src);
2866 void Assembler::ucomisd(XMMRegister dst,
const Operand& src) {
2867 EnsureSpace ensure_space(
this);
2869 emit_optional_rex_32(dst, src);
2872 emit_sse_operand(dst, src);
2876 void Assembler::cmpltsd(XMMRegister dst, XMMRegister src) {
2877 EnsureSpace ensure_space(
this);
2879 emit_optional_rex_32(dst, src);
2882 emit_sse_operand(dst, src);
2887 void Assembler::roundsd(XMMRegister dst, XMMRegister src,
2888 Assembler::RoundingMode
mode) {
2890 EnsureSpace ensure_space(
this);
2892 emit_optional_rex_32(dst, src);
2896 emit_sse_operand(dst, src);
2898 emit(
static_cast<byte>(
mode) | 0x8);
2902 void Assembler::movmskpd(Register dst, XMMRegister src) {
2903 EnsureSpace ensure_space(
this);
2905 emit_optional_rex_32(dst, src);
2908 emit_sse_operand(dst, src);
2912 void Assembler::movmskps(Register dst, XMMRegister src) {
2913 EnsureSpace ensure_space(
this);
2914 emit_optional_rex_32(dst, src);
2917 emit_sse_operand(dst, src);
2921 void Assembler::emit_sse_operand(XMMRegister reg,
const Operand& adr) {
2922 Register ireg = { reg.code() };
2923 emit_operand(ireg, adr);
2927 void Assembler::emit_sse_operand(Register reg,
const Operand& adr) {
2928 Register ireg = {reg.code()};
2929 emit_operand(ireg, adr);
2933 void Assembler::emit_sse_operand(XMMRegister dst, XMMRegister src) {
2934 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits());
2938 void Assembler::emit_sse_operand(XMMRegister dst, Register src) {
2939 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits());
2943 void Assembler::emit_sse_operand(Register dst, XMMRegister src) {
2944 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits());
2949 EnsureSpace ensure_space(
this);
2954 void Assembler::dd(
uint32_t data) {
2955 EnsureSpace ensure_space(
this);
2962 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
2963 DCHECK(!RelocInfo::IsNone(rmode));
2965 if (rmode == RelocInfo::EXTERNAL_REFERENCE &&
2966 !serializer_enabled() && !emit_debug_code()) {
2968 }
else if (rmode == RelocInfo::CODE_AGE_SEQUENCE) {
2972 RelocInfo rinfo(pc_, rmode, data,
NULL);
2973 reloc_info_writer.Write(&rinfo);
2977 void Assembler::RecordJSReturn() {
2978 positions_recorder()->WriteRecordedPositions();
2979 EnsureSpace ensure_space(
this);
2980 RecordRelocInfo(RelocInfo::JS_RETURN);
2984 void Assembler::RecordDebugBreakSlot() {
2985 positions_recorder()->WriteRecordedPositions();
2986 EnsureSpace ensure_space(
this);
2987 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT);
2991 void Assembler::RecordComment(
const char* msg,
bool force) {
2992 if (FLAG_code_comments || force) {
2993 EnsureSpace ensure_space(
this);
2994 RecordRelocInfo(RelocInfo::COMMENT,
reinterpret_cast<intptr_t
>(msg));
2999 Handle<ConstantPoolArray> Assembler::NewConstantPool(Isolate* isolate) {
3001 DCHECK(!FLAG_enable_ool_constant_pool);
3002 return isolate->factory()->empty_constant_pool_array();
3006 void Assembler::PopulateConstantPool(ConstantPoolArray* constant_pool) {
3008 DCHECK(!FLAG_enable_ool_constant_pool);
3013 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask |
3015 1 << RelocInfo::INTERNAL_REFERENCE |
3016 1 << RelocInfo::CODE_AGE_SEQUENCE;
3019 bool RelocInfo::IsCodedSpecially() {
3023 return (1 << rmode_) & kApplyMask;
3027 bool RelocInfo::IsInConstantPool() {
static const int kCallSequenceLength
static RelocInfo::Mode RelocInfoNone()
static void FlushICache(void *start, size_t size)
static unsigned supported_
static void PrintFeatures()
static void PrintTarget()
static void ProbeImpl(bool cross_compile)
Operand(Register reg, Shift shift=LSL, unsigned shift_amount=0)
void PatchCode(byte *instructions, int instruction_count)
void PatchCodeWithCall(Address target, int guard_bytes)
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
enable harmony numeric enable harmony object literal extensions Optimize object Array shift
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
bool IsPowerOfTwo32(uint32_t value)
void DeleteArray(T *array)
const Register kScratchRegister
void MemMove(void *dest, const void *src, size_t size)
void FatalProcessOutOfMemory(const char *message)
Debugger support for the V8 JavaScript engine.
static const uint16_t * Align(const uint16_t *chars)
#define RUNTIME_ENTRY(name, nargs, ressize)
static const int kAllocationIndexByRegisterCode[kNumRegisters]
static const int kRegisterCodeByAllocationIndex[kMaxNumAllocatableRegisters]