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

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

Issue 10857016: Refactored FlowGraphBuilder into a separate FlowGraph representation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revision based on Kevin's review. Created 8 years, 4 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 | « runtime/vm/flow_graph_allocator.cc ('k') | 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"
11 #include "vm/intermediate_language.h" 11 #include "vm/intermediate_language.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 class FlowGraph;
15 class Instruction; 16 class Instruction;
16 class ParsedFunction; 17 class ParsedFunction;
17 18
18 // Build a flow graph from a parsed function's AST. 19 // Build a flow graph from a parsed function's AST.
19 class FlowGraphBuilder: public ValueObject { 20 class FlowGraphBuilder: public ValueObject {
20 public: 21 public:
21 explicit FlowGraphBuilder(const ParsedFunction& parsed_function); 22 explicit FlowGraphBuilder(const ParsedFunction& parsed_function);
22 23
23 void BuildGraph(bool for_optimized, bool use_ssa); 24 FlowGraph* BuildGraph();
24 25
25 const ParsedFunction& parsed_function() const { return parsed_function_; } 26 const ParsedFunction& parsed_function() const { return parsed_function_; }
26 27
27 const GrowableArray<BlockEntryInstr*>& postorder_block_entries() const {
28 return postorder_block_entries_;
29 }
30
31 void Bailout(const char* reason); 28 void Bailout(const char* reason);
32 29
33 void set_context_level(intptr_t value) { context_level_ = value; } 30 void set_context_level(intptr_t value) { context_level_ = value; }
34 intptr_t context_level() const { return context_level_; } 31 intptr_t context_level() const { return context_level_; }
35 32
36 // Each try in this function gets its own try index. 33 // Each try in this function gets its own try index.
37 intptr_t AllocateTryIndex() { return ++last_used_try_index_; } 34 intptr_t AllocateTryIndex() { return ++last_used_try_index_; }
38 35
39 // Manage the currently active try index. 36 // Manage the currently active try index.
40 void set_try_index(intptr_t value) { try_index_ = value; } 37 void set_try_index(intptr_t value) { try_index_ = value; }
41 intptr_t try_index() const { return try_index_; } 38 intptr_t try_index() const { return try_index_; }
42 39
43 void AddCatchEntry(TargetEntryInstr* entry); 40 void AddCatchEntry(TargetEntryInstr* entry);
44 41
45 intptr_t current_ssa_temp_index() const { 42 intptr_t copied_parameter_count() const {
46 return current_ssa_temp_index_; 43 return copied_parameter_count_;
47 } 44 }
48 45 intptr_t non_copied_parameter_count() const {
49 intptr_t alloc_ssa_temp_index() { 46 return non_copied_parameter_count_;
50 return current_ssa_temp_index_++;
51 } 47 }
52 48 intptr_t stack_local_count() const {
53 intptr_t copied_parameter_count() const { return copied_parameter_count_; } 49 return stack_local_count_;
50 }
54 51
55 private: 52 private:
56 intptr_t parameter_count() const { 53 intptr_t parameter_count() const {
57 return copied_parameter_count_ + non_copied_parameter_count_; 54 return copied_parameter_count_ + non_copied_parameter_count_;
58 } 55 }
59 intptr_t variable_count() const { 56 intptr_t variable_count() const {
60 return parameter_count() + stack_local_count_; 57 return parameter_count() + stack_local_count_;
61 } 58 }
62 59
63 void ComputeDominators(GrowableArray<BlockEntryInstr*>* preorder,
64 GrowableArray<intptr_t>* parent,
65 GrowableArray<BitVector*>* dominance_frontier);
66
67 void CompressPath(intptr_t start_index,
68 intptr_t current_index,
69 GrowableArray<intptr_t>* parent,
70 GrowableArray<intptr_t>* label);
71
72 void Rename(GrowableArray<PhiInstr*>* live_phis);
73 void RenameRecursive(BlockEntryInstr* block_entry,
74 GrowableArray<Value*>* env,
75 GrowableArray<PhiInstr*>* live_phis);
76
77 void InsertPhis(const GrowableArray<BlockEntryInstr*>& preorder,
78 const GrowableArray<BitVector*>& assigned_vars,
79 const GrowableArray<BitVector*>& dom_frontier);
80
81 void MarkLivePhis(GrowableArray<PhiInstr*>* live_phis);
82
83 const ParsedFunction& parsed_function_; 60 const ParsedFunction& parsed_function_;
84 61
85 const intptr_t copied_parameter_count_; 62 const intptr_t copied_parameter_count_;
86 const intptr_t non_copied_parameter_count_; 63 const intptr_t non_copied_parameter_count_;
87 const intptr_t stack_local_count_; // Does not include any parameters. 64 const intptr_t stack_local_count_; // Does not include any parameters.
88 65
89 GrowableArray<BlockEntryInstr*> preorder_block_entries_;
90 GrowableArray<BlockEntryInstr*> postorder_block_entries_;
91 intptr_t context_level_; 66 intptr_t context_level_;
92 intptr_t last_used_try_index_; 67 intptr_t last_used_try_index_;
93 intptr_t try_index_; 68 intptr_t try_index_;
94 GraphEntryInstr* graph_entry_; 69 GraphEntryInstr* graph_entry_;
95 intptr_t current_ssa_temp_index_;
96 70
97 DISALLOW_IMPLICIT_CONSTRUCTORS(FlowGraphBuilder); 71 DISALLOW_IMPLICIT_CONSTRUCTORS(FlowGraphBuilder);
98 }; 72 };
99 73
100 74
101 class TestGraphVisitor; 75 class TestGraphVisitor;
102 76
103 // Translate an AstNode to a control-flow graph fragment for its effects 77 // Translate an AstNode to a control-flow graph fragment for its effects
104 // (e.g., a statement or an expression in an effect context). Implements a 78 // (e.g., a statement or an expression in an effect context). Implements a
105 // function from an AstNode and next temporary index to a graph fragment 79 // function from an AstNode and next temporary index to a graph fragment
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 // Output parameters. 350 // Output parameters.
377 TargetEntryInstr** true_successor_address_; 351 TargetEntryInstr** true_successor_address_;
378 TargetEntryInstr** false_successor_address_; 352 TargetEntryInstr** false_successor_address_;
379 353
380 intptr_t condition_token_pos_; 354 intptr_t condition_token_pos_;
381 }; 355 };
382 356
383 } // namespace dart 357 } // namespace dart
384 358
385 #endif // VM_FLOW_GRAPH_BUILDER_H_ 359 #endif // VM_FLOW_GRAPH_BUILDER_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_allocator.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698