| 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 488 } |
| 489 Instruction* MarkAsCall() { | 489 Instruction* MarkAsCall() { |
| 490 bit_field_ = IsCallField::update(bit_field_, true); | 490 bit_field_ = IsCallField::update(bit_field_, true); |
| 491 return this; | 491 return this; |
| 492 } | 492 } |
| 493 bool IsControl() const { return IsControlField::decode(bit_field_); } | 493 bool IsControl() const { return IsControlField::decode(bit_field_); } |
| 494 bool IsCall() const { return IsCallField::decode(bit_field_); } | 494 bool IsCall() const { return IsCallField::decode(bit_field_); } |
| 495 bool NeedsPointerMap() const { return IsCall(); } | 495 bool NeedsPointerMap() const { return IsCall(); } |
| 496 bool HasPointerMap() const { return pointer_map_ != NULL; } | 496 bool HasPointerMap() const { return pointer_map_ != NULL; } |
| 497 | 497 |
| 498 bool IsGapMoves() const { | 498 bool IsGapMoves() const { return opcode() == kGapInstruction; } |
| 499 return opcode() == kGapInstruction || opcode() == kBlockStartInstruction; | |
| 500 } | |
| 501 bool IsBlockStart() const { return opcode() == kBlockStartInstruction; } | 499 bool IsBlockStart() const { return opcode() == kBlockStartInstruction; } |
| 502 bool IsSourcePosition() const { | 500 bool IsSourcePosition() const { |
| 503 return opcode() == kSourcePositionInstruction; | 501 return opcode() == kSourcePositionInstruction; |
| 504 } | 502 } |
| 505 | 503 |
| 506 bool ClobbersRegisters() const { return IsCall(); } | 504 bool ClobbersRegisters() const { return IsCall(); } |
| 507 bool ClobbersTemps() const { return IsCall(); } | 505 bool ClobbersTemps() const { return IsCall(); } |
| 508 bool ClobbersDoubleRegisters() const { return IsCall(); } | 506 bool ClobbersDoubleRegisters() const { return IsCall(); } |
| 509 PointerMap* pointer_map() const { return pointer_map_; } | 507 PointerMap* pointer_map() const { return pointer_map_; } |
| 510 | 508 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 ParallelMove* GetParallelMove(InnerPosition pos) { | 592 ParallelMove* GetParallelMove(InnerPosition pos) { |
| 595 return parallel_moves_[pos]; | 593 return parallel_moves_[pos]; |
| 596 } | 594 } |
| 597 | 595 |
| 598 const ParallelMove* GetParallelMove(InnerPosition pos) const { | 596 const ParallelMove* GetParallelMove(InnerPosition pos) const { |
| 599 return parallel_moves_[pos]; | 597 return parallel_moves_[pos]; |
| 600 } | 598 } |
| 601 | 599 |
| 602 static GapInstruction* New(Zone* zone) { | 600 static GapInstruction* New(Zone* zone) { |
| 603 void* buffer = zone->New(sizeof(GapInstruction)); | 601 void* buffer = zone->New(sizeof(GapInstruction)); |
| 604 return new (buffer) GapInstruction(kGapInstruction); | 602 return new (buffer) GapInstruction(); |
| 605 } | 603 } |
| 606 | 604 |
| 607 static GapInstruction* cast(Instruction* instr) { | 605 static GapInstruction* cast(Instruction* instr) { |
| 608 DCHECK(instr->IsGapMoves()); | 606 DCHECK(instr->IsGapMoves()); |
| 609 return static_cast<GapInstruction*>(instr); | 607 return static_cast<GapInstruction*>(instr); |
| 610 } | 608 } |
| 611 | 609 |
| 612 static const GapInstruction* cast(const Instruction* instr) { | 610 static const GapInstruction* cast(const Instruction* instr) { |
| 613 DCHECK(instr->IsGapMoves()); | 611 DCHECK(instr->IsGapMoves()); |
| 614 return static_cast<const GapInstruction*>(instr); | 612 return static_cast<const GapInstruction*>(instr); |
| 615 } | 613 } |
| 616 | 614 |
| 617 protected: | 615 private: |
| 618 explicit GapInstruction(InstructionCode opcode) : Instruction(opcode) { | 616 GapInstruction() : Instruction(kGapInstruction) { |
| 619 parallel_moves_[BEFORE] = NULL; | 617 parallel_moves_[BEFORE] = NULL; |
| 620 parallel_moves_[START] = NULL; | 618 parallel_moves_[START] = NULL; |
| 621 parallel_moves_[END] = NULL; | 619 parallel_moves_[END] = NULL; |
| 622 parallel_moves_[AFTER] = NULL; | 620 parallel_moves_[AFTER] = NULL; |
| 623 } | 621 } |
| 624 | 622 |
| 625 private: | |
| 626 friend std::ostream& operator<<(std::ostream& os, | 623 friend std::ostream& operator<<(std::ostream& os, |
| 627 const PrintableInstruction& instr); | 624 const PrintableInstruction& instr); |
| 628 ParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; | 625 ParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; |
| 629 }; | 626 }; |
| 630 | 627 |
| 631 | 628 |
| 632 // This special kind of gap move instruction represents the beginning of a | 629 // This is a placeholder instruction marking the start of a block. |
| 633 // block of code. | 630 class BlockStartInstruction FINAL : public Instruction { |
| 634 class BlockStartInstruction FINAL : public GapInstruction { | |
| 635 public: | 631 public: |
| 636 static BlockStartInstruction* New(Zone* zone) { | 632 static BlockStartInstruction* New(Zone* zone) { |
| 637 void* buffer = zone->New(sizeof(BlockStartInstruction)); | 633 void* buffer = zone->New(sizeof(BlockStartInstruction)); |
| 638 return new (buffer) BlockStartInstruction(); | 634 return new (buffer) BlockStartInstruction(); |
| 639 } | 635 } |
| 640 | 636 |
| 641 static BlockStartInstruction* cast(Instruction* instr) { | 637 static BlockStartInstruction* cast(Instruction* instr) { |
| 642 DCHECK(instr->IsBlockStart()); | 638 DCHECK(instr->IsBlockStart()); |
| 643 return static_cast<BlockStartInstruction*>(instr); | 639 return static_cast<BlockStartInstruction*>(instr); |
| 644 } | 640 } |
| 645 | 641 |
| 646 static const BlockStartInstruction* cast(const Instruction* instr) { | 642 static const BlockStartInstruction* cast(const Instruction* instr) { |
| 647 DCHECK(instr->IsBlockStart()); | 643 DCHECK(instr->IsBlockStart()); |
| 648 return static_cast<const BlockStartInstruction*>(instr); | 644 return static_cast<const BlockStartInstruction*>(instr); |
| 649 } | 645 } |
| 650 | 646 |
| 651 private: | 647 private: |
| 652 BlockStartInstruction() : GapInstruction(kBlockStartInstruction) {} | 648 BlockStartInstruction() : Instruction(kBlockStartInstruction) {} |
| 653 }; | 649 }; |
| 654 | 650 |
| 655 | 651 |
| 656 class SourcePositionInstruction FINAL : public Instruction { | 652 class SourcePositionInstruction FINAL : public Instruction { |
| 657 public: | 653 public: |
| 658 static SourcePositionInstruction* New(Zone* zone, SourcePosition position) { | 654 static SourcePositionInstruction* New(Zone* zone, SourcePosition position) { |
| 659 void* buffer = zone->New(sizeof(SourcePositionInstruction)); | 655 void* buffer = zone->New(sizeof(SourcePositionInstruction)); |
| 660 return new (buffer) SourcePositionInstruction(position); | 656 return new (buffer) SourcePositionInstruction(position); |
| 661 } | 657 } |
| 662 | 658 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 const InstructionBlock* GetInstructionBlock(int instruction_index) const; | 946 const InstructionBlock* GetInstructionBlock(int instruction_index) const; |
| 951 | 947 |
| 952 bool IsReference(int virtual_register) const; | 948 bool IsReference(int virtual_register) const; |
| 953 bool IsDouble(int virtual_register) const; | 949 bool IsDouble(int virtual_register) const; |
| 954 | 950 |
| 955 void MarkAsReference(int virtual_register); | 951 void MarkAsReference(int virtual_register); |
| 956 void MarkAsDouble(int virtual_register); | 952 void MarkAsDouble(int virtual_register); |
| 957 | 953 |
| 958 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); | 954 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); |
| 959 | 955 |
| 960 BlockStartInstruction* GetBlockStart(BasicBlock::RpoNumber rpo) const; | 956 const BlockStartInstruction* GetBlockStart(BasicBlock::RpoNumber rpo) const; |
| 961 | 957 |
| 962 typedef InstructionDeque::const_iterator const_iterator; | 958 typedef InstructionDeque::const_iterator const_iterator; |
| 963 const_iterator begin() const { return instructions_.begin(); } | 959 const_iterator begin() const { return instructions_.begin(); } |
| 964 const_iterator end() const { return instructions_.end(); } | 960 const_iterator end() const { return instructions_.end(); } |
| 965 const InstructionDeque& instructions() const { return instructions_; } | 961 const InstructionDeque& instructions() const { return instructions_; } |
| 966 | 962 |
| 967 GapInstruction* GapAt(int index) const { | 963 GapInstruction* GapAt(int index) const { |
| 968 return GapInstruction::cast(InstructionAt(index)); | 964 return GapInstruction::cast(InstructionAt(index)); |
| 969 } | 965 } |
| 970 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } | 966 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 | 1049 |
| 1054 | 1050 |
| 1055 std::ostream& operator<<(std::ostream& os, | 1051 std::ostream& operator<<(std::ostream& os, |
| 1056 const PrintableInstructionSequence& code); | 1052 const PrintableInstructionSequence& code); |
| 1057 | 1053 |
| 1058 } // namespace compiler | 1054 } // namespace compiler |
| 1059 } // namespace internal | 1055 } // namespace internal |
| 1060 } // namespace v8 | 1056 } // namespace v8 |
| 1061 | 1057 |
| 1062 #endif // V8_COMPILER_INSTRUCTION_H_ | 1058 #endif // V8_COMPILER_INSTRUCTION_H_ |
| OLD | NEW |