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