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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 DCHECK(index >= 0); | 325 DCHECK(index >= 0); |
326 if (index < kNumCachedOperands) return &cache[index]; | 326 if (index < kNumCachedOperands) return &cache[index]; |
327 return new (zone) SubKindOperand(index); | 327 return new (zone) SubKindOperand(index); |
328 } | 328 } |
329 | 329 |
330 static SubKindOperand* cast(InstructionOperand* op) { | 330 static SubKindOperand* cast(InstructionOperand* op) { |
331 DCHECK(op->kind() == kOperandKind); | 331 DCHECK(op->kind() == kOperandKind); |
332 return reinterpret_cast<SubKindOperand*>(op); | 332 return reinterpret_cast<SubKindOperand*>(op); |
333 } | 333 } |
334 | 334 |
| 335 static const SubKindOperand* cast(const InstructionOperand* op) { |
| 336 DCHECK(op->kind() == kOperandKind); |
| 337 return reinterpret_cast<const SubKindOperand*>(op); |
| 338 } |
| 339 |
335 static void SetUpCache(); | 340 static void SetUpCache(); |
336 static void TearDownCache(); | 341 static void TearDownCache(); |
337 | 342 |
338 private: | 343 private: |
339 static SubKindOperand* cache; | 344 static SubKindOperand* cache; |
340 | 345 |
341 SubKindOperand() : InstructionOperand() {} | 346 SubKindOperand() : InstructionOperand() {} |
342 explicit SubKindOperand(int index) | 347 explicit SubKindOperand(int index) |
343 : InstructionOperand(kOperandKind, index) {} | 348 : InstructionOperand(kOperandKind, index) {} |
344 }; | 349 }; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 LAST_INNER_POSITION = AFTER | 579 LAST_INNER_POSITION = AFTER |
575 }; | 580 }; |
576 | 581 |
577 ParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) { | 582 ParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) { |
578 if (parallel_moves_[pos] == NULL) { | 583 if (parallel_moves_[pos] == NULL) { |
579 parallel_moves_[pos] = new (zone) ParallelMove(zone); | 584 parallel_moves_[pos] = new (zone) ParallelMove(zone); |
580 } | 585 } |
581 return parallel_moves_[pos]; | 586 return parallel_moves_[pos]; |
582 } | 587 } |
583 | 588 |
584 ParallelMove* GetParallelMove(InnerPosition pos) { | 589 ParallelMove* GetParallelMove(InnerPosition pos) const { |
585 return parallel_moves_[pos]; | 590 return parallel_moves_[pos]; |
586 } | 591 } |
587 | 592 |
588 static GapInstruction* New(Zone* zone) { | 593 static GapInstruction* New(Zone* zone) { |
589 void* buffer = zone->New(sizeof(GapInstruction)); | 594 void* buffer = zone->New(sizeof(GapInstruction)); |
590 return new (buffer) GapInstruction(kGapInstruction); | 595 return new (buffer) GapInstruction(kGapInstruction); |
591 } | 596 } |
592 | 597 |
593 static GapInstruction* cast(Instruction* instr) { | 598 static GapInstruction* cast(Instruction* instr) { |
594 DCHECK(instr->IsGapMoves()); | 599 DCHECK(instr->IsGapMoves()); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 void MarkAsReference(int virtual_register); | 915 void MarkAsReference(int virtual_register); |
911 void MarkAsDouble(int virtual_register); | 916 void MarkAsDouble(int virtual_register); |
912 | 917 |
913 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); | 918 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to); |
914 | 919 |
915 BlockStartInstruction* GetBlockStart(BasicBlock::RpoNumber rpo); | 920 BlockStartInstruction* GetBlockStart(BasicBlock::RpoNumber rpo); |
916 | 921 |
917 typedef InstructionDeque::const_iterator const_iterator; | 922 typedef InstructionDeque::const_iterator const_iterator; |
918 const_iterator begin() const { return instructions_.begin(); } | 923 const_iterator begin() const { return instructions_.begin(); } |
919 const_iterator end() const { return instructions_.end(); } | 924 const_iterator end() const { return instructions_.end(); } |
| 925 const InstructionDeque& instructions() const { return instructions_; } |
920 | 926 |
921 GapInstruction* GapAt(int index) const { | 927 GapInstruction* GapAt(int index) const { |
922 return GapInstruction::cast(InstructionAt(index)); | 928 return GapInstruction::cast(InstructionAt(index)); |
923 } | 929 } |
924 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } | 930 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } |
925 Instruction* InstructionAt(int index) const { | 931 Instruction* InstructionAt(int index) const { |
926 DCHECK(index >= 0); | 932 DCHECK(index >= 0); |
927 DCHECK(index < static_cast<int>(instructions_.size())); | 933 DCHECK(index < static_cast<int>(instructions_.size())); |
928 return instructions_[index]; | 934 return instructions_[index]; |
929 } | 935 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 | 1011 |
1006 | 1012 |
1007 std::ostream& operator<<(std::ostream& os, | 1013 std::ostream& operator<<(std::ostream& os, |
1008 const PrintableInstructionSequence& code); | 1014 const PrintableInstructionSequence& code); |
1009 | 1015 |
1010 } // namespace compiler | 1016 } // namespace compiler |
1011 } // namespace internal | 1017 } // namespace internal |
1012 } // namespace v8 | 1018 } // namespace v8 |
1013 | 1019 |
1014 #endif // V8_COMPILER_INSTRUCTION_H_ | 1020 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |