Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: src/compiler/instruction.h

Issue 1060373006: [turbofan] Get rid of SourcePositionInstruction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/code-generator.cc ('k') | src/compiler/instruction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/source-position.h" 18 #include "src/compiler/source-position.h"
19 #include "src/zone-allocator.h" 19 #include "src/zone-allocator.h"
20 20
21 namespace v8 { 21 namespace v8 {
22 namespace internal { 22 namespace internal {
23 namespace compiler { 23 namespace compiler {
24 24
25 class Schedule; 25 class Schedule;
26 26
27 // A couple of reserved opcodes are used for internal use.
28 const InstructionCode kSourcePositionInstruction = -1;
29
30 class InstructionOperand { 27 class InstructionOperand {
31 public: 28 public:
32 static const int kInvalidVirtualRegister = -1; 29 static const int kInvalidVirtualRegister = -1;
33 30
34 // TODO(dcarney): recover bit. INVALID can be represented as UNALLOCATED with 31 // TODO(dcarney): recover bit. INVALID can be represented as UNALLOCATED with
35 // kInvalidVirtualRegister and some DCHECKS. 32 // kInvalidVirtualRegister and some DCHECKS.
36 enum Kind { INVALID, UNALLOCATED, CONSTANT, IMMEDIATE, ALLOCATED }; 33 enum Kind { INVALID, UNALLOCATED, CONSTANT, IMMEDIATE, ALLOCATED };
37 34
38 InstructionOperand() : InstructionOperand(INVALID) {} 35 InstructionOperand() : InstructionOperand(INVALID) {}
39 36
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 614 }
618 615
619 Instruction* MarkAsCall() { 616 Instruction* MarkAsCall() {
620 bit_field_ = IsCallField::update(bit_field_, true); 617 bit_field_ = IsCallField::update(bit_field_, true);
621 return this; 618 return this;
622 } 619 }
623 bool IsCall() const { return IsCallField::decode(bit_field_); } 620 bool IsCall() const { return IsCallField::decode(bit_field_); }
624 bool NeedsReferenceMap() const { return IsCall(); } 621 bool NeedsReferenceMap() const { return IsCall(); }
625 bool HasReferenceMap() const { return reference_map_ != NULL; } 622 bool HasReferenceMap() const { return reference_map_ != NULL; }
626 623
627 bool IsSourcePosition() const {
628 return opcode() == kSourcePositionInstruction;
629 }
630
631 bool ClobbersRegisters() const { return IsCall(); } 624 bool ClobbersRegisters() const { return IsCall(); }
632 bool ClobbersTemps() const { return IsCall(); } 625 bool ClobbersTemps() const { return IsCall(); }
633 bool ClobbersDoubleRegisters() const { return IsCall(); } 626 bool ClobbersDoubleRegisters() const { return IsCall(); }
634 ReferenceMap* reference_map() const { return reference_map_; } 627 ReferenceMap* reference_map() const { return reference_map_; }
635 628
636 void set_reference_map(ReferenceMap* map) { 629 void set_reference_map(ReferenceMap* map) {
637 DCHECK(NeedsReferenceMap()); 630 DCHECK(NeedsReferenceMap());
638 DCHECK(!reference_map_); 631 DCHECK(!reference_map_);
639 reference_map_ = map; 632 reference_map_ = map;
640 } 633 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 }; 695 };
703 696
704 697
705 struct PrintableInstruction { 698 struct PrintableInstruction {
706 const RegisterConfiguration* register_configuration_; 699 const RegisterConfiguration* register_configuration_;
707 const Instruction* instr_; 700 const Instruction* instr_;
708 }; 701 };
709 std::ostream& operator<<(std::ostream& os, const PrintableInstruction& instr); 702 std::ostream& operator<<(std::ostream& os, const PrintableInstruction& instr);
710 703
711 704
712 class SourcePositionInstruction FINAL : public Instruction {
713 public:
714 static SourcePositionInstruction* New(Zone* zone, SourcePosition position) {
715 void* buffer = zone->New(sizeof(SourcePositionInstruction));
716 return new (buffer) SourcePositionInstruction(position);
717 }
718
719 SourcePosition source_position() const { return source_position_; }
720
721 static SourcePositionInstruction* cast(Instruction* instr) {
722 DCHECK(instr->IsSourcePosition());
723 return static_cast<SourcePositionInstruction*>(instr);
724 }
725
726 static const SourcePositionInstruction* cast(const Instruction* instr) {
727 DCHECK(instr->IsSourcePosition());
728 return static_cast<const SourcePositionInstruction*>(instr);
729 }
730
731 private:
732 explicit SourcePositionInstruction(SourcePosition source_position)
733 : Instruction(kSourcePositionInstruction),
734 source_position_(source_position) {
735 DCHECK(!source_position_.IsInvalid());
736 DCHECK(!source_position_.IsUnknown());
737 }
738
739 SourcePosition source_position_;
740 };
741
742
743 class RpoNumber FINAL { 705 class RpoNumber FINAL {
744 public: 706 public:
745 static const int kInvalidRpoNumber = -1; 707 static const int kInvalidRpoNumber = -1;
746 int ToInt() const { 708 int ToInt() const {
747 DCHECK(IsValid()); 709 DCHECK(IsValid());
748 return index_; 710 return index_;
749 } 711 }
750 size_t ToSize() const { 712 size_t ToSize() const {
751 DCHECK(IsValid()); 713 DCHECK(IsValid());
752 return static_cast<size_t>(index_); 714 return static_cast<size_t>(index_);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 explicit StateId(int id) : id_(id) {} 1068 explicit StateId(int id) : id_(id) {}
1107 int id_; 1069 int id_;
1108 }; 1070 };
1109 1071
1110 StateId AddFrameStateDescriptor(FrameStateDescriptor* descriptor); 1072 StateId AddFrameStateDescriptor(FrameStateDescriptor* descriptor);
1111 FrameStateDescriptor* GetFrameStateDescriptor(StateId deoptimization_id); 1073 FrameStateDescriptor* GetFrameStateDescriptor(StateId deoptimization_id);
1112 int GetFrameStateDescriptorCount(); 1074 int GetFrameStateDescriptorCount();
1113 1075
1114 RpoNumber InputRpo(Instruction* instr, size_t index); 1076 RpoNumber InputRpo(Instruction* instr, size_t index);
1115 1077
1078 bool GetSourcePosition(const Instruction* instr,
1079 SourcePosition* result) const;
1080 void SetSourcePosition(const Instruction* instr, SourcePosition value);
1081
1116 private: 1082 private:
1117 friend std::ostream& operator<<(std::ostream& os, 1083 friend std::ostream& operator<<(std::ostream& os,
1118 const PrintableInstructionSequence& code); 1084 const PrintableInstructionSequence& code);
1119 1085
1120 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet; 1086 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet;
1087 typedef ZoneMap<const Instruction*, SourcePosition> SourcePositionMap;
1121 1088
1122 Isolate* isolate_; 1089 Isolate* isolate_;
1123 Zone* const zone_; 1090 Zone* const zone_;
1124 InstructionBlocks* const instruction_blocks_; 1091 InstructionBlocks* const instruction_blocks_;
1092 SourcePositionMap source_positions_;
1125 IntVector block_starts_; 1093 IntVector block_starts_;
1126 ConstantMap constants_; 1094 ConstantMap constants_;
1127 Immediates immediates_; 1095 Immediates immediates_;
1128 InstructionDeque instructions_; 1096 InstructionDeque instructions_;
1129 int next_virtual_register_; 1097 int next_virtual_register_;
1130 ReferenceMapDeque reference_maps_; 1098 ReferenceMapDeque reference_maps_;
1131 VirtualRegisterSet doubles_; 1099 VirtualRegisterSet doubles_;
1132 VirtualRegisterSet references_; 1100 VirtualRegisterSet references_;
1133 DeoptimizationVector deoptimization_entries_; 1101 DeoptimizationVector deoptimization_entries_;
1134 1102
1135 DISALLOW_COPY_AND_ASSIGN(InstructionSequence); 1103 DISALLOW_COPY_AND_ASSIGN(InstructionSequence);
1136 }; 1104 };
1137 1105
1138 1106
1139 struct PrintableInstructionSequence { 1107 struct PrintableInstructionSequence {
1140 const RegisterConfiguration* register_configuration_; 1108 const RegisterConfiguration* register_configuration_;
1141 const InstructionSequence* sequence_; 1109 const InstructionSequence* sequence_;
1142 }; 1110 };
1143 1111
1144 1112
1145 std::ostream& operator<<(std::ostream& os, 1113 std::ostream& operator<<(std::ostream& os,
1146 const PrintableInstructionSequence& code); 1114 const PrintableInstructionSequence& code);
1147 1115
1148 } // namespace compiler 1116 } // namespace compiler
1149 } // namespace internal 1117 } // namespace internal
1150 } // namespace v8 1118 } // namespace v8
1151 1119
1152 #endif // V8_COMPILER_INSTRUCTION_H_ 1120 #endif // V8_COMPILER_INSTRUCTION_H_
OLDNEW
« no previous file with comments | « src/compiler/code-generator.cc ('k') | src/compiler/instruction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698