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

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: 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') | runtime/vm/flow_graph_builder.cc » ('J')
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* BuildStoreLocal(const LocalVariable& local,
165 Value* value,
166 bool result_is_needed);
165 Definition* BuildLoadLocal(const LocalVariable& local); 167 Definition* BuildLoadLocal(const LocalVariable& local);
166 168
169 void VisitStoreLocal(StoreLocalNode* node, bool result_is_needed);
170
167 // Helpers for translating parts of the AST. 171 // Helpers for translating parts of the AST.
168 void TranslateArgumentList(const ArgumentListNode& node, 172 void TranslateArgumentList(const ArgumentListNode& node,
169 ZoneGrowableArray<Value*>* values); 173 ZoneGrowableArray<Value*>* values);
170 void BuildPushArguments(const ArgumentListNode& node, 174 void BuildPushArguments(const ArgumentListNode& node,
171 ZoneGrowableArray<PushArgumentInstr*>* values); 175 ZoneGrowableArray<PushArgumentInstr*>* values);
172 176
173 // Creates an instantiated type argument vector used in preparation of an 177 // Creates an instantiated type argument vector used in preparation of an
174 // allocation call. 178 // allocation call.
175 // May be called only if allocating an object of a parameterized class. 179 // May be called only if allocating an object of a parameterized class.
176 Value* BuildInstantiatedTypeArguments( 180 Value* BuildInstantiatedTypeArguments(
(...skipping 22 matching lines...) Expand all
199 Value* value, 203 Value* value,
200 const AbstractType& dst_type, 204 const AbstractType& dst_type,
201 const String& dst_name); 205 const String& dst_name);
202 206
203 // Perform a type check on the given value and return it. 207 // Perform a type check on the given value and return it.
204 Value* BuildAssignableValue(intptr_t token_pos, 208 Value* BuildAssignableValue(intptr_t token_pos,
205 Value* value, 209 Value* value,
206 const AbstractType& dst_type, 210 const AbstractType& dst_type,
207 const String& dst_name); 211 const String& dst_name);
208 212
209 enum ResultKind { 213 static const bool kResultNeeded = true;
210 kResultNotNeeded, 214 static const bool kResultNotNeeded = false;
211 kResultNeeded
212 };
213 215
214 Definition* BuildStoreIndexedValues(StoreIndexedNode* node, 216 Definition* BuildStoreIndexedValues(StoreIndexedNode* node,
215 bool result_is_needed); 217 bool result_is_needed);
216 218
217 void BuildInstanceSetterArguments( 219 void BuildInstanceSetterArguments(
218 InstanceSetterNode* node, 220 InstanceSetterNode* node,
219 ZoneGrowableArray<PushArgumentInstr*>* arguments, 221 ZoneGrowableArray<PushArgumentInstr*>* arguments,
220 bool result_is_needed); 222 bool result_is_needed);
221 223
222 virtual void BuildTypeTest(ComparisonNode* node); 224 virtual void BuildTypeTest(ComparisonNode* node);
(...skipping 14 matching lines...) Expand all
237 Value* BuildObjectAllocation(ConstructorCallNode* node); 239 Value* BuildObjectAllocation(ConstructorCallNode* node);
238 void BuildConstructorCall(ConstructorCallNode* node, 240 void BuildConstructorCall(ConstructorCallNode* node,
239 PushArgumentInstr* alloc_value); 241 PushArgumentInstr* alloc_value);
240 242
241 void BuildStoreContext(const LocalVariable& variable); 243 void BuildStoreContext(const LocalVariable& variable);
242 void BuildLoadContext(const LocalVariable& variable); 244 void BuildLoadContext(const LocalVariable& variable);
243 245
244 void BuildThrowNode(ThrowNode* node); 246 void BuildThrowNode(ThrowNode* node);
245 247
246 void BuildStaticSetter(StaticSetterNode* node, bool result_is_needed); 248 void BuildStaticSetter(StaticSetterNode* node, bool result_is_needed);
249 Definition* BuildStoreStaticField(StoreStaticFieldNode* node,
250 bool result_is_needed);
247 251
248 ClosureCallInstr* BuildClosureCall(ClosureCallNode* node); 252 ClosureCallInstr* BuildClosureCall(ClosureCallNode* node);
249 253
250 Value* BuildNullValue(); 254 Value* BuildNullValue();
251 255
252 private: 256 private:
253 // Specify a definition of the final result. Adds the definition to 257 // Specify a definition of the final result. Adds the definition to
254 // the graph, but normally overridden in subclasses. 258 // the graph, but normally overridden in subclasses.
255 virtual void ReturnDefinition(Definition* definition) { 259 virtual void ReturnDefinition(Definition* definition) {
256 Do(definition); 260 Do(definition);
(...skipping 27 matching lines...) Expand all
284 ValueGraphVisitor(FlowGraphBuilder* owner, intptr_t temp_index) 288 ValueGraphVisitor(FlowGraphBuilder* owner, intptr_t temp_index)
285 : EffectGraphVisitor(owner, temp_index), value_(NULL) { } 289 : EffectGraphVisitor(owner, temp_index), value_(NULL) { }
286 290
287 // Visit functions overridden by this class. 291 // Visit functions overridden by this class.
288 virtual void VisitLiteralNode(LiteralNode* node); 292 virtual void VisitLiteralNode(LiteralNode* node);
289 virtual void VisitAssignableNode(AssignableNode* node); 293 virtual void VisitAssignableNode(AssignableNode* node);
290 virtual void VisitConstructorCallNode(ConstructorCallNode* node); 294 virtual void VisitConstructorCallNode(ConstructorCallNode* node);
291 virtual void VisitBinaryOpNode(BinaryOpNode* node); 295 virtual void VisitBinaryOpNode(BinaryOpNode* node);
292 virtual void VisitConditionalExprNode(ConditionalExprNode* node); 296 virtual void VisitConditionalExprNode(ConditionalExprNode* node);
293 virtual void VisitLoadLocalNode(LoadLocalNode* node); 297 virtual void VisitLoadLocalNode(LoadLocalNode* node);
298 virtual void VisitStoreLocalNode(StoreLocalNode* node);
294 virtual void VisitStoreIndexedNode(StoreIndexedNode* node); 299 virtual void VisitStoreIndexedNode(StoreIndexedNode* node);
295 virtual void VisitStoreInstanceFieldNode(StoreInstanceFieldNode* node); 300 virtual void VisitStoreInstanceFieldNode(StoreInstanceFieldNode* node);
296 virtual void VisitInstanceSetterNode(InstanceSetterNode* node); 301 virtual void VisitInstanceSetterNode(InstanceSetterNode* node);
297 virtual void VisitThrowNode(ThrowNode* node); 302 virtual void VisitThrowNode(ThrowNode* node);
298 virtual void VisitClosureCallNode(ClosureCallNode* node); 303 virtual void VisitClosureCallNode(ClosureCallNode* node);
299 virtual void VisitStaticSetterNode(StaticSetterNode* node); 304 virtual void VisitStaticSetterNode(StaticSetterNode* node);
305 virtual void VisitStoreStaticFieldNode(StoreStaticFieldNode* node);
300 306
301 Value* value() const { return value_; } 307 Value* value() const { return value_; }
302 308
303 protected: 309 protected:
304 // Output parameters. 310 // Output parameters.
305 Value* value_; 311 Value* value_;
306 312
307 private: 313 private:
308 // Helper to set the output state to return a Value. 314 // Helper to set the output state to return a Value.
309 virtual void ReturnValue(Value* value) { value_ = value; } 315 virtual void ReturnValue(Value* value) { value_ = value; }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // Output parameters. 385 // Output parameters.
380 GrowableArray<TargetEntryInstr**> true_successor_addresses_; 386 GrowableArray<TargetEntryInstr**> true_successor_addresses_;
381 GrowableArray<TargetEntryInstr**> false_successor_addresses_; 387 GrowableArray<TargetEntryInstr**> false_successor_addresses_;
382 388
383 intptr_t condition_token_pos_; 389 intptr_t condition_token_pos_;
384 }; 390 };
385 391
386 } // namespace dart 392 } // namespace dart
387 393
388 #endif // VM_FLOW_GRAPH_BUILDER_H_ 394 #endif // VM_FLOW_GRAPH_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | runtime/vm/flow_graph_builder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698