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

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

Issue 10905182: Refactor building of StoreStaticField and StoreLocal to manually preserve value. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Florian's comments Created 8 years, 3 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 PushArgumentInstr* PushArgument(Value* value); 154 PushArgumentInstr* PushArgument(Value* value);
155 155
156 // This implementation shares state among visitors by using the builder. 156 // This implementation shares state among visitors by using the builder.
157 // The implementation is incorrect if a visitor that hits a return is not 157 // The implementation is incorrect if a visitor that hits a return is not
158 // actually added to the graph. 158 // actually added to the graph.
159 void AddReturnExit(ReturnInstr* return_instr) { 159 void AddReturnExit(ReturnInstr* return_instr) {
160 owner()->AddReturnExit(return_instr); 160 owner()->AddReturnExit(return_instr);
161 } 161 }
162 162
163 protected: 163 protected:
164 Definition* BuildStoreLocal(const LocalVariable& local, Value* value); 164 Definition* BuildStoreTemp(const LocalVariable& local, Value* value);
165 Definition* BuildStoreExprTemp(Value* value);
166 Definition* BuildLoadExprTemp();
167
168 Definition* BuildStoreLocal(const LocalVariable& local,
169 Value* value,
170 bool result_is_needed);
165 Definition* BuildLoadLocal(const LocalVariable& local); 171 Definition* BuildLoadLocal(const LocalVariable& local);
166 172
173 void HandleStoreLocal(StoreLocalNode* node, bool result_is_needed);
174
167 // Helpers for translating parts of the AST. 175 // Helpers for translating parts of the AST.
168 void TranslateArgumentList(const ArgumentListNode& node, 176 void TranslateArgumentList(const ArgumentListNode& node,
169 ZoneGrowableArray<Value*>* values); 177 ZoneGrowableArray<Value*>* values);
170 void BuildPushArguments(const ArgumentListNode& node, 178 void BuildPushArguments(const ArgumentListNode& node,
171 ZoneGrowableArray<PushArgumentInstr*>* values); 179 ZoneGrowableArray<PushArgumentInstr*>* values);
172 180
173 // Creates an instantiated type argument vector used in preparation of an 181 // Creates an instantiated type argument vector used in preparation of an
174 // allocation call. 182 // allocation call.
175 // May be called only if allocating an object of a parameterized class. 183 // May be called only if allocating an object of a parameterized class.
176 Value* BuildInstantiatedTypeArguments( 184 Value* BuildInstantiatedTypeArguments(
(...skipping 22 matching lines...) Expand all
199 Value* value, 207 Value* value,
200 const AbstractType& dst_type, 208 const AbstractType& dst_type,
201 const String& dst_name); 209 const String& dst_name);
202 210
203 // Perform a type check on the given value and return it. 211 // Perform a type check on the given value and return it.
204 Value* BuildAssignableValue(intptr_t token_pos, 212 Value* BuildAssignableValue(intptr_t token_pos,
205 Value* value, 213 Value* value,
206 const AbstractType& dst_type, 214 const AbstractType& dst_type,
207 const String& dst_name); 215 const String& dst_name);
208 216
209 enum ResultKind { 217 static const bool kResultNeeded = true;
210 kResultNotNeeded, 218 static const bool kResultNotNeeded = false;
211 kResultNeeded
212 };
213 219
214 Definition* BuildStoreIndexedValues(StoreIndexedNode* node, 220 Definition* BuildStoreIndexedValues(StoreIndexedNode* node,
215 bool result_is_needed); 221 bool result_is_needed);
216 222
217 void BuildInstanceSetterArguments( 223 void BuildInstanceSetterArguments(
218 InstanceSetterNode* node, 224 InstanceSetterNode* node,
219 ZoneGrowableArray<PushArgumentInstr*>* arguments, 225 ZoneGrowableArray<PushArgumentInstr*>* arguments,
220 bool result_is_needed); 226 bool result_is_needed);
221 227
222 virtual void BuildTypeTest(ComparisonNode* node); 228 virtual void BuildTypeTest(ComparisonNode* node);
(...skipping 14 matching lines...) Expand all
237 Value* BuildObjectAllocation(ConstructorCallNode* node); 243 Value* BuildObjectAllocation(ConstructorCallNode* node);
238 void BuildConstructorCall(ConstructorCallNode* node, 244 void BuildConstructorCall(ConstructorCallNode* node,
239 PushArgumentInstr* alloc_value); 245 PushArgumentInstr* alloc_value);
240 246
241 void BuildStoreContext(const LocalVariable& variable); 247 void BuildStoreContext(const LocalVariable& variable);
242 void BuildLoadContext(const LocalVariable& variable); 248 void BuildLoadContext(const LocalVariable& variable);
243 249
244 void BuildThrowNode(ThrowNode* node); 250 void BuildThrowNode(ThrowNode* node);
245 251
246 void BuildStaticSetter(StaticSetterNode* node, bool result_is_needed); 252 void BuildStaticSetter(StaticSetterNode* node, bool result_is_needed);
253 Definition* BuildStoreStaticField(StoreStaticFieldNode* node,
254 bool result_is_needed);
247 255
248 ClosureCallInstr* BuildClosureCall(ClosureCallNode* node); 256 ClosureCallInstr* BuildClosureCall(ClosureCallNode* node);
249 257
250 Value* BuildNullValue(); 258 Value* BuildNullValue();
251 259
252 private: 260 private:
253 // Specify a definition of the final result. Adds the definition to 261 // Specify a definition of the final result. Adds the definition to
254 // the graph, but normally overridden in subclasses. 262 // the graph, but normally overridden in subclasses.
255 virtual void ReturnDefinition(Definition* definition) { 263 virtual void ReturnDefinition(Definition* definition) {
256 Do(definition); 264 Do(definition);
(...skipping 27 matching lines...) Expand all
284 ValueGraphVisitor(FlowGraphBuilder* owner, intptr_t temp_index) 292 ValueGraphVisitor(FlowGraphBuilder* owner, intptr_t temp_index)
285 : EffectGraphVisitor(owner, temp_index), value_(NULL) { } 293 : EffectGraphVisitor(owner, temp_index), value_(NULL) { }
286 294
287 // Visit functions overridden by this class. 295 // Visit functions overridden by this class.
288 virtual void VisitLiteralNode(LiteralNode* node); 296 virtual void VisitLiteralNode(LiteralNode* node);
289 virtual void VisitAssignableNode(AssignableNode* node); 297 virtual void VisitAssignableNode(AssignableNode* node);
290 virtual void VisitConstructorCallNode(ConstructorCallNode* node); 298 virtual void VisitConstructorCallNode(ConstructorCallNode* node);
291 virtual void VisitBinaryOpNode(BinaryOpNode* node); 299 virtual void VisitBinaryOpNode(BinaryOpNode* node);
292 virtual void VisitConditionalExprNode(ConditionalExprNode* node); 300 virtual void VisitConditionalExprNode(ConditionalExprNode* node);
293 virtual void VisitLoadLocalNode(LoadLocalNode* node); 301 virtual void VisitLoadLocalNode(LoadLocalNode* node);
302 virtual void VisitStoreLocalNode(StoreLocalNode* node);
294 virtual void VisitStoreIndexedNode(StoreIndexedNode* node); 303 virtual void VisitStoreIndexedNode(StoreIndexedNode* node);
295 virtual void VisitStoreInstanceFieldNode(StoreInstanceFieldNode* node); 304 virtual void VisitStoreInstanceFieldNode(StoreInstanceFieldNode* node);
296 virtual void VisitInstanceSetterNode(InstanceSetterNode* node); 305 virtual void VisitInstanceSetterNode(InstanceSetterNode* node);
297 virtual void VisitThrowNode(ThrowNode* node); 306 virtual void VisitThrowNode(ThrowNode* node);
298 virtual void VisitClosureCallNode(ClosureCallNode* node); 307 virtual void VisitClosureCallNode(ClosureCallNode* node);
299 virtual void VisitStaticSetterNode(StaticSetterNode* node); 308 virtual void VisitStaticSetterNode(StaticSetterNode* node);
309 virtual void VisitStoreStaticFieldNode(StoreStaticFieldNode* node);
300 310
301 Value* value() const { return value_; } 311 Value* value() const { return value_; }
302 312
303 protected: 313 protected:
304 // Output parameters. 314 // Output parameters.
305 Value* value_; 315 Value* value_;
306 316
307 private: 317 private:
308 // Helper to set the output state to return a Value. 318 // Helper to set the output state to return a Value.
309 virtual void ReturnValue(Value* value) { value_ = value; } 319 virtual void ReturnValue(Value* value) { value_ = value; }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // Output parameters. 389 // Output parameters.
380 GrowableArray<TargetEntryInstr**> true_successor_addresses_; 390 GrowableArray<TargetEntryInstr**> true_successor_addresses_;
381 GrowableArray<TargetEntryInstr**> false_successor_addresses_; 391 GrowableArray<TargetEntryInstr**> false_successor_addresses_;
382 392
383 intptr_t condition_token_pos_; 393 intptr_t condition_token_pos_;
384 }; 394 };
385 395
386 } // namespace dart 396 } // namespace dart
387 397
388 #endif // VM_FLOW_GRAPH_BUILDER_H_ 398 #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