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

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: Added flow_graph.{h,cc} 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
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/ast.h"
Kevin Millikin (Google) 2012/08/16 08:09:57 Are you sure you need to include this? I can't im
zerny-google 2012/08/16 11:52:27 Thanks. It was the parser.h I needed.
9 #include "vm/parser.h"
10 #include "vm/growable_array.h"
11 #include "vm/intermediate_language.h"
12
13 namespace dart {
14
15 // Class to incapsulate the construction and manipulation of the flow graph.
16 class FlowGraph: public ValueObject {
17 public:
18 // Build a flow graph from a parsed function's AST.
19 explicit FlowGraph(const ParsedFunction& parsed_function);
20
21 // Function properties.
22 const ParsedFunction& parsed_function() const {
23 return parsed_function_;
24 }
25 intptr_t parameter_count() const {
26 return copied_parameter_count_ + non_copied_parameter_count_;
27 }
28 intptr_t variable_count() const {
29 return parameter_count() + stack_local_count_;
30 }
31 intptr_t stack_local_count() const {
32 return stack_local_count_;
33 }
34 intptr_t copied_parameter_count() const {
35 return copied_parameter_count_;
36 }
37 intptr_t non_copied_parameter_count() const {
38 return non_copied_parameter_count_;
39 }
40
41 // Flow graph orders.
42 const GrowableArray<BlockEntryInstr*>& preorder() const {
43 return preorder_;
44 }
45 const GrowableArray<BlockEntryInstr*>& postorder() const {
46 return postorder_;
47 }
48 const GrowableArray<BlockEntryInstr*>& reverse_postorder() const {
49 return reverse_postorder_;
50 }
51
52 intptr_t max_virtual_register_number() const {
53 return current_ssa_temp_index();
54 }
55
56 // Operations on the flow graph.
57 void BuildGraph();
58 void ComputeSSA();
59
60 // TODO(zerny): Once the SSA is feature complete this should be removed.
61 void Bailout(const char* reason);
62
63 private:
64 void ComputeOrders();
Kevin Millikin (Google) 2012/08/16 08:09:57 I like the name DiscoverBlocks better. It seems m
zerny-google 2012/08/16 11:52:27 Ok
65
66 const ParsedFunction& parsed_function_;
Kevin Millikin (Google) 2012/08/16 08:09:57 Member variables should all be at the end of the p
zerny-google 2012/08/16 11:52:27 Done.
67 const intptr_t copied_parameter_count_;
68 const intptr_t non_copied_parameter_count_;
69 const intptr_t stack_local_count_;
70 GraphEntryInstr* graph_entry_;
71 GrowableArray<BlockEntryInstr*> preorder_;
72 GrowableArray<BlockEntryInstr*> postorder_;
73 GrowableArray<BlockEntryInstr*> reverse_postorder_;
74
75 // SSA transformation methods and fields.
76 void ComputeDominators(
77 GrowableArray<BlockEntryInstr*>* preorder,
78 GrowableArray<intptr_t>* parent,
79 GrowableArray<BitVector*>* dominance_frontier);
80
81 void CompressPath(
82 intptr_t start_index,
83 intptr_t current_index,
84 GrowableArray<intptr_t>* parent,
85 GrowableArray<intptr_t>* label);
86
87 void Rename(GrowableArray<PhiInstr*>* live_phis);
88 void RenameRecursive(
89 BlockEntryInstr* block_entry,
90 GrowableArray<Value*>* env,
91 GrowableArray<PhiInstr*>* live_phis);
92
93 void InsertPhis(
94 const GrowableArray<BlockEntryInstr*>& preorder,
95 const GrowableArray<BitVector*>& assigned_vars,
96 const GrowableArray<BitVector*>& dom_frontier);
97
98 void MarkLivePhis(GrowableArray<PhiInstr*>* live_phis);
99
100 intptr_t current_ssa_temp_index() const { return current_ssa_temp_index_; }
101 intptr_t alloc_ssa_temp_index() { return current_ssa_temp_index_++; }
102
103 GrowableArray<intptr_t> parent_;
Kevin Millikin (Google) 2012/08/16 08:09:57 These variables (parent_ and assigned_vars_) shoul
zerny-google 2012/08/16 11:52:27 Done.
104 GrowableArray<BitVector*> assigned_vars_;
105 intptr_t current_ssa_temp_index_;
106 };
107
108 } // namespace dart
109
110 #endif // VM_FLOW_GRAPH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698