| 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 "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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // or else control flow has both true and false successors. | 336 // or else control flow has both true and false successors. |
| 337 // | 337 // |
| 338 // The cis and token_pos are used in checked mode to verify that the | 338 // The cis and token_pos are used in checked mode to verify that the |
| 339 // condition of the test is of type bool. | 339 // condition of the test is of type bool. |
| 340 class TestGraphVisitor : public ValueGraphVisitor { | 340 class TestGraphVisitor : public ValueGraphVisitor { |
| 341 public: | 341 public: |
| 342 TestGraphVisitor(FlowGraphBuilder* owner, | 342 TestGraphVisitor(FlowGraphBuilder* owner, |
| 343 intptr_t temp_index, | 343 intptr_t temp_index, |
| 344 intptr_t condition_token_pos) | 344 intptr_t condition_token_pos) |
| 345 : ValueGraphVisitor(owner, temp_index), | 345 : ValueGraphVisitor(owner, temp_index), |
| 346 true_successor_address_(NULL), | 346 true_successor_addresses_(1), |
| 347 false_successor_address_(NULL), | 347 false_successor_addresses_(1), |
| 348 condition_token_pos_(condition_token_pos) { } | 348 condition_token_pos_(condition_token_pos) { } |
| 349 | 349 |
| 350 TargetEntryInstr** true_successor_address() const { | 350 void IfFalseGoto(JoinEntryInstr* join) const; |
| 351 ASSERT(true_successor_address_ != NULL); | 351 void IfTrueGoto(JoinEntryInstr* join) const; |
| 352 return true_successor_address_; | 352 |
| 353 } | 353 BlockEntryInstr* CreateTrueSuccessor() const; |
| 354 TargetEntryInstr** false_successor_address() const { | 354 BlockEntryInstr* CreateFalseSuccessor() const; |
| 355 ASSERT(false_successor_address_ != NULL); | 355 |
| 356 return false_successor_address_; | 356 virtual void VisitBinaryOpNode(BinaryOpNode* node); |
| 357 } | |
| 358 | 357 |
| 359 intptr_t condition_token_pos() const { return condition_token_pos_; } | 358 intptr_t condition_token_pos() const { return condition_token_pos_; } |
| 360 | 359 |
| 361 private: | 360 private: |
| 362 // Construct and concatenate a Branch instruction to this graph fragment. | 361 // Construct and concatenate a Branch instruction to this graph fragment. |
| 363 // Closes the fragment and sets the output parameters. | 362 // Closes the fragment and sets the output parameters. |
| 364 virtual void ReturnValue(Value* value); | 363 virtual void ReturnValue(Value* value); |
| 365 | 364 |
| 366 // Either merges the computation into BranchInstr (Comparison, BooleanNegate) | 365 // Either merges the computation into BranchInstr (Comparison, BooleanNegate) |
| 367 // or adds a Bind instruction to the graph and returns its temporary value. | 366 // or adds a Bind instruction to the graph and returns its temporary value. |
| 368 virtual void ReturnComputation(Computation* computation); | 367 virtual void ReturnComputation(Computation* computation); |
| 369 | 368 |
| 370 void MergeBranchWithComparison(ComparisonComp* comp); | 369 void MergeBranchWithComparison(ComparisonComp* comp); |
| 371 void MergeBranchWithNegate(BooleanNegateComp* comp); | 370 void MergeBranchWithNegate(BooleanNegateComp* comp); |
| 372 | 371 |
| 372 BlockEntryInstr* CreateSuccessorFor( |
| 373 const GrowableArray<TargetEntryInstr**>& branches) const; |
| 374 |
| 375 void ConnectBranchesTo( |
| 376 const GrowableArray<TargetEntryInstr**>& branches, |
| 377 JoinEntryInstr* join) const; |
| 378 |
| 373 // Output parameters. | 379 // Output parameters. |
| 374 TargetEntryInstr** true_successor_address_; | 380 GrowableArray<TargetEntryInstr**> true_successor_addresses_; |
| 375 TargetEntryInstr** false_successor_address_; | 381 GrowableArray<TargetEntryInstr**> false_successor_addresses_; |
| 376 | 382 |
| 377 intptr_t condition_token_pos_; | 383 intptr_t condition_token_pos_; |
| 378 }; | 384 }; |
| 379 | 385 |
| 380 } // namespace dart | 386 } // namespace dart |
| 381 | 387 |
| 382 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 388 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |