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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 static const int kCallTargetSize = kPointerSize; | 461 static const int kCallTargetSize = kPointerSize; |
462 static const int kExternalTargetSize = kPointerSize; | 462 static const int kExternalTargetSize = kPointerSize; |
463 | 463 |
464 // Distance between the address of the code target in the call instruction | 464 // Distance between the address of the code target in the call instruction |
465 // and the return address | 465 // and the return address |
466 static const int kCallTargetAddressOffset = kPointerSize; | 466 static const int kCallTargetAddressOffset = kPointerSize; |
467 // Distance between start of patched return sequence and the emitted address | 467 // Distance between start of patched return sequence and the emitted address |
468 // to jump to. | 468 // to jump to. |
469 static const int kPatchReturnSequenceAddressOffset = 1; // JMP imm32. | 469 static const int kPatchReturnSequenceAddressOffset = 1; // JMP imm32. |
470 | 470 |
| 471 // Distance between start of patched debug break slot and the emitted address |
| 472 // to jump to. |
| 473 static const int kPatchDebugBreakSlotAddressOffset = 1; // JMP imm32. |
| 474 |
471 static const int kCallInstructionLength = 5; | 475 static const int kCallInstructionLength = 5; |
472 static const int kJSReturnSequenceLength = 6; | 476 static const int kJSReturnSequenceLength = 6; |
473 | 477 |
| 478 // The debug break slot must be able to contain a call instruction. |
| 479 static const int kDebugBreakSlotLength = kCallInstructionLength; |
| 480 |
474 // --------------------------------------------------------------------------- | 481 // --------------------------------------------------------------------------- |
475 // Code generation | 482 // Code generation |
476 // | 483 // |
477 // - function names correspond one-to-one to ia32 instruction mnemonics | 484 // - function names correspond one-to-one to ia32 instruction mnemonics |
478 // - unless specified otherwise, instructions operate on 32bit operands | 485 // - unless specified otherwise, instructions operate on 32bit operands |
479 // - instructions on 8bit (byte) operands/registers have a trailing '_b' | 486 // - instructions on 8bit (byte) operands/registers have a trailing '_b' |
480 // - instructions on 16bit (word) operands/registers have a trailing '_w' | 487 // - instructions on 16bit (word) operands/registers have a trailing '_w' |
481 // - naming conflicts with C++ keywords are resolved via a trailing '_' | 488 // - naming conflicts with C++ keywords are resolved via a trailing '_' |
482 | 489 |
483 // NOTE ON INTERFACE: Currently, the interface is not very consistent | 490 // NOTE ON INTERFACE: Currently, the interface is not very consistent |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 | 809 |
803 // Debugging | 810 // Debugging |
804 void Print(); | 811 void Print(); |
805 | 812 |
806 // Check the code size generated from label to here. | 813 // Check the code size generated from label to here. |
807 int SizeOfCodeGeneratedSince(Label* l) { return pc_offset() - l->pos(); } | 814 int SizeOfCodeGeneratedSince(Label* l) { return pc_offset() - l->pos(); } |
808 | 815 |
809 // Mark address of the ExitJSFrame code. | 816 // Mark address of the ExitJSFrame code. |
810 void RecordJSReturn(); | 817 void RecordJSReturn(); |
811 | 818 |
| 819 // Mark address of a debug break slot. |
| 820 void RecordDebugBreakSlot(); |
| 821 |
812 // Record a comment relocation entry that can be used by a disassembler. | 822 // Record a comment relocation entry that can be used by a disassembler. |
813 // Use --debug_code to enable. | 823 // Use --debug_code to enable. |
814 void RecordComment(const char* msg); | 824 void RecordComment(const char* msg); |
815 | 825 |
816 void RecordPosition(int pos); | 826 void RecordPosition(int pos); |
817 void RecordStatementPosition(int pos); | 827 void RecordStatementPosition(int pos); |
818 void WriteRecordedPositions(); | 828 bool WriteRecordedPositions(); |
819 | 829 |
820 // Writes a single word of data in the code stream. | 830 // Writes a single word of data in the code stream. |
821 // Used for inline tables, e.g., jump-tables. | 831 // Used for inline tables, e.g., jump-tables. |
822 void dd(uint32_t data, RelocInfo::Mode reloc_info); | 832 void dd(uint32_t data, RelocInfo::Mode reloc_info); |
823 | 833 |
824 int pc_offset() const { return pc_ - buffer_; } | 834 int pc_offset() const { return pc_ - buffer_; } |
825 int current_statement_position() const { return current_statement_position_; } | 835 int current_statement_position() const { return current_statement_position_; } |
826 int current_position() const { return current_position_; } | 836 int current_position() const { return current_position_; } |
827 | 837 |
828 // Check if there is less than kGap bytes available in the buffer. | 838 // Check if there is less than kGap bytes available in the buffer. |
829 // If this is the case, we need to grow the buffer before emitting | 839 // If this is the case, we need to grow the buffer before emitting |
830 // an instruction or relocation information. | 840 // an instruction or relocation information. |
831 inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } | 841 inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } |
832 | 842 |
833 // Get the number of bytes available in the buffer. | 843 // Get the number of bytes available in the buffer. |
834 inline int available_space() const { return reloc_info_writer.pos() - pc_; } | 844 inline int available_space() const { return reloc_info_writer.pos() - pc_; } |
835 | 845 |
| 846 static bool IsNop(Address addr) { return *addr == 0x90; } |
| 847 |
836 // Avoid overflows for displacements etc. | 848 // Avoid overflows for displacements etc. |
837 static const int kMaximalBufferSize = 512*MB; | 849 static const int kMaximalBufferSize = 512*MB; |
838 static const int kMinimalBufferSize = 4*KB; | 850 static const int kMinimalBufferSize = 4*KB; |
839 | 851 |
840 protected: | 852 protected: |
841 void movsd(XMMRegister dst, const Operand& src); | 853 void movsd(XMMRegister dst, const Operand& src); |
842 void movsd(const Operand& dst, XMMRegister src); | 854 void movsd(const Operand& dst, XMMRegister src); |
843 | 855 |
844 void emit_sse_operand(XMMRegister reg, const Operand& adr); | 856 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
845 void emit_sse_operand(XMMRegister dst, XMMRegister src); | 857 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 private: | 954 private: |
943 Assembler* assembler_; | 955 Assembler* assembler_; |
944 #ifdef DEBUG | 956 #ifdef DEBUG |
945 int space_before_; | 957 int space_before_; |
946 #endif | 958 #endif |
947 }; | 959 }; |
948 | 960 |
949 } } // namespace v8::internal | 961 } } // namespace v8::internal |
950 | 962 |
951 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 963 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |