| 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> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "src/compiler/common-operator.h" | 13 #include "src/compiler/common-operator.h" |
| 14 #include "src/compiler/frame.h" | 14 #include "src/compiler/frame.h" |
| 15 #include "src/compiler/instruction-codes.h" | 15 #include "src/compiler/instruction-codes.h" |
| 16 #include "src/compiler/opcodes.h" | 16 #include "src/compiler/opcodes.h" |
| 17 #include "src/compiler/register-configuration.h" | 17 #include "src/compiler/register-configuration.h" |
| 18 #include "src/compiler/schedule.h" | 18 #include "src/compiler/schedule.h" |
| 19 #include "src/compiler/source-position.h" | 19 #include "src/compiler/source-position.h" |
| 20 #include "src/zone-allocator.h" | 20 #include "src/zone-allocator.h" |
| 21 | 21 |
| 22 namespace v8 { | 22 namespace v8 { |
| 23 namespace internal { | 23 namespace internal { |
| 24 namespace compiler { | 24 namespace compiler { |
| 25 | 25 |
| 26 // A couple of reserved opcodes are used for internal use. | 26 // A couple of reserved opcodes are used for internal use. |
| 27 const InstructionCode kGapInstruction = -1; | 27 const InstructionCode kGapInstruction = -1; |
| 28 const InstructionCode kBlockStartInstruction = -2; | 28 const InstructionCode kSourcePositionInstruction = -2; |
| 29 const InstructionCode kSourcePositionInstruction = -3; | |
| 30 | 29 |
| 31 #define INSTRUCTION_OPERAND_LIST(V) \ | 30 #define INSTRUCTION_OPERAND_LIST(V) \ |
| 32 V(Constant, CONSTANT, 0) \ | 31 V(Constant, CONSTANT, 0) \ |
| 33 V(Immediate, IMMEDIATE, 0) \ | 32 V(Immediate, IMMEDIATE, 0) \ |
| 34 V(StackSlot, STACK_SLOT, 128) \ | 33 V(StackSlot, STACK_SLOT, 128) \ |
| 35 V(DoubleStackSlot, DOUBLE_STACK_SLOT, 128) \ | 34 V(DoubleStackSlot, DOUBLE_STACK_SLOT, 128) \ |
| 36 V(Register, REGISTER, RegisterConfiguration::kMaxGeneralRegisters) \ | 35 V(Register, REGISTER, RegisterConfiguration::kMaxGeneralRegisters) \ |
| 37 V(DoubleRegister, DOUBLE_REGISTER, RegisterConfiguration::kMaxDoubleRegisters) | 36 V(DoubleRegister, DOUBLE_REGISTER, RegisterConfiguration::kMaxDoubleRegisters) |
| 38 | 37 |
| 39 class InstructionOperand : public ZoneObject { | 38 class InstructionOperand : public ZoneObject { |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 } | 484 } |
| 486 Instruction* MarkAsCall() { | 485 Instruction* MarkAsCall() { |
| 487 bit_field_ = IsCallField::update(bit_field_, true); | 486 bit_field_ = IsCallField::update(bit_field_, true); |
| 488 return this; | 487 return this; |
| 489 } | 488 } |
| 490 bool IsControl() const { return IsControlField::decode(bit_field_); } | 489 bool IsControl() const { return IsControlField::decode(bit_field_); } |
| 491 bool IsCall() const { return IsCallField::decode(bit_field_); } | 490 bool IsCall() const { return IsCallField::decode(bit_field_); } |
| 492 bool NeedsPointerMap() const { return IsCall(); } | 491 bool NeedsPointerMap() const { return IsCall(); } |
| 493 bool HasPointerMap() const { return pointer_map_ != NULL; } | 492 bool HasPointerMap() const { return pointer_map_ != NULL; } |
| 494 | 493 |
| 495 bool IsGapMoves() const { | 494 bool IsGapMoves() const { return opcode() == kGapInstruction; } |
| 496 return opcode() == kGapInstruction || opcode() == kBlockStartInstruction; | |
| 497 } | |
| 498 bool IsBlockStart() const { return opcode() == kBlockStartInstruction; } | |
| 499 bool IsSourcePosition() const { | 495 bool IsSourcePosition() const { |
| 500 return opcode() == kSourcePositionInstruction; | 496 return opcode() == kSourcePositionInstruction; |
| 501 } | 497 } |
| 502 | 498 |
| 503 bool ClobbersRegisters() const { return IsCall(); } | 499 bool ClobbersRegisters() const { return IsCall(); } |
| 504 bool ClobbersTemps() const { return IsCall(); } | 500 bool ClobbersTemps() const { return IsCall(); } |
| 505 bool ClobbersDoubleRegisters() const { return IsCall(); } | 501 bool ClobbersDoubleRegisters() const { return IsCall(); } |
| 506 PointerMap* pointer_map() const { return pointer_map_; } | 502 PointerMap* pointer_map() const { return pointer_map_; } |
| 507 | 503 |
| 508 void set_pointer_map(PointerMap* map) { | 504 void set_pointer_map(PointerMap* map) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 parallel_moves_[AFTER] = NULL; | 630 parallel_moves_[AFTER] = NULL; |
| 635 } | 631 } |
| 636 | 632 |
| 637 private: | 633 private: |
| 638 friend std::ostream& operator<<(std::ostream& os, | 634 friend std::ostream& operator<<(std::ostream& os, |
| 639 const PrintableInstruction& instr); | 635 const PrintableInstruction& instr); |
| 640 ParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; | 636 ParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; |
| 641 }; | 637 }; |
| 642 | 638 |
| 643 | 639 |
| 644 // This special kind of gap move instruction represents the beginning of a | |
| 645 // block of code. | |
| 646 class BlockStartInstruction FINAL : public GapInstruction { | |
| 647 public: | |
| 648 static BlockStartInstruction* New(Zone* zone) { | |
| 649 void* buffer = zone->New(sizeof(BlockStartInstruction)); | |
| 650 return new (buffer) BlockStartInstruction(); | |
| 651 } | |
| 652 | |
| 653 static BlockStartInstruction* cast(Instruction* instr) { | |
| 654 DCHECK(instr->IsBlockStart()); | |
| 655 return static_cast<BlockStartInstruction*>(instr); | |
| 656 } | |
| 657 | |
| 658 static const BlockStartInstruction* cast(const Instruction* instr) { | |
| 659 DCHECK(instr->IsBlockStart()); | |
| 660 return static_cast<const BlockStartInstruction*>(instr); | |
| 661 } | |
| 662 | |
| 663 private: | |
| 664 BlockStartInstruction() : GapInstruction(kBlockStartInstruction) {} | |
| 665 }; | |
| 666 | |
| 667 | |
| 668 class SourcePositionInstruction FINAL : public Instruction { | 640 class SourcePositionInstruction FINAL : public Instruction { |
| 669 public: | 641 public: |
| 670 static SourcePositionInstruction* New(Zone* zone, SourcePosition position) { | 642 static SourcePositionInstruction* New(Zone* zone, SourcePosition position) { |
| 671 void* buffer = zone->New(sizeof(SourcePositionInstruction)); | 643 void* buffer = zone->New(sizeof(SourcePositionInstruction)); |
| 672 return new (buffer) SourcePositionInstruction(position); | 644 return new (buffer) SourcePositionInstruction(position); |
| 673 } | 645 } |
| 674 | 646 |
| 675 SourcePosition source_position() const { return source_position_; } | 647 SourcePosition source_position() const { return source_position_; } |
| 676 | 648 |
| 677 static SourcePositionInstruction* cast(Instruction* instr) { | 649 static SourcePositionInstruction* cast(Instruction* instr) { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 const InstructionBlock* GetInstructionBlock(int instruction_index) const; | 945 const InstructionBlock* GetInstructionBlock(int instruction_index) const; |
| 974 | 946 |
| 975 bool IsReference(int virtual_register) const; | 947 bool IsReference(int virtual_register) const; |
| 976 bool IsDouble(int virtual_register) const; | 948 bool IsDouble(int virtual_register) const; |
| 977 | 949 |
| 978 void MarkAsReference(int virtual_register); | 950 void MarkAsReference(int virtual_register); |
| 979 void MarkAsDouble(int virtual_register); | 951 void MarkAsDouble(int virtual_register); |
| 980 | 952 |
| 981 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); | 953 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); |
| 982 | 954 |
| 983 BlockStartInstruction* GetBlockStart(BasicBlock::RpoNumber rpo) const; | 955 GapInstruction* GetBlockStart(BasicBlock::RpoNumber rpo) const; |
| 984 | 956 |
| 985 typedef InstructionDeque::const_iterator const_iterator; | 957 typedef InstructionDeque::const_iterator const_iterator; |
| 986 const_iterator begin() const { return instructions_.begin(); } | 958 const_iterator begin() const { return instructions_.begin(); } |
| 987 const_iterator end() const { return instructions_.end(); } | 959 const_iterator end() const { return instructions_.end(); } |
| 988 const InstructionDeque& instructions() const { return instructions_; } | 960 const InstructionDeque& instructions() const { return instructions_; } |
| 989 | 961 |
| 990 GapInstruction* GapAt(int index) const { | 962 GapInstruction* GapAt(int index) const { |
| 991 return GapInstruction::cast(InstructionAt(index)); | 963 return GapInstruction::cast(InstructionAt(index)); |
| 992 } | 964 } |
| 993 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } | 965 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 | 1057 |
| 1086 | 1058 |
| 1087 std::ostream& operator<<(std::ostream& os, | 1059 std::ostream& operator<<(std::ostream& os, |
| 1088 const PrintableInstructionSequence& code); | 1060 const PrintableInstructionSequence& code); |
| 1089 | 1061 |
| 1090 } // namespace compiler | 1062 } // namespace compiler |
| 1091 } // namespace internal | 1063 } // namespace internal |
| 1092 } // namespace v8 | 1064 } // namespace v8 |
| 1093 | 1065 |
| 1094 #endif // V8_COMPILER_INSTRUCTION_H_ | 1066 #endif // V8_COMPILER_INSTRUCTION_H_ |
| OLD | NEW |