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

Side by Side Diff: src/compiler/escape-analysis.h

Issue 1485183002: [turbofan] Deopt support for escape analysis (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@ea-local
Patch Set: 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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_ESCAPE_ANALYSIS_H_ 5 #ifndef V8_COMPILER_ESCAPE_ANALYSIS_H_
6 #define V8_COMPILER_ESCAPE_ANALYSIS_H_ 6 #define V8_COMPILER_ESCAPE_ANALYSIS_H_
7 7
8 #include "src/base/flags.h" 8 #include "src/base/flags.h"
9 #include "src/compiler/graph.h" 9 #include "src/compiler/graph.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace compiler { 13 namespace compiler {
14 14
15 // Forward declarations. 15 // Forward declarations.
16 class CommonOperatorBuilder; 16 class CommonOperatorBuilder;
17 17
18 18
19 class VirtualObject : public ZoneObject { 19 class VirtualObject : public ZoneObject {
20 public: 20 public:
21 enum Status { kUntracked = 0, kTracked = 1 }; 21 enum Status { kUntracked = 0, kTracked = 1 };
22 VirtualObject(NodeId id, Zone* zone) 22 VirtualObject(NodeId id, Zone* zone)
23 : id_(id), status_(kUntracked), fields_(zone), replacement_(nullptr) {} 23 : id_(id),
24 status_(kUntracked),
25 fields_(zone),
26 replacement_(nullptr),
27 object_state_(nullptr) {}
24 28
25 VirtualObject(const VirtualObject& other) 29 VirtualObject(const VirtualObject& other)
26 : id_(other.id_), 30 : id_(other.id_),
27 status_(other.status_), 31 status_(other.status_),
28 fields_(other.fields_), 32 fields_(other.fields_),
29 replacement_(other.replacement_) {} 33 replacement_(other.replacement_),
34 object_state_(other.object_state_) {}
30 35
31 VirtualObject(NodeId id, Zone* zone, size_t field_number) 36 VirtualObject(NodeId id, Zone* zone, size_t field_number)
Jarin 2015/12/02 12:24:34 does field_number mean field_count here?
sigurds 2015/12/02 16:35:12 Yes.
32 : id_(id), status_(kTracked), fields_(zone), replacement_(nullptr) { 37 : id_(id),
38 status_(kTracked),
39 fields_(zone),
40 replacement_(nullptr),
41 object_state_(nullptr) {
33 fields_.resize(field_number); 42 fields_.resize(field_number);
34 } 43 }
35 44
36 Node* GetField(size_t offset) { 45 Node* GetField(size_t offset) {
37 if (offset < fields_.size()) { 46 if (offset < fields_.size()) {
38 return fields_[offset]; 47 return fields_[offset];
39 } 48 }
40 return nullptr; 49 return nullptr;
41 } 50 }
42 51
43 bool SetField(size_t offset, Node* node) { 52 bool SetField(size_t offset, Node* node) {
44 bool changed = fields_[offset] != node; 53 bool changed = fields_[offset] != node;
45 fields_[offset] = node; 54 fields_[offset] = node;
46 return changed; 55 return changed;
47 } 56 }
48 bool IsVirtual() const { return status_ == kTracked; } 57 bool IsVirtual() const { return status_ == kTracked; }
49 bool IsTracked() const { return status_ != kUntracked; } 58 bool IsTracked() const { return status_ != kUntracked; }
50 Node* GetReplacement() { return replacement_; } 59 Node* GetReplacement() { return replacement_; }
51 bool SetReplacement(Node* node) { 60 bool SetReplacement(Node* node) {
52 bool changed = replacement_ != node; 61 bool changed = replacement_ != node;
53 replacement_ = node; 62 replacement_ = node;
54 return changed; 63 return changed;
55 } 64 }
56 65
66 Node** fields_array() { return &fields_.front(); }
57 size_t fields() { return fields_.size(); } 67 size_t fields() { return fields_.size(); }
Jarin 2015/12/02 12:24:34 fields -> field_count?
sigurds 2015/12/02 16:35:12 Changed.
58 bool ResizeFields(size_t field_number) { 68 bool ResizeFields(size_t field_number) {
59 if (field_number != fields_.size()) { 69 if (field_number != fields_.size()) {
60 fields_.resize(field_number); 70 fields_.resize(field_number);
61 return true; 71 return true;
62 } 72 }
63 return false; 73 return false;
64 } 74 }
65 75 void SetObjectState(Node* node) { object_state_ = node; }
76 Node* GetObjectState() { return object_state_; }
66 bool UpdateFrom(const VirtualObject& other); 77 bool UpdateFrom(const VirtualObject& other);
67 78
68 NodeId id() { return id_; } 79 NodeId id() { return id_; }
69 void id(NodeId id) { id_ = id; } 80 void id(NodeId id) { id_ = id; }
70 81
71 private: 82 private:
72 NodeId id_; 83 NodeId id_;
73 Status status_; 84 Status status_;
74 ZoneVector<Node*> fields_; 85 ZoneVector<Node*> fields_;
75 Node* replacement_; 86 Node* replacement_;
87 Node* object_state_;
76 }; 88 };
77 89
78 90
79 class VirtualState : public ZoneObject { 91 class VirtualState : public ZoneObject {
80 public: 92 public:
81 VirtualState(Zone* zone, size_t size); 93 VirtualState(Zone* zone, size_t size);
82 VirtualState(const VirtualState& states); 94 VirtualState(const VirtualState& states);
83 95
84 VirtualObject* GetVirtualObject(Node* node); 96 VirtualObject* GetVirtualObject(Node* node);
85 VirtualObject* GetVirtualObject(size_t id); 97 VirtualObject* GetVirtualObject(size_t id);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // EscapeObjectAnalysis simulates stores to determine values of loads if 169 // EscapeObjectAnalysis simulates stores to determine values of loads if
158 // an object is virtual and eliminated. 170 // an object is virtual and eliminated.
159 class EscapeObjectAnalysis { 171 class EscapeObjectAnalysis {
160 public: 172 public:
161 EscapeObjectAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone); 173 EscapeObjectAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone);
162 ~EscapeObjectAnalysis(); 174 ~EscapeObjectAnalysis();
163 175
164 void Run(); 176 void Run();
165 177
166 Node* GetReplacement(Node* at, NodeId id); 178 Node* GetReplacement(Node* at, NodeId id);
179 VirtualObject* GetVirtualObject(Node* at, NodeId id);
180 Node* GetEffect(Node* node);
167 181
168 private: 182 private:
169 bool Process(Node* node); 183 bool Process(Node* node);
170 void ProcessLoadField(Node* node); 184 void ProcessLoadField(Node* node);
171 void ProcessStoreField(Node* node); 185 void ProcessStoreField(Node* node);
172 void ProcessAllocation(Node* node); 186 void ProcessAllocation(Node* node);
173 void ProcessFinishRegion(Node* node); 187 void ProcessFinishRegion(Node* node);
174 void ProcessCall(Node* node); 188 void ProcessCall(Node* node);
175 void ProcessStart(Node* node); 189 void ProcessStart(Node* node);
176 bool ProcessEffectPhi(Node* node); 190 bool ProcessEffectPhi(Node* node);
177 void ForwardVirtualState(Node* node); 191 void ForwardVirtualState(Node* node);
192 void ProcessFrameState(Node* node);
178 bool IsEffectBranchPoint(Node* node); 193 bool IsEffectBranchPoint(Node* node);
179 bool IsDanglingEffectNode(Node* node); 194 bool IsDanglingEffectNode(Node* node);
180 int OffsetFromAccess(Node* node); 195 int OffsetFromAccess(Node* node);
181 196
197 void RecordEffectForFrameStateUses(Node* node, Node* effect);
198
182 void DebugPrint(); 199 void DebugPrint();
183 200
184 Graph* graph() const { return graph_; } 201 Graph* graph() const { return graph_; }
185 CommonOperatorBuilder* common() const { return common_; } 202 CommonOperatorBuilder* common() const { return common_; }
186 Zone* zone() const { return zone_; } 203 Zone* zone() const { return zone_; }
187 204
188 Graph* const graph_; 205 Graph* const graph_;
189 CommonOperatorBuilder* const common_; 206 CommonOperatorBuilder* const common_;
190 Zone* const zone_; 207 Zone* const zone_;
191 ZoneVector<VirtualState*> virtual_states_; 208 ZoneVector<VirtualState*> virtual_states_;
209 ZoneVector<Node*> effects_;
192 210
193 DISALLOW_COPY_AND_ASSIGN(EscapeObjectAnalysis); 211 DISALLOW_COPY_AND_ASSIGN(EscapeObjectAnalysis);
194 }; 212 };
195 213
196 } // namespace compiler 214 } // namespace compiler
197 } // namespace internal 215 } // namespace internal
198 } // namespace v8 216 } // namespace v8
199 217
200 #endif // V8_COMPILER_ESCAPE_ANALYSIS_H_ 218 #endif // V8_COMPILER_ESCAPE_ANALYSIS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698