| OLD | NEW |
| 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 | 610 |
| 611 private: | 611 private: |
| 612 friend std::ostream& operator<<(std::ostream& os, | 612 friend std::ostream& operator<<(std::ostream& os, |
| 613 const PrintableInstruction& instr); | 613 const PrintableInstruction& instr); |
| 614 ParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; | 614 ParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; |
| 615 }; | 615 }; |
| 616 | 616 |
| 617 | 617 |
| 618 // This special kind of gap move instruction represents the beginning of a | 618 // This special kind of gap move instruction represents the beginning of a |
| 619 // block of code. | 619 // block of code. |
| 620 // TODO(titzer): move code_start and code_end from BasicBlock to here. | |
| 621 class BlockStartInstruction FINAL : public GapInstruction { | 620 class BlockStartInstruction FINAL : public GapInstruction { |
| 622 public: | 621 public: |
| 623 Label* label() { return &label_; } | 622 static BlockStartInstruction* New(Zone* zone) { |
| 624 BasicBlock::RpoNumber rpo_number() const { return rpo_number_; } | |
| 625 BasicBlock::Id id() const { return id_; } | |
| 626 | |
| 627 static BlockStartInstruction* New(Zone* zone, BasicBlock::Id id, | |
| 628 BasicBlock::RpoNumber rpo_number) { | |
| 629 void* buffer = zone->New(sizeof(BlockStartInstruction)); | 623 void* buffer = zone->New(sizeof(BlockStartInstruction)); |
| 630 return new (buffer) BlockStartInstruction(id, rpo_number); | 624 return new (buffer) BlockStartInstruction(); |
| 631 } | 625 } |
| 632 | 626 |
| 633 static BlockStartInstruction* cast(Instruction* instr) { | 627 static BlockStartInstruction* cast(Instruction* instr) { |
| 634 DCHECK(instr->IsBlockStart()); | 628 DCHECK(instr->IsBlockStart()); |
| 635 return static_cast<BlockStartInstruction*>(instr); | 629 return static_cast<BlockStartInstruction*>(instr); |
| 636 } | 630 } |
| 637 | 631 |
| 638 private: | 632 private: |
| 639 BlockStartInstruction(BasicBlock::Id id, BasicBlock::RpoNumber rpo_number) | 633 BlockStartInstruction() : GapInstruction(kBlockStartInstruction) {} |
| 640 : GapInstruction(kBlockStartInstruction), | |
| 641 id_(id), | |
| 642 rpo_number_(rpo_number) {} | |
| 643 | |
| 644 BasicBlock::Id id_; | |
| 645 BasicBlock::RpoNumber rpo_number_; | |
| 646 Label label_; | |
| 647 }; | 634 }; |
| 648 | 635 |
| 649 | 636 |
| 650 class SourcePositionInstruction FINAL : public Instruction { | 637 class SourcePositionInstruction FINAL : public Instruction { |
| 651 public: | 638 public: |
| 652 static SourcePositionInstruction* New(Zone* zone, SourcePosition position) { | 639 static SourcePositionInstruction* New(Zone* zone, SourcePosition position) { |
| 653 void* buffer = zone->New(sizeof(SourcePositionInstruction)); | 640 void* buffer = zone->New(sizeof(SourcePositionInstruction)); |
| 654 return new (buffer) SourcePositionInstruction(position); | 641 return new (buffer) SourcePositionInstruction(position); |
| 655 } | 642 } |
| 656 | 643 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 const InstructionBlock* GetInstructionBlock(int instruction_index) const; | 905 const InstructionBlock* GetInstructionBlock(int instruction_index) const; |
| 919 | 906 |
| 920 bool IsReference(int virtual_register) const; | 907 bool IsReference(int virtual_register) const; |
| 921 bool IsDouble(int virtual_register) const; | 908 bool IsDouble(int virtual_register) const; |
| 922 | 909 |
| 923 void MarkAsReference(int virtual_register); | 910 void MarkAsReference(int virtual_register); |
| 924 void MarkAsDouble(int virtual_register); | 911 void MarkAsDouble(int virtual_register); |
| 925 | 912 |
| 926 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); | 913 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); |
| 927 | 914 |
| 928 Label* GetLabel(BasicBlock::RpoNumber rpo); | |
| 929 BlockStartInstruction* GetBlockStart(BasicBlock::RpoNumber rpo); | 915 BlockStartInstruction* GetBlockStart(BasicBlock::RpoNumber rpo); |
| 930 | 916 |
| 931 typedef InstructionDeque::const_iterator const_iterator; | 917 typedef InstructionDeque::const_iterator const_iterator; |
| 932 const_iterator begin() const { return instructions_.begin(); } | 918 const_iterator begin() const { return instructions_.begin(); } |
| 933 const_iterator end() const { return instructions_.end(); } | 919 const_iterator end() const { return instructions_.end(); } |
| 934 | 920 |
| 935 GapInstruction* GapAt(int index) const { | 921 GapInstruction* GapAt(int index) const { |
| 936 return GapInstruction::cast(InstructionAt(index)); | 922 return GapInstruction::cast(InstructionAt(index)); |
| 937 } | 923 } |
| 938 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } | 924 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 int GetFrameStateDescriptorCount(); | 979 int GetFrameStateDescriptorCount(); |
| 994 | 980 |
| 995 private: | 981 private: |
| 996 friend std::ostream& operator<<(std::ostream& os, | 982 friend std::ostream& operator<<(std::ostream& os, |
| 997 const PrintableInstructionSequence& code); | 983 const PrintableInstructionSequence& code); |
| 998 | 984 |
| 999 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet; | 985 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet; |
| 1000 | 986 |
| 1001 Zone* const zone_; | 987 Zone* const zone_; |
| 1002 InstructionBlocks* const instruction_blocks_; | 988 InstructionBlocks* const instruction_blocks_; |
| 989 IntVector block_starts_; |
| 1003 ConstantMap constants_; | 990 ConstantMap constants_; |
| 1004 ConstantDeque immediates_; | 991 ConstantDeque immediates_; |
| 1005 InstructionDeque instructions_; | 992 InstructionDeque instructions_; |
| 1006 int next_virtual_register_; | 993 int next_virtual_register_; |
| 1007 PointerMapDeque pointer_maps_; | 994 PointerMapDeque pointer_maps_; |
| 1008 VirtualRegisterSet doubles_; | 995 VirtualRegisterSet doubles_; |
| 1009 VirtualRegisterSet references_; | 996 VirtualRegisterSet references_; |
| 1010 DeoptimizationVector deoptimization_entries_; | 997 DeoptimizationVector deoptimization_entries_; |
| 1011 }; | 998 }; |
| 1012 | 999 |
| 1013 | 1000 |
| 1014 struct PrintableInstructionSequence { | 1001 struct PrintableInstructionSequence { |
| 1015 const RegisterConfiguration* register_configuration_; | 1002 const RegisterConfiguration* register_configuration_; |
| 1016 const InstructionSequence* sequence_; | 1003 const InstructionSequence* sequence_; |
| 1017 }; | 1004 }; |
| 1018 | 1005 |
| 1019 | 1006 |
| 1020 std::ostream& operator<<(std::ostream& os, | 1007 std::ostream& operator<<(std::ostream& os, |
| 1021 const PrintableInstructionSequence& code); | 1008 const PrintableInstructionSequence& code); |
| 1022 | 1009 |
| 1023 } // namespace compiler | 1010 } // namespace compiler |
| 1024 } // namespace internal | 1011 } // namespace internal |
| 1025 } // namespace v8 | 1012 } // namespace v8 |
| 1026 | 1013 |
| 1027 #endif // V8_COMPILER_INSTRUCTION_H_ | 1014 #endif // V8_COMPILER_INSTRUCTION_H_ |
| OLD | NEW |