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

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

Issue 10919004: Revert "Inlining of static calls with trivial function bodies." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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.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 FlowGraph;
16 class Instruction; 16 class Instruction;
17 class ParsedFunction; 17 class ParsedFunction;
18 18
19 // Build a flow graph from a parsed function's AST. 19 // Build a flow graph from a parsed function's AST.
20 class FlowGraphBuilder: public ValueObject { 20 class FlowGraphBuilder: public ValueObject {
21 public: 21 public:
22 explicit FlowGraphBuilder(const ParsedFunction& parsed_function); 22 explicit FlowGraphBuilder(const ParsedFunction& parsed_function);
23 23
24 enum InliningContext {
25 kNotInlining,
26 kValueContext,
27 kEffectContext,
28 kTestContext
29 };
30
31 FlowGraph* BuildGraph(); 24 FlowGraph* BuildGraph();
32 FlowGraph* BuildGraphForInlining(InliningContext context);
33 25
34 const ParsedFunction& parsed_function() const { return parsed_function_; } 26 const ParsedFunction& parsed_function() const { return parsed_function_; }
35 27
36 void Bailout(const char* reason); 28 void Bailout(const char* reason);
37 29
38 void set_context_level(intptr_t value) { context_level_ = value; } 30 void set_context_level(intptr_t value) { context_level_ = value; }
39 intptr_t context_level() const { return context_level_; } 31 intptr_t context_level() const { return context_level_; }
40 32
41 // Each try in this function gets its own try index. 33 // Each try in this function gets its own try index.
42 intptr_t AllocateTryIndex() { return ++last_used_try_index_; } 34 intptr_t AllocateTryIndex() { return ++last_used_try_index_; }
43 35
44 // Manage the currently active try index. 36 // Manage the currently active try index.
45 void set_try_index(intptr_t value) { try_index_ = value; } 37 void set_try_index(intptr_t value) { try_index_ = value; }
46 intptr_t try_index() const { return try_index_; } 38 intptr_t try_index() const { return try_index_; }
47 39
48 void AddCatchEntry(TargetEntryInstr* entry); 40 void AddCatchEntry(TargetEntryInstr* entry);
49 41
50 intptr_t copied_parameter_count() const { 42 intptr_t copied_parameter_count() const {
51 return copied_parameter_count_; 43 return copied_parameter_count_;
52 } 44 }
53 intptr_t non_copied_parameter_count() const { 45 intptr_t non_copied_parameter_count() const {
54 return non_copied_parameter_count_; 46 return non_copied_parameter_count_;
55 } 47 }
56 intptr_t stack_local_count() const { 48 intptr_t stack_local_count() const {
57 return stack_local_count_; 49 return stack_local_count_;
58 } 50 }
59 51
60 bool InInliningContext() const { return inlining_context_ != kNotInlining; }
61 void AddReturnExit(ReturnInstr* return_instr) {
62 if (InInliningContext()) {
63 ASSERT(exits_ != NULL);
64 exits_->Add(return_instr);
65 }
66 }
67
68 private: 52 private:
69 intptr_t parameter_count() const { 53 intptr_t parameter_count() const {
70 return copied_parameter_count_ + non_copied_parameter_count_; 54 return copied_parameter_count_ + non_copied_parameter_count_;
71 } 55 }
72 intptr_t variable_count() const { 56 intptr_t variable_count() const {
73 return parameter_count() + stack_local_count_; 57 return parameter_count() + stack_local_count_;
74 } 58 }
75 59
76 const ParsedFunction& parsed_function_; 60 const ParsedFunction& parsed_function_;
77 61
78 const intptr_t copied_parameter_count_; 62 const intptr_t copied_parameter_count_;
79 const intptr_t non_copied_parameter_count_; 63 const intptr_t non_copied_parameter_count_;
80 const intptr_t stack_local_count_; // Does not include any parameters. 64 const intptr_t stack_local_count_; // Does not include any parameters.
81 65
82 intptr_t context_level_; 66 intptr_t context_level_;
83 intptr_t last_used_try_index_; 67 intptr_t last_used_try_index_;
84 intptr_t try_index_; 68 intptr_t try_index_;
85 GraphEntryInstr* graph_entry_; 69 GraphEntryInstr* graph_entry_;
86 InliningContext inlining_context_;
87 ZoneGrowableArray<ReturnInstr*>* exits_;
88 70
89 DISALLOW_IMPLICIT_CONSTRUCTORS(FlowGraphBuilder); 71 DISALLOW_IMPLICIT_CONSTRUCTORS(FlowGraphBuilder);
90 }; 72 };
91 73
92 74
93 class TestGraphVisitor; 75 class TestGraphVisitor;
94 76
95 // 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
96 // (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
97 // 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 17 matching lines...) Expand all
115 97
116 FlowGraphBuilder* owner() const { return owner_; } 98 FlowGraphBuilder* owner() const { return owner_; }
117 intptr_t temp_index() const { return temp_index_; } 99 intptr_t temp_index() const { return temp_index_; }
118 Instruction* entry() const { return entry_; } 100 Instruction* entry() const { return entry_; }
119 Instruction* exit() const { return exit_; } 101 Instruction* exit() const { return exit_; }
120 102
121 bool is_empty() const { return entry_ == NULL; } 103 bool is_empty() const { return entry_ == NULL; }
122 bool is_open() const { return is_empty() || exit_ != NULL; } 104 bool is_open() const { return is_empty() || exit_ != NULL; }
123 105
124 void Bailout(const char* reason); 106 void Bailout(const char* reason);
125 void InlineBailout(const char* reason);
126 107
127 // Append a graph fragment to this graph. Assumes this graph is open. 108 // Append a graph fragment to this graph. Assumes this graph is open.
128 void Append(const EffectGraphVisitor& other_fragment); 109 void Append(const EffectGraphVisitor& other_fragment);
129 // Append a computation with one use. Assumes this graph is open. 110 // Append a computation with one use. Assumes this graph is open.
130 UseVal* Bind(Computation* computation); 111 UseVal* Bind(Computation* computation);
131 // Append a computation with no uses. Assumes this graph is open. 112 // Append a computation with no uses. Assumes this graph is open.
132 void Do(Computation* computation); 113 void Do(Computation* computation);
133 // Append a single (non-Definition, non-Entry) instruction. Assumes this 114 // Append a single (non-Definition, non-Entry) instruction. Assumes this
134 // graph is open. 115 // graph is open.
135 void AddInstruction(Instruction* instruction); 116 void AddInstruction(Instruction* instruction);
(...skipping 10 matching lines...) Expand all
146 // Append a 'while loop' test and back edge to this graph, depending on 127 // Append a 'while loop' test and back edge to this graph, depending on
147 // which parts are reachable. Afterward, the graph exit is the false 128 // which parts are reachable. Afterward, the graph exit is the false
148 // successor of the loop condition. 129 // successor of the loop condition.
149 void TieLoop(const TestGraphVisitor& test_fragment, 130 void TieLoop(const TestGraphVisitor& test_fragment,
150 const EffectGraphVisitor& body_fragment); 131 const EffectGraphVisitor& body_fragment);
151 132
152 // Wraps a value in a push-argument instruction and adds the result to the 133 // Wraps a value in a push-argument instruction and adds the result to the
153 // graph. 134 // graph.
154 PushArgumentInstr* PushArgument(Value* value); 135 PushArgumentInstr* PushArgument(Value* value);
155 136
156 // This implementation shares state among visitors by using the builder.
157 // The implementation is incorrect if a visitor that hits a return is not
158 // actually added to the graph.
159 void AddReturnExit(ReturnInstr* return_instr) {
160 owner()->AddReturnExit(return_instr);
161 }
162
163 protected: 137 protected:
164 Computation* BuildStoreLocal(const LocalVariable& local, Value* value); 138 Computation* BuildStoreLocal(const LocalVariable& local, Value* value);
165 Computation* BuildLoadLocal(const LocalVariable& local); 139 Computation* BuildLoadLocal(const LocalVariable& local);
166 140
167 // Helpers for translating parts of the AST. 141 // Helpers for translating parts of the AST.
168 void TranslateArgumentList(const ArgumentListNode& node, 142 void TranslateArgumentList(const ArgumentListNode& node,
169 ZoneGrowableArray<Value*>* values); 143 ZoneGrowableArray<Value*>* values);
170 void BuildPushArguments(const ArgumentListNode& node, 144 void BuildPushArguments(const ArgumentListNode& node,
171 ZoneGrowableArray<PushArgumentInstr*>* values); 145 ZoneGrowableArray<PushArgumentInstr*>* values);
172 146
(...skipping 203 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.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698