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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 // is returned by RelocInfo::target_reference_address(). | 637 // is returned by RelocInfo::target_reference_address(). |
638 Address reconstructed_adr_ptr_; | 638 Address reconstructed_adr_ptr_; |
639 friend class RelocIterator; | 639 friend class RelocIterator; |
640 }; | 640 }; |
641 | 641 |
642 | 642 |
643 // RelocInfoWriter serializes a stream of relocation info. It writes towards | 643 // RelocInfoWriter serializes a stream of relocation info. It writes towards |
644 // lower addresses. | 644 // lower addresses. |
645 class RelocInfoWriter BASE_EMBEDDED { | 645 class RelocInfoWriter BASE_EMBEDDED { |
646 public: | 646 public: |
647 RelocInfoWriter() : pos_(NULL), | 647 RelocInfoWriter() |
648 last_pc_(NULL), | 648 : pos_(NULL), |
649 last_id_(0), | 649 last_pc_(NULL), |
650 last_position_(0) {} | 650 last_id_(0), |
651 RelocInfoWriter(byte* pos, byte* pc) : pos_(pos), | 651 last_position_(0), |
652 last_pc_(pc), | 652 last_mode_(RelocInfo::NUMBER_OF_MODES), |
653 last_id_(0), | 653 next_position_candidate_pos_delta_(0), |
654 last_position_(0) {} | 654 next_position_candidate_pc_delta_(0), |
| 655 next_position_candidate_flushed_(true) {} |
| 656 RelocInfoWriter(byte* pos, byte* pc) |
| 657 : pos_(pos), |
| 658 last_pc_(pc), |
| 659 last_id_(0), |
| 660 last_position_(0), |
| 661 last_mode_(RelocInfo::NUMBER_OF_MODES), |
| 662 next_position_candidate_pos_delta_(0), |
| 663 next_position_candidate_pc_delta_(0), |
| 664 next_position_candidate_flushed_(true) {} |
655 | 665 |
656 byte* pos() const { return pos_; } | 666 byte* pos() const { return pos_; } |
657 byte* last_pc() const { return last_pc_; } | 667 byte* last_pc() const { return last_pc_; } |
658 | 668 |
659 void Write(const RelocInfo* rinfo); | 669 void Write(const RelocInfo* rinfo); |
660 | 670 |
661 // Update the state of the stream after reloc info buffer | 671 // Update the state of the stream after reloc info buffer |
662 // and/or code is moved while the stream is active. | 672 // and/or code is moved while the stream is active. |
663 void Reposition(byte* pos, byte* pc) { | 673 void Reposition(byte* pos, byte* pc) { |
664 pos_ = pos; | 674 pos_ = pos; |
665 last_pc_ = pc; | 675 last_pc_ = pc; |
666 } | 676 } |
667 | 677 |
| 678 void Finish() { FlushPosition(); } |
| 679 |
668 // Max size (bytes) of a written RelocInfo. Longest encoding is | 680 // Max size (bytes) of a written RelocInfo. Longest encoding is |
669 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta. | 681 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta. |
670 // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12. | 682 // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12. |
671 // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16; | 683 // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16; |
672 // Here we use the maximum of the two. | 684 // Here we use the maximum of the two. |
673 static const int kMaxSize = 16; | 685 static const int kMaxSize = 16; |
674 | 686 |
675 private: | 687 private: |
676 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta); | 688 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta); |
677 inline void WriteTaggedPC(uint32_t pc_delta, int tag); | 689 inline void WriteTaggedPC(uint32_t pc_delta, int tag); |
678 inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag); | 690 inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag); |
679 inline void WriteExtraTaggedIntData(int data_delta, int top_tag); | 691 inline void WriteExtraTaggedIntData(int data_delta, int top_tag); |
680 inline void WriteExtraTaggedPoolData(int data, int pool_type); | 692 inline void WriteExtraTaggedPoolData(int data, int pool_type); |
681 inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag); | 693 inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag); |
682 inline void WriteTaggedData(intptr_t data_delta, int tag); | 694 inline void WriteTaggedData(intptr_t data_delta, int tag); |
683 inline void WriteExtraTag(int extra_tag, int top_tag); | 695 inline void WriteExtraTag(int extra_tag, int top_tag); |
| 696 inline void WritePosition(int pc_delta, int pos_delta, RelocInfo::Mode rmode); |
| 697 |
| 698 void FlushPosition(); |
684 | 699 |
685 byte* pos_; | 700 byte* pos_; |
686 byte* last_pc_; | 701 byte* last_pc_; |
687 int last_id_; | 702 int last_id_; |
688 int last_position_; | 703 int last_position_; |
| 704 RelocInfo::Mode last_mode_; |
| 705 int next_position_candidate_pos_delta_; |
| 706 uint32_t next_position_candidate_pc_delta_; |
| 707 bool next_position_candidate_flushed_; |
| 708 |
689 DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter); | 709 DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter); |
690 }; | 710 }; |
691 | 711 |
692 | 712 |
693 // A RelocIterator iterates over relocation information. | 713 // A RelocIterator iterates over relocation information. |
694 // Typical use: | 714 // Typical use: |
695 // | 715 // |
696 // for (RelocIterator it(code); !it.done(); it.next()) { | 716 // for (RelocIterator it(code); !it.done(); it.next()) { |
697 // // do something with it.rinfo() here | 717 // // do something with it.rinfo() here |
698 // } | 718 // } |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 NullCallWrapper() { } | 1152 NullCallWrapper() { } |
1133 virtual ~NullCallWrapper() { } | 1153 virtual ~NullCallWrapper() { } |
1134 virtual void BeforeCall(int call_size) const { } | 1154 virtual void BeforeCall(int call_size) const { } |
1135 virtual void AfterCall() const { } | 1155 virtual void AfterCall() const { } |
1136 }; | 1156 }; |
1137 | 1157 |
1138 | 1158 |
1139 } } // namespace v8::internal | 1159 } } // namespace v8::internal |
1140 | 1160 |
1141 #endif // V8_ASSEMBLER_H_ | 1161 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |