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

Side by Side Diff: src/compiler/instruction.h

Issue 683133005: [turbofan] initial framework for unittesting of register allocator (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler/instruction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_INSTRUCTION_H_ 5 #ifndef V8_COMPILER_INSTRUCTION_H_
6 #define V8_COMPILER_INSTRUCTION_H_ 6 #define V8_COMPILER_INSTRUCTION_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <iosfwd> 9 #include <iosfwd>
10 #include <map> 10 #include <map>
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 BasicBlock::RpoNumber ao_number() const { return ao_number_; } 802 BasicBlock::RpoNumber ao_number() const { return ao_number_; }
803 BasicBlock::RpoNumber rpo_number() const { return rpo_number_; } 803 BasicBlock::RpoNumber rpo_number() const { return rpo_number_; }
804 BasicBlock::RpoNumber loop_header() const { return loop_header_; } 804 BasicBlock::RpoNumber loop_header() const { return loop_header_; }
805 BasicBlock::RpoNumber loop_end() const { 805 BasicBlock::RpoNumber loop_end() const {
806 DCHECK(IsLoopHeader()); 806 DCHECK(IsLoopHeader());
807 return loop_end_; 807 return loop_end_;
808 } 808 }
809 inline bool IsLoopHeader() const { return loop_end_.IsValid(); } 809 inline bool IsLoopHeader() const { return loop_end_.IsValid(); }
810 810
811 typedef ZoneVector<BasicBlock::RpoNumber> Predecessors; 811 typedef ZoneVector<BasicBlock::RpoNumber> Predecessors;
812 Predecessors& predecessors() { return predecessors_; }
812 const Predecessors& predecessors() const { return predecessors_; } 813 const Predecessors& predecessors() const { return predecessors_; }
813 size_t PredecessorCount() const { return predecessors_.size(); } 814 size_t PredecessorCount() const { return predecessors_.size(); }
814 size_t PredecessorIndexOf(BasicBlock::RpoNumber rpo_number) const; 815 size_t PredecessorIndexOf(BasicBlock::RpoNumber rpo_number) const;
815 816
816 typedef ZoneVector<BasicBlock::RpoNumber> Successors; 817 typedef ZoneVector<BasicBlock::RpoNumber> Successors;
818 Successors& successors() { return successors_; }
817 const Successors& successors() const { return successors_; } 819 const Successors& successors() const { return successors_; }
818 size_t SuccessorCount() const { return successors_.size(); } 820 size_t SuccessorCount() const { return successors_.size(); }
819 821
820 typedef ZoneVector<PhiInstruction*> PhiInstructions; 822 typedef ZoneVector<PhiInstruction*> PhiInstructions;
821 const PhiInstructions& phis() const { return phis_; } 823 const PhiInstructions& phis() const { return phis_; }
822 void AddPhi(PhiInstruction* phi) { phis_.push_back(phi); } 824 void AddPhi(PhiInstruction* phi) { phis_.push_back(phi); }
823 825
824 private: 826 private:
825 Successors successors_; 827 Successors successors_;
826 Predecessors predecessors_; 828 Predecessors predecessors_;
827 PhiInstructions phis_; 829 PhiInstructions phis_;
828 BasicBlock::Id id_; 830 const BasicBlock::Id id_;
829 BasicBlock::RpoNumber ao_number_; // Assembly order number. 831 const BasicBlock::RpoNumber ao_number_; // Assembly order number.
830 // TODO(dcarney): probably dont't need this. 832 // TODO(dcarney): probably dont't need this.
831 BasicBlock::RpoNumber rpo_number_; 833 const BasicBlock::RpoNumber rpo_number_;
832 BasicBlock::RpoNumber loop_header_; 834 const BasicBlock::RpoNumber loop_header_;
833 BasicBlock::RpoNumber loop_end_; 835 const BasicBlock::RpoNumber loop_end_;
834 int32_t code_start_; // start index of arch-specific code. 836 int32_t code_start_; // start index of arch-specific code.
835 int32_t code_end_; // end index of arch-specific code. 837 int32_t code_end_; // end index of arch-specific code.
836 const bool deferred_; // Block contains deferred code. 838 const bool deferred_; // Block contains deferred code.
837 }; 839 };
838 840
839 typedef ZoneDeque<Constant> ConstantDeque; 841 typedef ZoneDeque<Constant> ConstantDeque;
840 typedef std::map<int, Constant, std::less<int>, 842 typedef std::map<int, Constant, std::less<int>,
841 zone_allocator<std::pair<int, Constant> > > ConstantMap; 843 zone_allocator<std::pair<int, Constant> > > ConstantMap;
842 844
843 typedef ZoneDeque<Instruction*> InstructionDeque; 845 typedef ZoneDeque<Instruction*> InstructionDeque;
844 typedef ZoneDeque<PointerMap*> PointerMapDeque; 846 typedef ZoneDeque<PointerMap*> PointerMapDeque;
845 typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector; 847 typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector;
846 typedef ZoneVector<InstructionBlock*> InstructionBlocks; 848 typedef ZoneVector<InstructionBlock*> InstructionBlocks;
847 849
848 // Represents architecture-specific generated code before, during, and after 850 // Represents architecture-specific generated code before, during, and after
849 // register allocation. 851 // register allocation.
850 // TODO(titzer): s/IsDouble/IsFloat64/ 852 // TODO(titzer): s/IsDouble/IsFloat64/
851 class InstructionSequence FINAL { 853 class InstructionSequence FINAL {
852 public: 854 public:
853 InstructionSequence(Zone* zone, const Schedule* schedule); 855 static InstructionBlocks* InstructionBlocksFor(Zone* zone,
856 const Schedule* schedule);
857
858 InstructionSequence(Zone* zone, InstructionBlocks* instruction_blocks);
854 859
855 int NextVirtualRegister() { return next_virtual_register_++; } 860 int NextVirtualRegister() { return next_virtual_register_++; }
856 int VirtualRegisterCount() const { return next_virtual_register_; } 861 int VirtualRegisterCount() const { return next_virtual_register_; }
857 862
858 const InstructionBlocks& instruction_blocks() const { 863 const InstructionBlocks& instruction_blocks() const {
859 return instruction_blocks_; 864 return *instruction_blocks_;
860 } 865 }
861 866
862 int InstructionBlockCount() const { 867 int InstructionBlockCount() const {
863 return static_cast<int>(instruction_blocks_.size()); 868 return static_cast<int>(instruction_blocks_->size());
864 } 869 }
865 870
866 InstructionBlock* InstructionBlockAt(BasicBlock::RpoNumber rpo_number) { 871 InstructionBlock* InstructionBlockAt(BasicBlock::RpoNumber rpo_number) {
867 return instruction_blocks_[rpo_number.ToSize()]; 872 return instruction_blocks_->at(rpo_number.ToSize());
868 } 873 }
869 874
870 int LastLoopInstructionIndex(const InstructionBlock* block) { 875 int LastLoopInstructionIndex(const InstructionBlock* block) {
871 return instruction_blocks_[block->loop_end().ToSize() - 1] 876 return instruction_blocks_->at(block->loop_end().ToSize() - 1)
872 ->last_instruction_index(); 877 ->last_instruction_index();
873 } 878 }
874 879
875 const InstructionBlock* InstructionBlockAt( 880 const InstructionBlock* InstructionBlockAt(
876 BasicBlock::RpoNumber rpo_number) const { 881 BasicBlock::RpoNumber rpo_number) const {
877 return instruction_blocks_[rpo_number.ToSize()]; 882 return instruction_blocks_->at(rpo_number.ToSize());
878 } 883 }
879 884
880 const InstructionBlock* GetInstructionBlock(int instruction_index) const; 885 const InstructionBlock* GetInstructionBlock(int instruction_index) const;
881 886
882 bool IsReference(int virtual_register) const; 887 bool IsReference(int virtual_register) const;
883 bool IsDouble(int virtual_register) const; 888 bool IsDouble(int virtual_register) const;
884 889
885 void MarkAsReference(int virtual_register); 890 void MarkAsReference(int virtual_register);
886 void MarkAsDouble(int virtual_register); 891 void MarkAsDouble(int virtual_register);
887 892
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 FrameStateDescriptor* GetFrameStateDescriptor(StateId deoptimization_id); 959 FrameStateDescriptor* GetFrameStateDescriptor(StateId deoptimization_id);
955 int GetFrameStateDescriptorCount(); 960 int GetFrameStateDescriptorCount();
956 961
957 private: 962 private:
958 friend std::ostream& operator<<(std::ostream& os, 963 friend std::ostream& operator<<(std::ostream& os,
959 const InstructionSequence& code); 964 const InstructionSequence& code);
960 965
961 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet; 966 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet;
962 967
963 Zone* const zone_; 968 Zone* const zone_;
964 InstructionBlocks instruction_blocks_; 969 InstructionBlocks* const instruction_blocks_;
965 ConstantMap constants_; 970 ConstantMap constants_;
966 ConstantDeque immediates_; 971 ConstantDeque immediates_;
967 InstructionDeque instructions_; 972 InstructionDeque instructions_;
968 int next_virtual_register_; 973 int next_virtual_register_;
969 PointerMapDeque pointer_maps_; 974 PointerMapDeque pointer_maps_;
970 VirtualRegisterSet doubles_; 975 VirtualRegisterSet doubles_;
971 VirtualRegisterSet references_; 976 VirtualRegisterSet references_;
972 DeoptimizationVector deoptimization_entries_; 977 DeoptimizationVector deoptimization_entries_;
973 }; 978 };
974 979
975 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code); 980 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code);
976 981
977 } // namespace compiler 982 } // namespace compiler
978 } // namespace internal 983 } // namespace internal
979 } // namespace v8 984 } // namespace v8
980 985
981 #endif // V8_COMPILER_INSTRUCTION_H_ 986 #endif // V8_COMPILER_INSTRUCTION_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/instruction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698