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

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

Issue 10316005: Automatically assign temporary indices to definitions in the IL. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 // Append a 'while loop' test and back edge to this graph, depending on 109 // Append a 'while loop' test and back edge to this graph, depending on
110 // which parts are reachable. Afterward, the graph exit is the false 110 // which parts are reachable. Afterward, the graph exit is the false
111 // successor of the loop condition. 111 // successor of the loop condition.
112 void TieLoop(const TestGraphVisitor& test_fragment, 112 void TieLoop(const TestGraphVisitor& test_fragment,
113 const EffectGraphVisitor& body_fragment); 113 const EffectGraphVisitor& body_fragment);
114 114
115 protected: 115 protected:
116 // Helpers for translating parts of the AST. 116 // Helpers for translating parts of the AST.
117 void TranslateArgumentList(const ArgumentListNode& node, 117 void TranslateArgumentList(const ArgumentListNode& node,
118 intptr_t next_temp_index,
119 ZoneGrowableArray<Value*>* values); 118 ZoneGrowableArray<Value*>* values);
120 119
121 // Build the load part of a instance field increment. Translates the 120 // Build the load part of a instance field increment. Translates the
122 // receiver and loads the value. The receiver will be returned in the 121 // receiver and loads the value. The receiver will be returned in the
123 // output parameter 'receiver'. 122 // output parameter 'receiver'.
124 Definition* BuildIncrOpFieldLoad(IncrOpInstanceFieldNode* node, 123 Definition* BuildIncrOpFieldLoad(IncrOpInstanceFieldNode* node,
125 Value** receiver); 124 Value** receiver);
126 125
127 // Build the load part of an indexed increment. Translates the receiver 126 // Build the load part of an indexed increment. Translates the receiver
128 // and index and loads the value. The receiver will be returned in the 127 // and index and loads the value. The receiver will be returned in the
(...skipping 15 matching lines...) Expand all
144 Definition* BuildFactoryTypeArguments(ConstructorCallNode* node); 143 Definition* BuildFactoryTypeArguments(ConstructorCallNode* node);
145 144
146 // Creates a possibly uninstantiated type argument vector and the type 145 // Creates a possibly uninstantiated type argument vector and the type
147 // argument vector of the instantiator (two values in 'args') used in 146 // argument vector of the instantiator (two values in 'args') used in
148 // preparation of a constructor call. 147 // preparation of a constructor call.
149 // May be called only if allocating an object of a parameterized class. 148 // May be called only if allocating an object of a parameterized class.
150 void BuildConstructorTypeArguments(ConstructorCallNode* node, 149 void BuildConstructorTypeArguments(ConstructorCallNode* node,
151 ZoneGrowableArray<Value*>* args); 150 ZoneGrowableArray<Value*>* args);
152 151
153 // Returns the value of the type arguments of the instantiator. 152 // Returns the value of the type arguments of the instantiator.
154 Value* BuildInstantiatorTypeArguments(intptr_t token_index, 153 Value* BuildInstantiatorTypeArguments(intptr_t token_index);
155 intptr_t start_index);
156 154
157 // Perform a type check on the given value. 155 // Perform a type check on the given value.
158 void BuildAssertAssignable(intptr_t token_index, 156 void BuildAssertAssignable(intptr_t token_index,
159 Value* value, 157 Value* value,
160 const AbstractType& dst_type, 158 const AbstractType& dst_type,
161 const String& dst_name, 159 const String& dst_name);
162 intptr_t start_index);
163 160
164 // Perform a type check on the given value and return it. 161 // Perform a type check on the given value and return it.
165 Value* BuildAssignableValue(AstNode* value_node, 162 Value* BuildAssignableValue(AstNode* value_node,
166 Value* value, 163 Value* value,
167 const AbstractType& dst_type, 164 const AbstractType& dst_type,
168 const String& dst_name, 165 const String& dst_name);
169 intptr_t start_index);
170 166
171 virtual void BuildInstanceOf(ComparisonNode* node); 167 virtual void BuildInstanceOf(ComparisonNode* node);
172 168
173 bool MustSaveRestoreContext(SequenceNode* node) const; 169 bool MustSaveRestoreContext(SequenceNode* node) const;
174 170
175 // Moves parent context into the context register. 171 // Moves parent context into the context register.
176 void UnchainContext(); 172 void UnchainContext();
177 173
178 void CloseFragment() { exit_ = NULL; } 174 void CloseFragment() { exit_ = NULL; }
179 intptr_t AllocateTempIndex() { return temp_index_++; } 175 intptr_t AllocateTempIndex() { return temp_index_++; }
180 void DeallocateTempIndex() { --temp_index_; } 176 void DeallocateTempIndex(intptr_t n) {
177 ASSERT(temp_index_ >= n);
178 temp_index_ -= n;
179 }
181 180
182 virtual void CompiletimeStringInterpolation(const Function& interpol_func, 181 virtual void CompiletimeStringInterpolation(const Function& interpol_func,
183 const Array& literals); 182 const Array& literals);
184 183
185 Definition* BuildObjectAllocation(ConstructorCallNode* node); 184 Definition* BuildObjectAllocation(ConstructorCallNode* node);
186 void BuildConstructorCall(ConstructorCallNode* node, Value* alloc_value); 185 void BuildConstructorCall(ConstructorCallNode* node, Value* alloc_value);
187 186
188 void BuildStoreContext(const LocalVariable& variable); 187 void BuildStoreContext(const LocalVariable& variable);
189 void BuildLoadContext(const LocalVariable& variable); 188 void BuildLoadContext(const LocalVariable& variable);
190 189
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Helper to set the output state to return a Value. 240 // Helper to set the output state to return a Value.
242 virtual void ReturnValue(Value* value) { 241 virtual void ReturnValue(Value* value) {
243 ASSERT(value->IsUse() || value->IsTemp()); 242 ASSERT(value->IsUse() || value->IsTemp());
244 value_ = value; 243 value_ = value;
245 } 244 }
246 245
247 // Specify a computation as the final result. Adds a Bind instruction to 246 // Specify a computation as the final result. Adds a Bind instruction to
248 // the graph and returns its temporary value (i.e., set the output 247 // the graph and returns its temporary value (i.e., set the output
249 // parameters). 248 // parameters).
250 virtual void ReturnComputation(Computation* computation) { 249 virtual void ReturnComputation(Computation* computation) {
251 BindInstr* defn = new BindInstr(temp_index(), computation); 250 BindInstr* defn = new BindInstr(computation);
252 AddInstruction(defn); 251 AddInstruction(defn);
253 AllocateTempIndex(); 252 ReturnValue(new UseVal(defn));
254 value_ = new UseVal(defn);
255 } 253 }
256 254
257 virtual void CompiletimeStringInterpolation(const Function& interpol_func, 255 virtual void CompiletimeStringInterpolation(const Function& interpol_func,
258 const Array& literals); 256 const Array& literals);
259 257
260 virtual void BuildInstanceOf(ComparisonNode* node); 258 virtual void BuildInstanceOf(ComparisonNode* node);
261 }; 259 };
262 260
263 261
264 // Translate an AstNode to a control-flow graph fragment for both its 262 // Translate an AstNode to a control-flow graph fragment for both its
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return false_successor_address_; 296 return false_successor_address_;
299 } 297 }
300 298
301 intptr_t condition_token_index() const { return condition_token_index_; } 299 intptr_t condition_token_index() const { return condition_token_index_; }
302 300
303 private: 301 private:
304 // Construct and concatenate a Branch instruction to this graph fragment. 302 // Construct and concatenate a Branch instruction to this graph fragment.
305 // Closes the fragment and sets the output parameters. 303 // Closes the fragment and sets the output parameters.
306 virtual void ReturnValue(Value* value); 304 virtual void ReturnValue(Value* value);
307 305
308 // Specify a computation as the final result. Adds a Bind instruction to
309 // the graph and branches on its value.
310 virtual void ReturnComputation(Computation* computation) {
311 BindInstr* defn = new BindInstr(temp_index(), computation);
312 AddInstruction(defn);
313 ReturnValue(new UseVal(defn));
314 }
315
316 // Output parameters. 306 // Output parameters.
317 TargetEntryInstr** true_successor_address_; 307 TargetEntryInstr** true_successor_address_;
318 TargetEntryInstr** false_successor_address_; 308 TargetEntryInstr** false_successor_address_;
319 309
320 intptr_t condition_token_index_; 310 intptr_t condition_token_index_;
321 }; 311 };
322 312
323 } // namespace dart 313 } // namespace dart
324 314
325 #endif // VM_FLOW_GRAPH_BUILDER_H_ 315 #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