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

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

Issue 664123002: [turbofan] cleanup InstructionSequence (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/ia32/code-generator-ia32.cc ('k') | 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 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 }; 831 };
832 832
833 typedef ZoneDeque<Constant> ConstantDeque; 833 typedef ZoneDeque<Constant> ConstantDeque;
834 typedef std::map<int, Constant, std::less<int>, 834 typedef std::map<int, Constant, std::less<int>,
835 zone_allocator<std::pair<int, Constant> > > ConstantMap; 835 zone_allocator<std::pair<int, Constant> > > ConstantMap;
836 836
837 typedef ZoneDeque<Instruction*> InstructionDeque; 837 typedef ZoneDeque<Instruction*> InstructionDeque;
838 typedef ZoneDeque<PointerMap*> PointerMapDeque; 838 typedef ZoneDeque<PointerMap*> PointerMapDeque;
839 typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector; 839 typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector;
840 typedef ZoneVector<InstructionBlock*> InstructionBlocks; 840 typedef ZoneVector<InstructionBlock*> InstructionBlocks;
841 typedef IntVector NodeToVregMap;
841 842
842 // Represents architecture-specific generated code before, during, and after 843 // Represents architecture-specific generated code before, during, and after
843 // register allocation. 844 // register allocation.
844 // TODO(titzer): s/IsDouble/IsFloat64/ 845 // TODO(titzer): s/IsDouble/IsFloat64/
845 class InstructionSequence FINAL { 846 class InstructionSequence FINAL {
846 public: 847 public:
847 InstructionSequence(Zone* zone, Linkage* linkage, const Graph* graph, 848 static const int kNodeUnmapped = -1;
848 const Schedule* schedule); 849
850 InstructionSequence(Zone* zone, const Graph* graph, const Schedule* schedule);
849 851
850 int NextVirtualRegister() { return next_virtual_register_++; } 852 int NextVirtualRegister() { return next_virtual_register_++; }
851 int VirtualRegisterCount() const { return next_virtual_register_; } 853 int VirtualRegisterCount() const { return next_virtual_register_; }
852 854
853 int node_count() const { return node_count_; } 855 int node_count() const { return static_cast<int>(node_map_.size()); }
854 856
855 int BasicBlockCount() const { 857 int InstructionBlockCount() const {
856 return static_cast<int>(instruction_blocks_.size()); 858 return static_cast<int>(instruction_blocks_.size());
857 } 859 }
858 860
859 InstructionBlock* InstructionBlockAt(BasicBlock::RpoNumber rpo_number) { 861 InstructionBlock* InstructionBlockAt(BasicBlock::RpoNumber rpo_number) {
860 return instruction_blocks_[rpo_number.ToSize()]; 862 return instruction_blocks_[rpo_number.ToSize()];
861 } 863 }
862 864
863 const InstructionBlock* InstructionBlockAt( 865 const InstructionBlock* InstructionBlockAt(
864 BasicBlock::RpoNumber rpo_number) const { 866 BasicBlock::RpoNumber rpo_number) const {
865 return instruction_blocks_[rpo_number.ToSize()]; 867 return instruction_blocks_[rpo_number.ToSize()];
866 } 868 }
867 869
868 // TODO(dcarney): move to register allocator.
869 const InstructionBlock* GetContainingLoop(
870 const InstructionBlock* block) const {
871 BasicBlock::RpoNumber index = block->loop_header();
872 if (!index.IsValid()) return NULL;
873 return instruction_blocks_[index.ToInt()];
874 }
875
876 const InstructionBlock* GetInstructionBlock(int instruction_index) const; 870 const InstructionBlock* GetInstructionBlock(int instruction_index) const;
877 871
878 int GetVirtualRegister(const Node* node); 872 int GetVirtualRegister(const Node* node);
879 // TODO(dcarney): find a way to remove this. 873 const NodeToVregMap& GetNodeMapForTesting() const { return node_map_; }
880 const int* GetNodeMapForTesting() const { return node_map_; }
881 874
882 bool IsReference(int virtual_register) const; 875 bool IsReference(int virtual_register) const;
883 bool IsDouble(int virtual_register) const; 876 bool IsDouble(int virtual_register) const;
884 877
885 void MarkAsReference(int virtual_register); 878 void MarkAsReference(int virtual_register);
886 void MarkAsDouble(int virtual_register); 879 void MarkAsDouble(int virtual_register);
887 880
888 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); 881 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to);
889 882
890 Label* GetLabel(BasicBlock::RpoNumber rpo); 883 Label* GetLabel(BasicBlock::RpoNumber rpo);
891 BlockStartInstruction* GetBlockStart(BasicBlock::RpoNumber rpo); 884 BlockStartInstruction* GetBlockStart(BasicBlock::RpoNumber rpo);
892 885
893 typedef InstructionDeque::const_iterator const_iterator; 886 typedef InstructionDeque::const_iterator const_iterator;
894 const_iterator begin() const { return instructions_.begin(); } 887 const_iterator begin() const { return instructions_.begin(); }
895 const_iterator end() const { return instructions_.end(); } 888 const_iterator end() const { return instructions_.end(); }
896 889
897 GapInstruction* GapAt(int index) const { 890 GapInstruction* GapAt(int index) const {
898 return GapInstruction::cast(InstructionAt(index)); 891 return GapInstruction::cast(InstructionAt(index));
899 } 892 }
900 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } 893 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); }
901 Instruction* InstructionAt(int index) const { 894 Instruction* InstructionAt(int index) const {
902 DCHECK(index >= 0); 895 DCHECK(index >= 0);
903 DCHECK(index < static_cast<int>(instructions_.size())); 896 DCHECK(index < static_cast<int>(instructions_.size()));
904 return instructions_[index]; 897 return instructions_[index];
905 } 898 }
906 899
907 Frame* frame() { return &frame_; }
908 Isolate* isolate() const { return zone()->isolate(); } 900 Isolate* isolate() const { return zone()->isolate(); }
909 Linkage* linkage() const { return linkage_; }
910 const PointerMapDeque* pointer_maps() const { return &pointer_maps_; } 901 const PointerMapDeque* pointer_maps() const { return &pointer_maps_; }
911 Zone* zone() const { return zone_; } 902 Zone* zone() const { return zone_; }
912 903
913 // Used by the instruction selector while adding instructions. 904 // Used by the instruction selector while adding instructions.
914 int AddInstruction(Instruction* instr); 905 int AddInstruction(Instruction* instr);
915 void StartBlock(BasicBlock* block); 906 void StartBlock(BasicBlock* block);
916 void EndBlock(BasicBlock* block); 907 void EndBlock(BasicBlock* block);
917 908
918 int AddConstant(Node* node, Constant constant) { 909 int AddConstant(Node* node, Constant constant) {
919 int virtual_register = GetVirtualRegister(node); 910 int virtual_register = GetVirtualRegister(node);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 StateId AddFrameStateDescriptor(FrameStateDescriptor* descriptor); 946 StateId AddFrameStateDescriptor(FrameStateDescriptor* descriptor);
956 FrameStateDescriptor* GetFrameStateDescriptor(StateId deoptimization_id); 947 FrameStateDescriptor* GetFrameStateDescriptor(StateId deoptimization_id);
957 int GetFrameStateDescriptorCount(); 948 int GetFrameStateDescriptorCount();
958 949
959 private: 950 private:
960 friend std::ostream& operator<<(std::ostream& os, 951 friend std::ostream& operator<<(std::ostream& os,
961 const InstructionSequence& code); 952 const InstructionSequence& code);
962 953
963 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet; 954 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet;
964 955
965 Zone* zone_; 956 Zone* const zone_;
966 int node_count_; 957 NodeToVregMap node_map_;
967 int* node_map_;
968 InstructionBlocks instruction_blocks_; 958 InstructionBlocks instruction_blocks_;
969 Linkage* linkage_;
970 ConstantMap constants_; 959 ConstantMap constants_;
971 ConstantDeque immediates_; 960 ConstantDeque immediates_;
972 InstructionDeque instructions_; 961 InstructionDeque instructions_;
973 int next_virtual_register_; 962 int next_virtual_register_;
974 PointerMapDeque pointer_maps_; 963 PointerMapDeque pointer_maps_;
975 VirtualRegisterSet doubles_; 964 VirtualRegisterSet doubles_;
976 VirtualRegisterSet references_; 965 VirtualRegisterSet references_;
977 Frame frame_;
978 DeoptimizationVector deoptimization_entries_; 966 DeoptimizationVector deoptimization_entries_;
979 }; 967 };
980 968
981 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code); 969 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code);
982 970
983 } // namespace compiler 971 } // namespace compiler
984 } // namespace internal 972 } // namespace internal
985 } // namespace v8 973 } // namespace v8
986 974
987 #endif // V8_COMPILER_INSTRUCTION_H_ 975 #endif // V8_COMPILER_INSTRUCTION_H_
OLDNEW
« no previous file with comments | « src/compiler/ia32/code-generator-ia32.cc ('k') | src/compiler/instruction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698