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

Side by Side Diff: runtime/vm/flow_graph_builder.h

Issue 10702092: Simplify adding of computations to the flow graph. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_FLOW_GRAPH_BUILDER_H_ 5 #ifndef VM_FLOW_GRAPH_BUILDER_H_
6 #define VM_FLOW_GRAPH_BUILDER_H_ 6 #define VM_FLOW_GRAPH_BUILDER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 Instruction* entry() const { return entry_; } 107 Instruction* entry() const { return entry_; }
108 Instruction* exit() const { return exit_; } 108 Instruction* exit() const { return exit_; }
109 109
110 bool is_empty() const { return entry_ == NULL; } 110 bool is_empty() const { return entry_ == NULL; }
111 bool is_open() const { return is_empty() || exit_ != NULL; } 111 bool is_open() const { return is_empty() || exit_ != NULL; }
112 112
113 void Bailout(const char* reason); 113 void Bailout(const char* reason);
114 114
115 // Append a graph fragment to this graph. Assumes this graph is open. 115 // Append a graph fragment to this graph. Assumes this graph is open.
116 void Append(const EffectGraphVisitor& other_fragment); 116 void Append(const EffectGraphVisitor& other_fragment);
117 // Append a single instruction. Assumes this graph is open. 117 // Append a computation with one use. Assumes this graph is open.
118 UseVal* Bind(Computation* computation);
119 // Append a computation with no uses. Assumes this graph is open.
120 void Do(Computation* computation);
121 // Append a single (non-Bind, non-Do) instruction. Assumes this graph is
122 // open.
118 void AddInstruction(Instruction* instruction); 123 void AddInstruction(Instruction* instruction);
119 124
120 // Append a 'diamond' branch and join to this graph, depending on which 125 // Append a 'diamond' branch and join to this graph, depending on which
121 // parts are reachable. Assumes this graph is open. 126 // parts are reachable. Assumes this graph is open.
122 void Join(const TestGraphVisitor& test_fragment, 127 void Join(const TestGraphVisitor& test_fragment,
123 const EffectGraphVisitor& true_fragment, 128 const EffectGraphVisitor& true_fragment,
124 const EffectGraphVisitor& false_fragment); 129 const EffectGraphVisitor& false_fragment);
125 130
126 // Append a 'while loop' test and back edge to this graph, depending on 131 // Append a 'while loop' test and back edge to this graph, depending on
127 // which parts are reachable. Afterward, the graph exit is the false 132 // which parts are reachable. Afterward, the graph exit is the false
128 // successor of the loop condition. 133 // successor of the loop condition.
129 void TieLoop(const TestGraphVisitor& test_fragment, 134 void TieLoop(const TestGraphVisitor& test_fragment,
130 const EffectGraphVisitor& body_fragment); 135 const EffectGraphVisitor& body_fragment);
131 136
132 protected: 137 protected:
133 Computation* BuildStoreLocal(const LocalVariable& local, Value* value); 138 Computation* BuildStoreLocal(const LocalVariable& local, Value* value);
134 Computation* BuildLoadLocal(const LocalVariable& local); 139 Computation* BuildLoadLocal(const LocalVariable& local);
135 140
136 // Helpers for translating parts of the AST. 141 // Helpers for translating parts of the AST.
137 void TranslateArgumentList(const ArgumentListNode& node, 142 void TranslateArgumentList(const ArgumentListNode& node,
138 ZoneGrowableArray<Value*>* values); 143 ZoneGrowableArray<Value*>* values);
139 144
140 // Creates an instantiated type argument vector used in preparation of an 145 // Creates an instantiated type argument vector used in preparation of an
141 // allocation call. 146 // allocation call.
142 // May be called only if allocating an object of a parameterized class. 147 // May be called only if allocating an object of a parameterized class.
143 BindInstr* BuildInstantiatedTypeArguments( 148 Value* BuildInstantiatedTypeArguments(
144 intptr_t token_pos, 149 intptr_t token_pos,
145 const AbstractTypeArguments& type_arguments); 150 const AbstractTypeArguments& type_arguments);
146 151
147 // Creates a possibly uninstantiated type argument vector and the type 152 // Creates a possibly uninstantiated type argument vector and the type
148 // argument vector of the instantiator (two values in 'args') used in 153 // argument vector of the instantiator (two values in 'args') used in
149 // preparation of a constructor call. 154 // preparation of a constructor call.
150 // May be called only if allocating an object of a parameterized class. 155 // May be called only if allocating an object of a parameterized class.
151 void BuildConstructorTypeArguments(ConstructorCallNode* node, 156 void BuildConstructorTypeArguments(ConstructorCallNode* node,
152 ZoneGrowableArray<Value*>* args); 157 ZoneGrowableArray<Value*>* args);
153 158
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void CloseFragment() { exit_ = NULL; } 194 void CloseFragment() { exit_ = NULL; }
190 intptr_t AllocateTempIndex() { return temp_index_++; } 195 intptr_t AllocateTempIndex() { return temp_index_++; }
191 void DeallocateTempIndex(intptr_t n) { 196 void DeallocateTempIndex(intptr_t n) {
192 ASSERT(temp_index_ >= n); 197 ASSERT(temp_index_ >= n);
193 temp_index_ -= n; 198 temp_index_ -= n;
194 } 199 }
195 200
196 virtual void CompiletimeStringInterpolation(const Function& interpol_func, 201 virtual void CompiletimeStringInterpolation(const Function& interpol_func,
197 const Array& literals); 202 const Array& literals);
198 203
199 BindInstr* BuildObjectAllocation(ConstructorCallNode* node); 204 Value* BuildObjectAllocation(ConstructorCallNode* node);
200 void BuildConstructorCall(ConstructorCallNode* node, Value* alloc_value); 205 void BuildConstructorCall(ConstructorCallNode* node, Value* alloc_value);
201 206
202 void BuildStoreContext(const LocalVariable& variable); 207 void BuildStoreContext(const LocalVariable& variable);
203 void BuildLoadContext(const LocalVariable& variable); 208 void BuildLoadContext(const LocalVariable& variable);
204 209
205 void BuildThrowNode(ThrowNode* node); 210 void BuildThrowNode(ThrowNode* node);
206 211
207 ClosureCallComp* BuildClosureCall(ClosureCallNode* node); 212 ClosureCallComp* BuildClosureCall(ClosureCallNode* node);
208 213
209 Value* BuildNullValue(); 214 Value* BuildNullValue();
210 215
211 private: 216 private:
212 // Specify a computation as the final result. Adds a Do instruction to 217 // Specify a computation as the final result. Adds a Do instruction to
213 // the graph, but normally overridden in subclasses. 218 // the graph, but normally overridden in subclasses.
214 virtual void ReturnComputation(Computation* computation) { 219 virtual void ReturnComputation(Computation* computation) {
215 AddInstruction(new DoInstr(computation)); 220 Do(computation);
216 } 221 }
217 222
218 // Shared global state. 223 // Shared global state.
219 FlowGraphBuilder* owner_; 224 FlowGraphBuilder* owner_;
220 225
221 // Input parameters. 226 // Input parameters.
222 intptr_t temp_index_; 227 intptr_t temp_index_;
223 228
224 // Output parameters. 229 // Output parameters.
225 Instruction* entry_; 230 Instruction* entry_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // Helper to set the output state to return a Value. 265 // Helper to set the output state to return a Value.
261 virtual void ReturnValue(Value* value) { 266 virtual void ReturnValue(Value* value) {
262 ASSERT(value->IsUse()); 267 ASSERT(value->IsUse());
263 value_ = value; 268 value_ = value;
264 } 269 }
265 270
266 // Specify a computation as the final result. Adds a Bind instruction to 271 // Specify a computation as the final result. Adds a Bind instruction to
267 // the graph and returns its temporary value (i.e., set the output 272 // the graph and returns its temporary value (i.e., set the output
268 // parameters). 273 // parameters).
269 virtual void ReturnComputation(Computation* computation) { 274 virtual void ReturnComputation(Computation* computation) {
270 BindInstr* defn = new BindInstr(computation); 275 ReturnValue(Bind(computation));
271 AddInstruction(defn);
272 ReturnValue(new UseVal(defn));
273 } 276 }
274 277
275 virtual void CompiletimeStringInterpolation(const Function& interpol_func, 278 virtual void CompiletimeStringInterpolation(const Function& interpol_func,
276 const Array& literals); 279 const Array& literals);
277 280
278 virtual void BuildTypeTest(ComparisonNode* node); 281 virtual void BuildTypeTest(ComparisonNode* node);
279 virtual void BuildTypeCast(ComparisonNode* node); 282 virtual void BuildTypeCast(ComparisonNode* node);
280 }; 283 };
281 284
282 285
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Output parameters. 330 // Output parameters.
328 TargetEntryInstr** true_successor_address_; 331 TargetEntryInstr** true_successor_address_;
329 TargetEntryInstr** false_successor_address_; 332 TargetEntryInstr** false_successor_address_;
330 333
331 intptr_t condition_token_pos_; 334 intptr_t condition_token_pos_;
332 }; 335 };
333 336
334 } // namespace dart 337 } // namespace dart
335 338
336 #endif // VM_FLOW_GRAPH_BUILDER_H_ 339 #endif // VM_FLOW_GRAPH_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698