| OLD | NEW |
| 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 "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 friend class TempLocalScope; // For ReturnDefinition. | 445 friend class TempLocalScope; // For ReturnDefinition. |
| 446 | 446 |
| 447 // Helper to drop the result value. | 447 // Helper to drop the result value. |
| 448 virtual void ReturnValue(Value* value) { | 448 virtual void ReturnValue(Value* value) { |
| 449 Do(new DropTempsInstr(0, value)); | 449 Do(new DropTempsInstr(0, value)); |
| 450 } | 450 } |
| 451 | 451 |
| 452 // Specify a definition of the final result. Adds the definition to | 452 // Specify a definition of the final result. Adds the definition to |
| 453 // the graph, but normally overridden in subclasses. | 453 // the graph, but normally overridden in subclasses. |
| 454 virtual void ReturnDefinition(Definition* definition) { | 454 virtual void ReturnDefinition(Definition* definition) { |
| 455 Do(definition); | 455 // Constants have no effect, do not add them to graph otherwise SSA |
| 456 // builder will get confused. |
| 457 if (!definition->IsConstant()) { |
| 458 Do(definition); |
| 459 } |
| 456 } | 460 } |
| 457 | 461 |
| 458 // Shared global state. | 462 // Shared global state. |
| 459 FlowGraphBuilder* owner_; | 463 FlowGraphBuilder* owner_; |
| 460 | 464 |
| 461 // Output parameters. | 465 // Output parameters. |
| 462 Instruction* entry_; | 466 Instruction* entry_; |
| 463 Instruction* exit_; | 467 Instruction* exit_; |
| 464 }; | 468 }; |
| 465 | 469 |
| 466 | 470 |
| 467 // Translate an AstNode to a control-flow graph fragment for both its effects | 471 // Translate an AstNode to a control-flow graph fragment for both its effects |
| 468 // and value (e.g., for an expression in a value context). Implements a | 472 // and value (e.g., for an expression in a value context). Implements a |
| 469 // function from an AstNode and next temporary index to a graph fragment (as | 473 // function from an AstNode and next temporary index to a graph fragment (as |
| 470 // in the EffectGraphVisitor), a next temporary index, and an intermediate | 474 // in the EffectGraphVisitor), a next temporary index, and an intermediate |
| 471 // language Value. | 475 // language Value. |
| 472 class ValueGraphVisitor : public EffectGraphVisitor { | 476 class ValueGraphVisitor : public EffectGraphVisitor { |
| 473 public: | 477 public: |
| 474 explicit ValueGraphVisitor(FlowGraphBuilder* owner) | 478 explicit ValueGraphVisitor(FlowGraphBuilder* owner) |
| 475 : EffectGraphVisitor(owner), value_(NULL) { } | 479 : EffectGraphVisitor(owner), value_(NULL) { } |
| 476 | 480 |
| 477 // Visit functions overridden by this class. | 481 // Visit functions overridden by this class. |
| 478 virtual void VisitLiteralNode(LiteralNode* node); | |
| 479 virtual void VisitAssignableNode(AssignableNode* node); | 482 virtual void VisitAssignableNode(AssignableNode* node); |
| 480 virtual void VisitConstructorCallNode(ConstructorCallNode* node); | 483 virtual void VisitConstructorCallNode(ConstructorCallNode* node); |
| 481 virtual void VisitBinaryOpNode(BinaryOpNode* node); | 484 virtual void VisitBinaryOpNode(BinaryOpNode* node); |
| 482 virtual void VisitConditionalExprNode(ConditionalExprNode* node); | 485 virtual void VisitConditionalExprNode(ConditionalExprNode* node); |
| 483 virtual void VisitLoadLocalNode(LoadLocalNode* node); | 486 virtual void VisitLoadLocalNode(LoadLocalNode* node); |
| 484 virtual void VisitStoreIndexedNode(StoreIndexedNode* node); | 487 virtual void VisitStoreIndexedNode(StoreIndexedNode* node); |
| 485 virtual void VisitInstanceSetterNode(InstanceSetterNode* node); | 488 virtual void VisitInstanceSetterNode(InstanceSetterNode* node); |
| 486 virtual void VisitThrowNode(ThrowNode* node); | 489 virtual void VisitThrowNode(ThrowNode* node); |
| 487 virtual void VisitClosureCallNode(ClosureCallNode* node); | 490 virtual void VisitClosureCallNode(ClosureCallNode* node); |
| 488 virtual void VisitStaticSetterNode(StaticSetterNode* node); | 491 virtual void VisitStaticSetterNode(StaticSetterNode* node); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // Output parameters. | 570 // Output parameters. |
| 568 GrowableArray<TargetEntryInstr**> true_successor_addresses_; | 571 GrowableArray<TargetEntryInstr**> true_successor_addresses_; |
| 569 GrowableArray<TargetEntryInstr**> false_successor_addresses_; | 572 GrowableArray<TargetEntryInstr**> false_successor_addresses_; |
| 570 | 573 |
| 571 intptr_t condition_token_pos_; | 574 intptr_t condition_token_pos_; |
| 572 }; | 575 }; |
| 573 | 576 |
| 574 } // namespace dart | 577 } // namespace dart |
| 575 | 578 |
| 576 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 579 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |