Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: src/x64/assembler-x64.h

Issue 165443: X64: Implement RegExp natively. (Closed)
Patch Set: Addressed review comments. Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 void movb(Register dst, Immediate imm); 489 void movb(Register dst, Immediate imm);
490 void movb(const Operand& dst, Register src); 490 void movb(const Operand& dst, Register src);
491 491
492 void movl(Register dst, Register src); 492 void movl(Register dst, Register src);
493 void movl(Register dst, const Operand& src); 493 void movl(Register dst, const Operand& src);
494 void movl(const Operand& dst, Register src); 494 void movl(const Operand& dst, Register src);
495 void movl(const Operand& dst, Immediate imm); 495 void movl(const Operand& dst, Immediate imm);
496 // Load a 32-bit immediate value, zero-extended to 64 bits. 496 // Load a 32-bit immediate value, zero-extended to 64 bits.
497 void movl(Register dst, Immediate imm32); 497 void movl(Register dst, Immediate imm32);
498 498
499 // Move 64 bit register value to 64-bit memory location.
500 void movq(const Operand& dst, Register src);
501 // Move 64 bit memory location to 64-bit register value.
499 void movq(Register dst, const Operand& src); 502 void movq(Register dst, const Operand& src);
503 void movq(Register dst, Register src);
500 // Sign extends immediate 32-bit value to 64 bits. 504 // Sign extends immediate 32-bit value to 64 bits.
501 void movq(Register dst, Immediate x); 505 void movq(Register dst, Immediate x);
502 void movq(Register dst, Register src); 506 // Move the offset of the label location relative to the current
507 // position (after the move) to the destination.
508 void movl(const Operand& dst, Label* src);
503 509
504 // Move 64 bit register value to 64-bit memory location.
505 void movq(const Operand& dst, Register src);
506 // Move sign extended immediate to memory location. 510 // Move sign extended immediate to memory location.
507 void movq(const Operand& dst, Immediate value); 511 void movq(const Operand& dst, Immediate value);
508 // New x64 instructions to load a 64-bit immediate into a register. 512 // New x64 instructions to load a 64-bit immediate into a register.
509 // All 64-bit immediates must have a relocation mode. 513 // All 64-bit immediates must have a relocation mode.
510 void movq(Register dst, void* ptr, RelocInfo::Mode rmode); 514 void movq(Register dst, void* ptr, RelocInfo::Mode rmode);
511 void movq(Register dst, int64_t value, RelocInfo::Mode rmode); 515 void movq(Register dst, int64_t value, RelocInfo::Mode rmode);
512 void movq(Register dst, const char* s, RelocInfo::Mode rmode); 516 void movq(Register dst, const char* s, RelocInfo::Mode rmode);
513 // Moves the address of the external reference into the register. 517 // Moves the address of the external reference into the register.
514 void movq(Register dst, ExternalReference ext); 518 void movq(Register dst, ExternalReference ext);
515 void movq(Register dst, Handle<Object> handle, RelocInfo::Mode rmode); 519 void movq(Register dst, Handle<Object> handle, RelocInfo::Mode rmode);
(...skipping 12 matching lines...) Expand all
528 void cmovq(Condition cc, Register dst, Register src); 532 void cmovq(Condition cc, Register dst, Register src);
529 void cmovq(Condition cc, Register dst, const Operand& src); 533 void cmovq(Condition cc, Register dst, const Operand& src);
530 void cmovl(Condition cc, Register dst, Register src); 534 void cmovl(Condition cc, Register dst, Register src);
531 void cmovl(Condition cc, Register dst, const Operand& src); 535 void cmovl(Condition cc, Register dst, const Operand& src);
532 536
533 // Exchange two registers 537 // Exchange two registers
534 void xchg(Register dst, Register src); 538 void xchg(Register dst, Register src);
535 539
536 // Arithmetics 540 // Arithmetics
537 void addl(Register dst, Register src) { 541 void addl(Register dst, Register src) {
538 arithmetic_op_32(0x03, dst, src); 542 if (dst.low_bits() == 4) { // Forces SIB byte.
543 arithmetic_op_32(0x01, src, dst);
544 } else {
545 arithmetic_op_32(0x03, dst, src);
546 }
539 } 547 }
540 548
541 void addl(Register dst, Immediate src) { 549 void addl(Register dst, Immediate src) {
542 immediate_arithmetic_op_32(0x0, dst, src); 550 immediate_arithmetic_op_32(0x0, dst, src);
543 } 551 }
544 552
545 void addl(Register dst, const Operand& src) { 553 void addl(Register dst, const Operand& src) {
546 arithmetic_op_32(0x03, dst, src); 554 arithmetic_op_32(0x03, dst, src);
547 } 555 }
548 556
(...skipping 18 matching lines...) Expand all
567 } 575 }
568 576
569 void addq(const Operand& dst, Immediate src) { 577 void addq(const Operand& dst, Immediate src) {
570 immediate_arithmetic_op(0x0, dst, src); 578 immediate_arithmetic_op(0x0, dst, src);
571 } 579 }
572 580
573 void cmpb(Register dst, Immediate src) { 581 void cmpb(Register dst, Immediate src) {
574 immediate_arithmetic_op_8(0x7, dst, src); 582 immediate_arithmetic_op_8(0x7, dst, src);
575 } 583 }
576 584
585 void cmpb_al(Immediate src);
586
587 void cmpb(Register dst, Register src) {
588 arithmetic_op(0x3A, dst, src);
589 }
590
591 void cmpb(Register dst, const Operand& src) {
592 arithmetic_op(0x3A, dst, src);
593 }
594
595 void cmpb(const Operand& dst, Register src) {
596 arithmetic_op(0x38, src, dst);
597 }
598
577 void cmpb(const Operand& dst, Immediate src) { 599 void cmpb(const Operand& dst, Immediate src) {
578 immediate_arithmetic_op_8(0x7, dst, src); 600 immediate_arithmetic_op_8(0x7, dst, src);
579 } 601 }
580 602
603 void cmpw(const Operand& dst, Immediate src) {
604 immediate_arithmetic_op_16(0x7, dst, src);
605 }
606
607 void cmpw(Register dst, Immediate src) {
608 immediate_arithmetic_op_16(0x7, dst, src);
609 }
610
611 void cmpw(Register dst, const Operand& src) {
612 arithmetic_op_16(0x3B, dst, src);
613 }
614
615 void cmpw(Register dst, Register src) {
616 arithmetic_op_16(0x3B, dst, src);
617 }
618
619 void cmpw(const Operand& dst, Register src) {
620 arithmetic_op_16(0x39, src, dst);
621 }
622
581 void cmpl(Register dst, Register src) { 623 void cmpl(Register dst, Register src) {
582 arithmetic_op_32(0x3B, dst, src); 624 arithmetic_op_32(0x3B, dst, src);
583 } 625 }
584 626
585 void cmpl(Register dst, const Operand& src) { 627 void cmpl(Register dst, const Operand& src) {
586 arithmetic_op_32(0x3B, dst, src); 628 arithmetic_op_32(0x3B, dst, src);
587 } 629 }
588 630
589 void cmpl(const Operand& dst, Register src) { 631 void cmpl(const Operand& dst, Register src) {
590 arithmetic_op_32(0x39, src, dst); 632 arithmetic_op_32(0x39, src, dst);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } 829 }
788 830
789 void subl(const Operand& dst, Immediate src) { 831 void subl(const Operand& dst, Immediate src) {
790 immediate_arithmetic_op_32(0x5, dst, src); 832 immediate_arithmetic_op_32(0x5, dst, src);
791 } 833 }
792 834
793 void subl(Register dst, Immediate src) { 835 void subl(Register dst, Immediate src) {
794 immediate_arithmetic_op_32(0x5, dst, src); 836 immediate_arithmetic_op_32(0x5, dst, src);
795 } 837 }
796 838
839 void subb(Register dst, Immediate src) {
840 immediate_arithmetic_op_8(0x5, dst, src);
841 }
842
797 void testb(Register reg, Immediate mask); 843 void testb(Register reg, Immediate mask);
798 void testb(const Operand& op, Immediate mask); 844 void testb(const Operand& op, Immediate mask);
799 void testl(Register dst, Register src); 845 void testl(Register dst, Register src);
800 void testl(Register reg, Immediate mask); 846 void testl(Register reg, Immediate mask);
801 void testl(const Operand& op, Immediate mask); 847 void testl(const Operand& op, Immediate mask);
802 void testq(const Operand& op, Register reg); 848 void testq(const Operand& op, Register reg);
803 void testq(Register dst, Register src); 849 void testq(Register dst, Register src);
804 void testq(Register dst, Immediate mask); 850 void testq(Register dst, Immediate mask);
805 851
806 void xor_(Register dst, Register src) { 852 void xor_(Register dst, Register src) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 emit(0xC0 | code << 3 | rm_reg.low_bits()); 1180 emit(0xC0 | code << 3 | rm_reg.low_bits());
1135 } 1181 }
1136 1182
1137 // Emit the code-object-relative offset of the label's position 1183 // Emit the code-object-relative offset of the label's position
1138 inline void emit_code_relative_offset(Label* label); 1184 inline void emit_code_relative_offset(Label* label);
1139 1185
1140 // Emit machine code for one of the operations ADD, ADC, SUB, SBC, 1186 // Emit machine code for one of the operations ADD, ADC, SUB, SBC,
1141 // AND, OR, XOR, or CMP. The encodings of these operations are all 1187 // AND, OR, XOR, or CMP. The encodings of these operations are all
1142 // similar, differing just in the opcode or in the reg field of the 1188 // similar, differing just in the opcode or in the reg field of the
1143 // ModR/M byte. 1189 // ModR/M byte.
1144 void arithmetic_op(byte opcode, Register dst, Register src); 1190 void arithmetic_op_16(byte opcode, Register reg, Register rm_reg);
1145 void arithmetic_op_32(byte opcode, Register dst, Register src); 1191 void arithmetic_op_16(byte opcode, Register reg, const Operand& rm_reg);
1192 void arithmetic_op_32(byte opcode, Register reg, Register rm_reg);
1146 void arithmetic_op_32(byte opcode, Register reg, const Operand& rm_reg); 1193 void arithmetic_op_32(byte opcode, Register reg, const Operand& rm_reg);
1194 void arithmetic_op(byte opcode, Register reg, Register rm_reg);
1147 void arithmetic_op(byte opcode, Register reg, const Operand& rm_reg); 1195 void arithmetic_op(byte opcode, Register reg, const Operand& rm_reg);
1148 void immediate_arithmetic_op(byte subcode, Register dst, Immediate src); 1196 void immediate_arithmetic_op(byte subcode, Register dst, Immediate src);
1149 void immediate_arithmetic_op(byte subcode, const Operand& dst, Immediate src); 1197 void immediate_arithmetic_op(byte subcode, const Operand& dst, Immediate src);
1198 // Operate on a byte in memory or register.
1199 void immediate_arithmetic_op_8(byte subcode,
1200 Register dst,
1201 Immediate src);
1202 void immediate_arithmetic_op_8(byte subcode,
1203 const Operand& dst,
1204 Immediate src);
1205 // Operate on a word in memory or register.
1206 void immediate_arithmetic_op_16(byte subcode,
1207 Register dst,
1208 Immediate src);
1209 void immediate_arithmetic_op_16(byte subcode,
1210 const Operand& dst,
1211 Immediate src);
1150 // Operate on a 32-bit word in memory or register. 1212 // Operate on a 32-bit word in memory or register.
1151 void immediate_arithmetic_op_32(byte subcode, 1213 void immediate_arithmetic_op_32(byte subcode,
1214 Register dst,
1215 Immediate src);
1216 void immediate_arithmetic_op_32(byte subcode,
1152 const Operand& dst, 1217 const Operand& dst,
1153 Immediate src); 1218 Immediate src);
1154 void immediate_arithmetic_op_32(byte subcode, 1219
1155 Register dst,
1156 Immediate src);
1157 // Operate on a byte in memory or register.
1158 void immediate_arithmetic_op_8(byte subcode,
1159 const Operand& dst,
1160 Immediate src);
1161 void immediate_arithmetic_op_8(byte subcode,
1162 Register dst,
1163 Immediate src);
1164 // Emit machine code for a shift operation. 1220 // Emit machine code for a shift operation.
1165 void shift(Register dst, Immediate shift_amount, int subcode); 1221 void shift(Register dst, Immediate shift_amount, int subcode);
1166 void shift_32(Register dst, Immediate shift_amount, int subcode); 1222 void shift_32(Register dst, Immediate shift_amount, int subcode);
1167 // Shift dst by cl % 64 bits. 1223 // Shift dst by cl % 64 bits.
1168 void shift(Register dst, int subcode); 1224 void shift(Register dst, int subcode);
1169 void shift_32(Register dst, int subcode); 1225 void shift_32(Register dst, int subcode);
1170 1226
1171 void emit_farith(int b1, int b2, int i); 1227 void emit_farith(int b1, int b2, int i);
1172 1228
1173 // labels 1229 // labels
1174 // void print(Label* L); 1230 // void print(Label* L);
1175 void bind_to(Label* L, int pos); 1231 void bind_to(Label* L, int pos);
1176 void link_to(Label* L, Label* appendix); 1232 void link_to(Label* L, Label* appendix);
1177 1233
1178 // record reloc info for current pc_ 1234 // record reloc info for current pc_
1179 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); 1235 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0);
1180 1236
1181 friend class CodePatcher; 1237 friend class CodePatcher;
1182 friend class EnsureSpace; 1238 friend class EnsureSpace;
1239 friend class RegExpMacroAssemblerX64;
1183 1240
1184 // Code buffer: 1241 // Code buffer:
1185 // The buffer into which code and relocation info are generated. 1242 // The buffer into which code and relocation info are generated.
1186 byte* buffer_; 1243 byte* buffer_;
1187 int buffer_size_; 1244 int buffer_size_;
1188 // True if the assembler owns the buffer, false if buffer is external. 1245 // True if the assembler owns the buffer, false if buffer is external.
1189 bool own_buffer_; 1246 bool own_buffer_;
1190 // A previously allocated buffer of kMinimalBufferSize bytes, or NULL. 1247 // A previously allocated buffer of kMinimalBufferSize bytes, or NULL.
1191 static byte* spare_buffer_; 1248 static byte* spare_buffer_;
1192 1249
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 private: 1285 private:
1229 Assembler* assembler_; 1286 Assembler* assembler_;
1230 #ifdef DEBUG 1287 #ifdef DEBUG
1231 int space_before_; 1288 int space_before_;
1232 #endif 1289 #endif
1233 }; 1290 };
1234 1291
1235 } } // namespace v8::internal 1292 } } // namespace v8::internal
1236 1293
1237 #endif // V8_X64_ASSEMBLER_X64_H_ 1294 #endif // V8_X64_ASSEMBLER_X64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698