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

Side by Side Diff: runtime/vm/flow_graph.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/compiler.cc ('k') | runtime/vm/flow_graph.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_FLOW_GRAPH_H_
6 #define VM_FLOW_GRAPH_H_
7
8 #include "vm/growable_array.h"
9 #include "vm/parser.h"
10
11 namespace dart {
12
13 class BlockEntryInstr;
14 class FlowGraphBuilder;
15 class GraphEntryInstr;
16 class PhiInstr;
17 class Value;
18
19 // Class to incapsulate the construction and manipulation of the flow graph.
20 class FlowGraph: public ZoneAllocated {
21 public:
22 FlowGraph(const FlowGraphBuilder& builder, GraphEntryInstr* graph_entry);
23
24 // Function properties.
25 const ParsedFunction& parsed_function() const {
26 return parsed_function_;
27 }
28 intptr_t parameter_count() const {
29 return copied_parameter_count_ + non_copied_parameter_count_;
30 }
31 intptr_t variable_count() const {
32 return parameter_count() + stack_local_count_;
33 }
34 intptr_t stack_local_count() const {
35 return stack_local_count_;
36 }
37 intptr_t copied_parameter_count() const {
38 return copied_parameter_count_;
39 }
40 intptr_t non_copied_parameter_count() const {
41 return non_copied_parameter_count_;
42 }
43
44 // Flow graph orders.
45 const GrowableArray<BlockEntryInstr*>& preorder() const {
46 return preorder_;
47 }
48 const GrowableArray<BlockEntryInstr*>& postorder() const {
49 return postorder_;
50 }
51 const GrowableArray<BlockEntryInstr*>& reverse_postorder() const {
52 return reverse_postorder_;
53 }
54
55 intptr_t max_virtual_register_number() const {
56 return current_ssa_temp_index();
57 }
58
59 // Operations on the flow graph.
60 void ComputeSSA();
61
62 // TODO(zerny): Once the SSA is feature complete this should be removed.
63 void Bailout(const char* reason) const;
64
65 private:
66 void DiscoverBlocks();
67
68 // SSA transformation methods and fields.
69 void ComputeDominators(
70 GrowableArray<BlockEntryInstr*>* preorder,
71 GrowableArray<intptr_t>* parent,
72 GrowableArray<BitVector*>* dominance_frontier);
73
74 void CompressPath(
75 intptr_t start_index,
76 intptr_t current_index,
77 GrowableArray<intptr_t>* parent,
78 GrowableArray<intptr_t>* label);
79
80 void Rename(GrowableArray<PhiInstr*>* live_phis);
81 void RenameRecursive(
82 BlockEntryInstr* block_entry,
83 GrowableArray<Value*>* env,
84 GrowableArray<PhiInstr*>* live_phis);
85
86 void InsertPhis(
87 const GrowableArray<BlockEntryInstr*>& preorder,
88 const GrowableArray<BitVector*>& assigned_vars,
89 const GrowableArray<BitVector*>& dom_frontier);
90
91 void MarkLivePhis(GrowableArray<PhiInstr*>* live_phis);
92
93 intptr_t current_ssa_temp_index() const { return current_ssa_temp_index_; }
94 intptr_t alloc_ssa_temp_index() { return current_ssa_temp_index_++; }
95
96 // DiscoverBlocks computes parent_ and assigned_vars_ which are then used
97 // if/when computing SSA.
98 GrowableArray<intptr_t> parent_;
99 GrowableArray<BitVector*> assigned_vars_;
100
101 intptr_t current_ssa_temp_index_;
102
103 // Flow graph fields.
104 const ParsedFunction& parsed_function_;
105 const intptr_t copied_parameter_count_;
106 const intptr_t non_copied_parameter_count_;
107 const intptr_t stack_local_count_;
108 GraphEntryInstr* graph_entry_;
109 GrowableArray<BlockEntryInstr*> preorder_;
110 GrowableArray<BlockEntryInstr*> postorder_;
111 GrowableArray<BlockEntryInstr*> reverse_postorder_;
112 };
113
114 } // namespace dart
115
116 #endif // VM_FLOW_GRAPH_H_
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698