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

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

Issue 623313003: [turbofan] map vregs early (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 | « 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 16 matching lines...) Expand all
27 // Forward declarations. 27 // Forward declarations.
28 class Linkage; 28 class Linkage;
29 29
30 // A couple of reserved opcodes are used for internal use. 30 // A couple of reserved opcodes are used for internal use.
31 const InstructionCode kGapInstruction = -1; 31 const InstructionCode kGapInstruction = -1;
32 const InstructionCode kBlockStartInstruction = -2; 32 const InstructionCode kBlockStartInstruction = -2;
33 const InstructionCode kSourcePositionInstruction = -3; 33 const InstructionCode kSourcePositionInstruction = -3;
34 34
35 35
36 #define INSTRUCTION_OPERAND_LIST(V) \ 36 #define INSTRUCTION_OPERAND_LIST(V) \
37 V(Constant, CONSTANT, 128) \ 37 V(Constant, CONSTANT, 0) \
38 V(Immediate, IMMEDIATE, 128) \ 38 V(Immediate, IMMEDIATE, 0) \
39 V(StackSlot, STACK_SLOT, 128) \ 39 V(StackSlot, STACK_SLOT, 128) \
40 V(DoubleStackSlot, DOUBLE_STACK_SLOT, 128) \ 40 V(DoubleStackSlot, DOUBLE_STACK_SLOT, 128) \
41 V(Register, REGISTER, Register::kNumRegisters) \ 41 V(Register, REGISTER, Register::kNumRegisters) \
42 V(DoubleRegister, DOUBLE_REGISTER, DoubleRegister::kMaxNumRegisters) 42 V(DoubleRegister, DOUBLE_REGISTER, DoubleRegister::kMaxNumRegisters)
43 43
44 class InstructionOperand : public ZoneObject { 44 class InstructionOperand : public ZoneObject {
45 public: 45 public:
46 enum Kind { 46 enum Kind {
47 INVALID, 47 INVALID,
48 UNALLOCATED, 48 UNALLOCATED,
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 797
798 typedef ZoneDeque<Instruction*> InstructionDeque; 798 typedef ZoneDeque<Instruction*> InstructionDeque;
799 typedef ZoneDeque<PointerMap*> PointerMapDeque; 799 typedef ZoneDeque<PointerMap*> PointerMapDeque;
800 typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector; 800 typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector;
801 801
802 // Represents architecture-specific generated code before, during, and after 802 // Represents architecture-specific generated code before, during, and after
803 // register allocation. 803 // register allocation.
804 // TODO(titzer): s/IsDouble/IsFloat64/ 804 // TODO(titzer): s/IsDouble/IsFloat64/
805 class InstructionSequence FINAL { 805 class InstructionSequence FINAL {
806 public: 806 public:
807 InstructionSequence(Linkage* linkage, Graph* graph, Schedule* schedule) 807 InstructionSequence(Linkage* linkage, Graph* graph, Schedule* schedule);
808 : graph_(graph),
809 linkage_(linkage),
810 schedule_(schedule),
811 constants_(ConstantMap::key_compare(),
812 ConstantMap::allocator_type(zone())),
813 immediates_(zone()),
814 instructions_(zone()),
815 next_virtual_register_(graph->NodeCount()),
816 pointer_maps_(zone()),
817 doubles_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())),
818 references_(std::less<int>(),
819 VirtualRegisterSet::allocator_type(zone())),
820 deoptimization_entries_(zone()) {}
821 808
822 int NextVirtualRegister() { return next_virtual_register_++; } 809 int NextVirtualRegister() { return next_virtual_register_++; }
823 int VirtualRegisterCount() const { return next_virtual_register_; } 810 int VirtualRegisterCount() const { return next_virtual_register_; }
824 811
825 int ValueCount() const { return graph_->NodeCount(); } 812 int ValueCount() const { return graph_->NodeCount(); }
826 813
827 int BasicBlockCount() const { 814 int BasicBlockCount() const {
828 return static_cast<int>(schedule_->rpo_order()->size()); 815 return static_cast<int>(schedule_->rpo_order()->size());
829 } 816 }
830 817
831 BasicBlock* BlockAt(int rpo_number) const { 818 BasicBlock* BlockAt(int rpo_number) const {
832 return (*schedule_->rpo_order())[rpo_number]; 819 return (*schedule_->rpo_order())[rpo_number];
833 } 820 }
834 821
835 BasicBlock* GetContainingLoop(BasicBlock* block) { 822 BasicBlock* GetContainingLoop(BasicBlock* block) {
836 return block->loop_header(); 823 return block->loop_header();
837 } 824 }
838 825
839 int GetLoopEnd(BasicBlock* block) const { return block->loop_end(); } 826 int GetLoopEnd(BasicBlock* block) const { return block->loop_end(); }
840 827
841 BasicBlock* GetBasicBlock(int instruction_index); 828 BasicBlock* GetBasicBlock(int instruction_index);
842 829
843 int GetVirtualRegister(Node* node) const { return node->id(); } 830 int GetVirtualRegister(const Node* node);
844 831
845 bool IsReference(int virtual_register) const; 832 bool IsReference(int virtual_register) const;
846 bool IsDouble(int virtual_register) const; 833 bool IsDouble(int virtual_register) const;
847 834
848 void MarkAsReference(int virtual_register); 835 void MarkAsReference(int virtual_register);
849 void MarkAsDouble(int virtual_register); 836 void MarkAsDouble(int virtual_register);
850 837
851 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); 838 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to);
852 839
853 Label* GetLabel(BasicBlock* block); 840 Label* GetLabel(BasicBlock* block);
(...skipping 19 matching lines...) Expand all
873 Linkage* linkage() const { return linkage_; } 860 Linkage* linkage() const { return linkage_; }
874 Schedule* schedule() const { return schedule_; } 861 Schedule* schedule() const { return schedule_; }
875 const PointerMapDeque* pointer_maps() const { return &pointer_maps_; } 862 const PointerMapDeque* pointer_maps() const { return &pointer_maps_; }
876 Zone* zone() const { return graph_->zone(); } 863 Zone* zone() const { return graph_->zone(); }
877 864
878 // Used by the code generator while adding instructions. 865 // Used by the code generator while adding instructions.
879 int AddInstruction(Instruction* instr, BasicBlock* block); 866 int AddInstruction(Instruction* instr, BasicBlock* block);
880 void StartBlock(BasicBlock* block); 867 void StartBlock(BasicBlock* block);
881 void EndBlock(BasicBlock* block); 868 void EndBlock(BasicBlock* block);
882 869
883 void AddConstant(int virtual_register, Constant constant) { 870 int AddConstant(Node* node, Constant constant) {
871 int virtual_register = GetVirtualRegister(node);
884 DCHECK(constants_.find(virtual_register) == constants_.end()); 872 DCHECK(constants_.find(virtual_register) == constants_.end());
885 constants_.insert(std::make_pair(virtual_register, constant)); 873 constants_.insert(std::make_pair(virtual_register, constant));
874 return virtual_register;
886 } 875 }
887 Constant GetConstant(int virtual_register) const { 876 Constant GetConstant(int virtual_register) const {
888 ConstantMap::const_iterator it = constants_.find(virtual_register); 877 ConstantMap::const_iterator it = constants_.find(virtual_register);
889 DCHECK(it != constants_.end()); 878 DCHECK(it != constants_.end());
890 DCHECK_EQ(virtual_register, it->first); 879 DCHECK_EQ(virtual_register, it->first);
891 return it->second; 880 return it->second;
892 } 881 }
893 882
894 typedef ConstantDeque Immediates; 883 typedef ConstantDeque Immediates;
895 const Immediates& immediates() const { return immediates_; } 884 const Immediates& immediates() const { return immediates_; }
(...skipping 23 matching lines...) Expand all
919 FrameStateDescriptor* GetFrameStateDescriptor(StateId deoptimization_id); 908 FrameStateDescriptor* GetFrameStateDescriptor(StateId deoptimization_id);
920 int GetFrameStateDescriptorCount(); 909 int GetFrameStateDescriptorCount();
921 910
922 private: 911 private:
923 friend std::ostream& operator<<(std::ostream& os, 912 friend std::ostream& operator<<(std::ostream& os,
924 const InstructionSequence& code); 913 const InstructionSequence& code);
925 914
926 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet; 915 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet;
927 916
928 Graph* graph_; 917 Graph* graph_;
918 int* node_map_;
929 Linkage* linkage_; 919 Linkage* linkage_;
930 Schedule* schedule_; 920 Schedule* schedule_;
931 ConstantMap constants_; 921 ConstantMap constants_;
932 ConstantDeque immediates_; 922 ConstantDeque immediates_;
933 InstructionDeque instructions_; 923 InstructionDeque instructions_;
934 int next_virtual_register_; 924 int next_virtual_register_;
935 PointerMapDeque pointer_maps_; 925 PointerMapDeque pointer_maps_;
936 VirtualRegisterSet doubles_; 926 VirtualRegisterSet doubles_;
937 VirtualRegisterSet references_; 927 VirtualRegisterSet references_;
938 Frame frame_; 928 Frame frame_;
939 DeoptimizationVector deoptimization_entries_; 929 DeoptimizationVector deoptimization_entries_;
940 }; 930 };
941 931
942 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code); 932 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code);
943 933
944 } // namespace compiler 934 } // namespace compiler
945 } // namespace internal 935 } // namespace internal
946 } // namespace v8 936 } // namespace v8
947 937
948 #endif // V8_COMPILER_INSTRUCTION_H_ 938 #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