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

Side by Side Diff: src/compiler/liveness-analyzer.h

Issue 949743002: [turbofan] Variable liveness analysis for deopt (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test tweaks Created 5 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_LIVENESS_ANAYZER_H_
6 #define V8_COMPILER_LIVENESS_ANAYZER_H_
7
8 #include "src/zone-containers.h"
9
10 namespace v8 {
11 namespace internal {
12 namespace compiler {
13
14 class LivenessAnalyzerBlock;
15 class Node;
16 class JSGraph;
17
18
19 class FrameStateRelaxer {
20 public:
21 void RelaxFrameState(Node* frame_state, ZoneVector<bool>* liveness);
titzer 2015/02/27 21:03:54 Can we use a BitVector here and in the implementat
Jarin 2015/03/16 21:30:12 Done. (Will BitVector be really smaller? Why?)
22 FrameStateRelaxer(JSGraph* js_graph, Node* replacement, size_t local_count,
23 Zone* local_zone)
24 : replacement_node_(replacement),
25 js_graph_(js_graph),
26 local_zone_(local_zone),
27 blacklist_(local_count, false, local_zone) {}
28
29 void Blacklist(int var) { blacklist_[var] = true; }
30
31 private:
32 Node* RelaxStateValues(Node* frame_state, ZoneVector<bool>* liveness);
33
34 JSGraph* js_graph() { return js_graph_; }
35 Zone* local_zone() { return local_zone_; }
36
37 // Node that replaces dead values.
38 Node* replacement_node_;
39 // Reference to graph so that we can create new nodes.
40 JSGraph* js_graph_;
41
42 Zone* local_zone_;
43
44 ZoneVector<bool> blacklist_;
45 };
46
47
48 class LivenessAnalyzer : public ZoneObject {
49 public:
50 LivenessAnalyzer(size_t local_count, Zone* zone);
51
52 LivenessAnalyzerBlock* New();
53 LivenessAnalyzerBlock* New(LivenessAnalyzerBlock* predecessor);
54
55 void Run(FrameStateRelaxer* relaxer);
56
57 Zone* zone() { return zone_; }
58
59 void Print(std::ostream& os);
60
61 size_t local_count() { return local_count_; }
62
63 private:
64 void Queue(LivenessAnalyzerBlock* block);
65
66 Zone* zone_;
67 ZoneDeque<LivenessAnalyzerBlock*> blocks_;
68 size_t local_count_;
69
70 ZoneQueue<LivenessAnalyzerBlock*> queue_;
71 };
72
73
74 class LivenessAnalyzerBlock : public ZoneObject {
75 public:
76 friend class LivenessAnalyzer;
77
78 void Lookup(int var) { entries_.push_back(Entry(Entry::kLookup, var)); }
79 void Bind(int var) { entries_.push_back(Entry(Entry::kBind, var)); }
80 void Checkpoint(Node* node) { entries_.push_back(Entry(node)); }
81 void AddPredecessor(LivenessAnalyzerBlock* b) { predecessors_.push_back(b); }
82
83 private:
84 class Entry {
85 public:
86 enum Kind { kBind, kLookup, kCheckpoint };
87
88 Kind kind() const { return kind_; }
89 Node* node() const {
90 DCHECK(kind() == kCheckpoint);
91 return node_;
92 }
93 int var() const {
94 DCHECK(kind() != kCheckpoint);
95 return var_;
96 }
97
98 explicit Entry(Node* node) : kind_(kCheckpoint), var_(-1), node_(node) {}
99 Entry(Kind kind, int var) : kind_(kind), var_(var), node_(nullptr) {
100 DCHECK(kind != kCheckpoint);
101 }
102
103 private:
104 Kind kind_;
105 int var_;
106 Node* node_;
107 };
108
109 LivenessAnalyzerBlock(size_t id, size_t local_count, Zone* zone)
110 : entries_(zone),
111 predecessors_(zone),
112 live_(local_count, false, zone),
113 queued_(false),
114 id_(id) {}
115 void Process(ZoneVector<bool>* result, FrameStateRelaxer* relaxer);
116 bool UpdateLive(ZoneVector<bool>* working_area);
117
118 void SetQueued() { queued_ = true; }
119 bool IsQueued() { return queued_; }
120
121 ZoneDeque<LivenessAnalyzerBlock*>::const_iterator pred_begin() {
122 return predecessors_.begin();
123 }
124 ZoneDeque<LivenessAnalyzerBlock*>::const_iterator pred_end() {
125 return predecessors_.end();
126 }
127
128 size_t id() { return id_; }
129 void Print(std::ostream& os);
130
131 ZoneDeque<Entry> entries_;
132 ZoneDeque<LivenessAnalyzerBlock*> predecessors_;
133
134 ZoneVector<bool> live_;
135 bool queued_;
136
137 size_t id_;
138 };
139
140
141 } // namespace compiler
142 } // namespace internal
143 } // namespace v8
144
145 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698