OLD | NEW |
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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 void imul(Register dst, Register src, int32_t imm32); | 521 void imul(Register dst, Register src, int32_t imm32); |
522 | 522 |
523 void inc(Register dst); | 523 void inc(Register dst); |
524 void inc(const Operand& dst); | 524 void inc(const Operand& dst); |
525 | 525 |
526 void lea(Register dst, const Operand& src); | 526 void lea(Register dst, const Operand& src); |
527 | 527 |
528 void mul(Register src); | 528 void mul(Register src); |
529 | 529 |
530 void neg(Register dst); | 530 void neg(Register dst); |
| 531 void neg(const Operand& dst); |
531 | 532 |
532 void not_(Register dst); | 533 void not_(Register dst); |
| 534 void not_(const Operand& dst); |
533 | 535 |
534 void or_(Register dst, Register src) { | 536 void or_(Register dst, Register src) { |
535 arithmetic_op(0x0B, dst, src); | 537 arithmetic_op(0x0B, dst, src); |
536 } | 538 } |
537 | 539 |
538 void or_(Register dst, const Operand& src) { | 540 void or_(Register dst, const Operand& src) { |
539 arithmetic_op(0x0B, dst, src); | 541 arithmetic_op(0x0B, dst, src); |
540 } | 542 } |
541 | 543 |
542 void or_(const Operand& dst, Register src) { | 544 void or_(const Operand& dst, Register src) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 } | 585 } |
584 | 586 |
585 void sub(Register dst, Immediate src) { | 587 void sub(Register dst, Immediate src) { |
586 immediate_arithmetic_op(0x5, dst, src); | 588 immediate_arithmetic_op(0x5, dst, src); |
587 } | 589 } |
588 | 590 |
589 void sub(const Operand& dst, Immediate src) { | 591 void sub(const Operand& dst, Immediate src) { |
590 immediate_arithmetic_op(0x5, dst, src); | 592 immediate_arithmetic_op(0x5, dst, src); |
591 } | 593 } |
592 | 594 |
593 | 595 void testb(Register reg, Immediate mask); |
594 void test(Register reg, const Immediate& imm); | 596 void testb(const Operand& op, Immediate mask); |
595 void test(Register reg, const Operand& op); | 597 void testl(Register reg, Immediate mask); |
596 void test(const Operand& op, const Immediate& imm); | 598 void testl(const Operand& op, Immediate mask); |
597 | 599 |
598 void xor_(Register dst, Register src) { | 600 void xor_(Register dst, Register src) { |
599 arithmetic_op(0x33, dst, src); | 601 arithmetic_op(0x33, dst, src); |
600 } | 602 } |
601 | 603 |
602 void xor_(Register dst, const Operand& src) { | 604 void xor_(Register dst, const Operand& src) { |
603 arithmetic_op(0x33, dst, src); | 605 arithmetic_op(0x33, dst, src); |
604 } | 606 } |
605 | 607 |
606 void xor_(const Operand& dst, Register src) { | 608 void xor_(const Operand& dst, Register src) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 void RecordJSReturn(); | 747 void RecordJSReturn(); |
746 | 748 |
747 // Record a comment relocation entry that can be used by a disassembler. | 749 // Record a comment relocation entry that can be used by a disassembler. |
748 // Use --debug_code to enable. | 750 // Use --debug_code to enable. |
749 void RecordComment(const char* msg); | 751 void RecordComment(const char* msg); |
750 | 752 |
751 void RecordPosition(int pos); | 753 void RecordPosition(int pos); |
752 void RecordStatementPosition(int pos); | 754 void RecordStatementPosition(int pos); |
753 void WriteRecordedPositions(); | 755 void WriteRecordedPositions(); |
754 | 756 |
755 // Writes a single word of data in the code stream. | 757 // Writes a doubleword of data in the code stream. |
756 // Used for inline tables, e.g., jump-tables. | 758 // Used for inline tables, e.g., jump-tables. |
757 void dd(uint32_t data, RelocInfo::Mode reloc_info); | 759 void dd(uint32_t data); |
| 760 |
| 761 // Writes a quadword of data in the code stream. |
| 762 // Used for inline tables, e.g., jump-tables. |
| 763 void dd(uint64_t data, RelocInfo::Mode reloc_info); |
758 | 764 |
759 // Writes the absolute address of a bound label at the given position in | 765 // Writes the absolute address of a bound label at the given position in |
760 // the generated code. That positions should have the relocation mode | 766 // the generated code. That positions should have the relocation mode |
761 // internal_reference! | 767 // internal_reference! |
762 void WriteInternalReference(int position, const Label& bound_label); | 768 void WriteInternalReference(int position, const Label& bound_label); |
763 | 769 |
764 int pc_offset() const { return pc_ - buffer_; } | 770 int pc_offset() const { return pc_ - buffer_; } |
765 int current_statement_position() const { return current_statement_position_; } | 771 int current_statement_position() const { return current_statement_position_; } |
766 int current_position() const { return current_position_; } | 772 int current_position() const { return current_position_; } |
767 | 773 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 inline void emitl(uint32_t x); | 808 inline void emitl(uint32_t x); |
803 inline void emit(Handle<Object> handle); | 809 inline void emit(Handle<Object> handle); |
804 inline void emitq(uint64_t x, RelocInfo::Mode rmode); | 810 inline void emitq(uint64_t x, RelocInfo::Mode rmode); |
805 void emit(Immediate x) { emitl(x.value_); } | 811 void emit(Immediate x) { emitl(x.value_); } |
806 | 812 |
807 // Emits a REX prefix that encodes a 64-bit operand size and | 813 // Emits a REX prefix that encodes a 64-bit operand size and |
808 // the top bit of both register codes. | 814 // the top bit of both register codes. |
809 // High bit of reg goes to REX.R, high bit of rm_reg goes to REX.B. | 815 // High bit of reg goes to REX.R, high bit of rm_reg goes to REX.B. |
810 // REX.W is set. | 816 // REX.W is set. |
811 inline void emit_rex_64(Register reg, Register rm_reg); | 817 inline void emit_rex_64(Register reg, Register rm_reg); |
| 818 void emit_rex_64(Register rm_reg) { emit_rex_64(rax, rm_reg); } |
812 | 819 |
813 // Emits a REX prefix that encodes a 64-bit operand size and | 820 // Emits a REX prefix that encodes a 64-bit operand size and |
814 // the top bit of the destination, index, and base register codes. | 821 // the top bit of the destination, index, and base register codes. |
815 // The high bit of reg is used for REX.R, the high bit of op's base | 822 // The high bit of reg is used for REX.R, the high bit of op's base |
816 // register is used for REX.B, and the high bit of op's index register | 823 // register is used for REX.B, and the high bit of op's index register |
817 // is used for REX.X. REX.W is set. | 824 // is used for REX.X. REX.W is set. |
818 inline void emit_rex_64(Register reg, const Operand& op); | 825 inline void emit_rex_64(Register reg, const Operand& op); |
| 826 void emit_rex_64(const Operand& op) { emit_rex_64(rax, op); } |
| 827 |
| 828 // High bit of reg goes to REX.R, high bit of rm_reg goes to REX.B. |
| 829 // REX.W is set. |
| 830 inline void emit_rex_32(Register reg, Register rm_reg); |
| 831 |
| 832 // The high bit of reg is used for REX.R, the high bit of op's base |
| 833 // register is used for REX.B, and the high bit of op's index register |
| 834 // is used for REX.X. REX.W is cleared. |
| 835 inline void emit_rex_32(Register reg, const Operand& op); |
| 836 |
| 837 // High bit of reg goes to REX.R, high bit of rm_reg goes to REX.B. |
| 838 // REX.W is cleared. If no REX bits are set, no byte is emitted. |
| 839 inline void emit_optional_rex_32(Register reg, Register rm_reg); |
| 840 |
| 841 // The high bit of reg is used for REX.R, the high bit of op's base |
| 842 // register is used for REX.B, and the high bit of op's index register |
| 843 // is used for REX.X. REX.W is cleared. If no REX bits are set, nothing |
| 844 // is emitted. |
| 845 inline void emit_optional_rex_32(Register reg, const Operand& op); |
819 | 846 |
820 // Emit the Mod/RM byte, and optionally the SIB byte and | 847 // Emit the Mod/RM byte, and optionally the SIB byte and |
821 // 1- or 4-byte offset for a memory operand. Also encodes | 848 // 1- or 4-byte offset for a memory operand. Also encodes |
822 // the second operand of the operation, a register, into the Mod/RM byte. | 849 // the second operand of the operation, a register or operation |
| 850 // subcode, into the Mod/RM byte. |
823 void emit_operand(Register reg, const Operand& adr); | 851 void emit_operand(Register reg, const Operand& adr); |
| 852 void emit_operand(int op_subcode, const Operand& adr) { |
| 853 emit_operand(Register::toRegister(op_subcode), adr); |
| 854 } |
824 | 855 |
825 // Emit the code-object-relative offset of the label's position | 856 // Emit the code-object-relative offset of the label's position |
826 inline void emit_code_relative_offset(Label* label); | 857 inline void emit_code_relative_offset(Label* label); |
827 | 858 |
828 // Emit machine code for one of the operations ADD, ADC, SUB, SBC, | 859 // Emit machine code for one of the operations ADD, ADC, SUB, SBC, |
829 // AND, OR, XOR, or CMP. The encodings of these operations are all | 860 // AND, OR, XOR, or CMP. The encodings of these operations are all |
830 // similar, differing just in the opcode or in the reg field of the | 861 // similar, differing just in the opcode or in the reg field of the |
831 // Mod/RM byte. | 862 // Mod/RM byte. |
832 void arithmetic_op(byte opcode, Register dst, Register src); | 863 void arithmetic_op(byte opcode, Register dst, Register src); |
833 void arithmetic_op(byte opcode, Register reg, const Operand& op); | 864 void arithmetic_op(byte opcode, Register reg, const Operand& op); |
834 void immediate_arithmetic_op(byte subcode, Register dst, Immediate src); | 865 void immediate_arithmetic_op(byte subcode, Register dst, Immediate src); |
835 void immediate_arithmetic_op(byte subcode, const Operand& dst, Immediate src); | 866 void immediate_arithmetic_op(byte subcode, const Operand& dst, Immediate src); |
836 | 867 |
837 void emit_farith(int b1, int b2, int i); | 868 void emit_farith(int b1, int b2, int i); |
838 | 869 |
839 // labels | 870 // labels |
840 void print(Label* L); | 871 void print(Label* L); |
841 void bind_to(Label* L, int pos); | 872 void bind_to(Label* L, int pos); |
842 void link_to(Label* L, Label* appendix); | 873 void link_to(Label* L, Label* appendix); |
843 | 874 |
844 // record reloc info for current pc_ | 875 // record reloc info for current pc_ |
845 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0) { | 876 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
846 UNIMPLEMENTED(); | |
847 } | |
848 | 877 |
849 friend class CodePatcher; | 878 friend class CodePatcher; |
850 friend class EnsureSpace; | 879 friend class EnsureSpace; |
851 | 880 |
852 // Code buffer: | 881 // Code buffer: |
853 // The buffer into which code and relocation info are generated. | 882 // The buffer into which code and relocation info are generated. |
854 byte* buffer_; | 883 byte* buffer_; |
855 int buffer_size_; | 884 int buffer_size_; |
856 // True if the assembler owns the buffer, false if buffer is external. | 885 // True if the assembler owns the buffer, false if buffer is external. |
857 bool own_buffer_; | 886 bool own_buffer_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 private: | 925 private: |
897 Assembler* assembler_; | 926 Assembler* assembler_; |
898 #ifdef DEBUG | 927 #ifdef DEBUG |
899 int space_before_; | 928 int space_before_; |
900 #endif | 929 #endif |
901 }; | 930 }; |
902 | 931 |
903 } } // namespace v8::internal | 932 } } // namespace v8::internal |
904 | 933 |
905 #endif // V8_X64_ASSEMBLER_X64_H_ | 934 #endif // V8_X64_ASSEMBLER_X64_H_ |
OLD | NEW |