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

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

Issue 1485183002: [turbofan] Deopt support for escape analysis (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@ea-local
Patch Set: Fix --always-opt triggered bug Created 5 years 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
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/source-position.h" 17 #include "src/compiler/source-position.h"
18 #include "src/macro-assembler.h" 18 #include "src/macro-assembler.h"
19 #include "src/register-configuration.h" 19 #include "src/register-configuration.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 // Forward declarations.
26 class Schedule; 27 class Schedule;
27 28
29
28 class InstructionOperand { 30 class InstructionOperand {
29 public: 31 public:
30 static const int kInvalidVirtualRegister = -1; 32 static const int kInvalidVirtualRegister = -1;
31 33
32 // TODO(dcarney): recover bit. INVALID can be represented as UNALLOCATED with 34 // TODO(dcarney): recover bit. INVALID can be represented as UNALLOCATED with
33 // kInvalidVirtualRegister and some DCHECKS. 35 // kInvalidVirtualRegister and some DCHECKS.
34 enum Kind { INVALID, UNALLOCATED, CONSTANT, IMMEDIATE, EXPLICIT, ALLOCATED }; 36 enum Kind { INVALID, UNALLOCATED, CONSTANT, IMMEDIATE, EXPLICIT, ALLOCATED };
35 37
36 InstructionOperand() : InstructionOperand(INVALID) {} 38 InstructionOperand() : InstructionOperand(INVALID) {}
37 39
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {} 100 explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {}
99 101
100 inline uint64_t GetCanonicalizedValue() const; 102 inline uint64_t GetCanonicalizedValue() const;
101 103
102 class KindField : public BitField64<Kind, 0, 3> {}; 104 class KindField : public BitField64<Kind, 0, 3> {};
103 105
104 uint64_t value_; 106 uint64_t value_;
105 }; 107 };
106 108
107 109
110 typedef ZoneVector<InstructionOperand> InstructionOperandVector;
111
112
113 // Forward declarations.
114 class FrameStateDescriptor;
115
116
117 enum class StateValueKind { kPlain, kRecursive, kDuplicate };
118
119
120 class StateValueDescriptor {
121 public:
122 explicit StateValueDescriptor(Zone* zone)
123 : kind_(StateValueKind::kPlain),
124 type_(kMachAnyTagged),
125 id_(0),
126 fields_(zone) {}
127
128 static StateValueDescriptor Plain(Zone* zone, MachineType type) {
129 return StateValueDescriptor(StateValueKind::kPlain, zone, type, 0);
130 }
131 static StateValueDescriptor Recursive(Zone* zone, size_t id) {
132 return StateValueDescriptor(StateValueKind::kRecursive, zone,
133 kMachAnyTagged, id);
134 }
135 static StateValueDescriptor Duplicate(Zone* zone, size_t id) {
136 return StateValueDescriptor(StateValueKind::kDuplicate, zone,
137 kMachAnyTagged, id);
138 }
139
140 size_t size() { return fields_.size(); }
141 ZoneVector<StateValueDescriptor>& fields() { return fields_; }
142 int IsPlain() { return kind_ == StateValueKind::kPlain; }
143 int IsRecursive() { return kind_ == StateValueKind::kRecursive; }
144 int IsDuplicate() { return kind_ == StateValueKind::kDuplicate; }
145 MachineType type() const { return type_; }
146 MachineType GetOperandType(size_t index) const {
147 return fields_[index].type_;
148 }
149 size_t id() const { return id_; }
150
151 private:
152 StateValueDescriptor(StateValueKind kind, Zone* zone, MachineType type,
153 size_t id)
154 : kind_(kind), type_(type), id_(id), fields_(zone) {}
155
156 StateValueKind kind_;
157 MachineType type_;
158 size_t id_;
159 ZoneVector<StateValueDescriptor> fields_;
160 };
161
162
163 class FrameStateDescriptor : public ZoneObject {
164 public:
165 FrameStateDescriptor(Zone* zone, FrameStateType type, BailoutId bailout_id,
166 OutputFrameStateCombine state_combine,
167 size_t parameters_count, size_t locals_count,
168 size_t stack_count,
169 MaybeHandle<SharedFunctionInfo> shared_info,
170 FrameStateDescriptor* outer_state = nullptr);
171
172 FrameStateType type() const { return type_; }
173 BailoutId bailout_id() const { return bailout_id_; }
174 OutputFrameStateCombine state_combine() const { return frame_state_combine_; }
175 size_t parameters_count() const { return parameters_count_; }
176 size_t locals_count() const { return locals_count_; }
177 size_t stack_count() const { return stack_count_; }
178 MaybeHandle<SharedFunctionInfo> shared_info() const { return shared_info_; }
179 FrameStateDescriptor* outer_state() const { return outer_state_; }
180 bool HasContext() const {
181 return type_ == FrameStateType::kJavaScriptFunction;
182 }
183
184 size_t GetSize(OutputFrameStateCombine combine =
185 OutputFrameStateCombine::Ignore()) const;
186 size_t GetTotalSize() const;
187 size_t GetFrameCount() const;
188 size_t GetJSFrameCount() const;
189
190 MachineType GetType(size_t index) const {
191 return values_.GetOperandType(index);
192 }
193 StateValueDescriptor* GetStateValueDescriptor() { return &values_; }
194
195 private:
196 FrameStateType type_;
197 BailoutId bailout_id_;
198 OutputFrameStateCombine frame_state_combine_;
199 size_t parameters_count_;
200 size_t locals_count_;
201 size_t stack_count_;
202 StateValueDescriptor values_;
203 MaybeHandle<SharedFunctionInfo> const shared_info_;
204 FrameStateDescriptor* outer_state_;
205 };
206
207
108 struct PrintableInstructionOperand { 208 struct PrintableInstructionOperand {
109 const RegisterConfiguration* register_configuration_; 209 const RegisterConfiguration* register_configuration_;
110 InstructionOperand op_; 210 InstructionOperand op_;
111 }; 211 };
112 212
113 213
114 std::ostream& operator<<(std::ostream& os, 214 std::ostream& operator<<(std::ostream& os,
115 const PrintableInstructionOperand& op); 215 const PrintableInstructionOperand& op);
116 216
117 217
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 DCHECK_EQ(kHeapObject, type()); 1021 DCHECK_EQ(kHeapObject, type());
922 return bit_cast<Handle<HeapObject> >(static_cast<intptr_t>(value_)); 1022 return bit_cast<Handle<HeapObject> >(static_cast<intptr_t>(value_));
923 } 1023 }
924 1024
925 private: 1025 private:
926 Type type_; 1026 Type type_;
927 int64_t value_; 1027 int64_t value_;
928 }; 1028 };
929 1029
930 1030
931 class FrameStateDescriptor : public ZoneObject {
932 public:
933 FrameStateDescriptor(Zone* zone, FrameStateType type, BailoutId bailout_id,
934 OutputFrameStateCombine state_combine,
935 size_t parameters_count, size_t locals_count,
936 size_t stack_count,
937 MaybeHandle<SharedFunctionInfo> shared_info,
938 FrameStateDescriptor* outer_state = nullptr);
939
940 FrameStateType type() const { return type_; }
941 BailoutId bailout_id() const { return bailout_id_; }
942 OutputFrameStateCombine state_combine() const { return frame_state_combine_; }
943 size_t parameters_count() const { return parameters_count_; }
944 size_t locals_count() const { return locals_count_; }
945 size_t stack_count() const { return stack_count_; }
946 MaybeHandle<SharedFunctionInfo> shared_info() const { return shared_info_; }
947 FrameStateDescriptor* outer_state() const { return outer_state_; }
948 bool HasContext() const {
949 return type_ == FrameStateType::kJavaScriptFunction;
950 }
951
952 size_t GetSize(OutputFrameStateCombine combine =
953 OutputFrameStateCombine::Ignore()) const;
954 size_t GetTotalSize() const;
955 size_t GetFrameCount() const;
956 size_t GetJSFrameCount() const;
957
958 MachineType GetType(size_t index) const;
959 void SetType(size_t index, MachineType type);
960
961 private:
962 FrameStateType type_;
963 BailoutId bailout_id_;
964 OutputFrameStateCombine frame_state_combine_;
965 size_t parameters_count_;
966 size_t locals_count_;
967 size_t stack_count_;
968 ZoneVector<MachineType> types_;
969 MaybeHandle<SharedFunctionInfo> const shared_info_;
970 FrameStateDescriptor* outer_state_;
971 };
972
973 std::ostream& operator<<(std::ostream& os, const Constant& constant); 1031 std::ostream& operator<<(std::ostream& os, const Constant& constant);
974 1032
975 1033
976 class PhiInstruction final : public ZoneObject { 1034 class PhiInstruction final : public ZoneObject {
977 public: 1035 public:
978 typedef ZoneVector<InstructionOperand> Inputs; 1036 typedef ZoneVector<InstructionOperand> Inputs;
979 1037
980 PhiInstruction(Zone* zone, int virtual_register, size_t input_count); 1038 PhiInstruction(Zone* zone, int virtual_register, size_t input_count);
981 1039
982 void SetInput(size_t offset, int virtual_register); 1040 void SetInput(size_t offset, int virtual_register);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 1335
1278 1336
1279 std::ostream& operator<<(std::ostream& os, 1337 std::ostream& operator<<(std::ostream& os,
1280 const PrintableInstructionSequence& code); 1338 const PrintableInstructionSequence& code);
1281 1339
1282 } // namespace compiler 1340 } // namespace compiler
1283 } // namespace internal 1341 } // namespace internal
1284 } // namespace v8 1342 } // namespace v8
1285 1343
1286 #endif // V8_COMPILER_INSTRUCTION_H_ 1344 #endif // V8_COMPILER_INSTRUCTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698