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

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

Issue 16888013: Revert "Initial implementation of on-stack replacement (OSR)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 FlowGraph* caller_graph_; 94 FlowGraph* caller_graph_;
95 Definition* call_; 95 Definition* call_;
96 GrowableArray<Data> exits_; 96 GrowableArray<Data> exits_;
97 }; 97 };
98 98
99 99
100 // Build a flow graph from a parsed function's AST. 100 // Build a flow graph from a parsed function's AST.
101 class FlowGraphBuilder: public ValueObject { 101 class FlowGraphBuilder: public ValueObject {
102 public: 102 public:
103 // The inlining context is NULL if not inlining. The osr_id is the deopt 103 // The inlining context is NULL if not inlining.
104 // id of the OSR entry or Isolate::kNoDeoptId if not compiling for OSR.
105 FlowGraphBuilder(ParsedFunction* parsed_function, 104 FlowGraphBuilder(ParsedFunction* parsed_function,
106 const Array& ic_data_array, 105 const Array& ic_data_array,
107 InlineExitCollector* exit_collector, 106 InlineExitCollector* exit_collector);
108 intptr_t osr_id);
109 107
110 FlowGraph* BuildGraph(); 108 FlowGraph* BuildGraph();
111 109
112 ParsedFunction* parsed_function() const { return parsed_function_; } 110 ParsedFunction* parsed_function() const { return parsed_function_; }
113 const Array& ic_data_array() const { return ic_data_array_; } 111 const Array& ic_data_array() const { return ic_data_array_; }
114 112
115 void Bailout(const char* reason); 113 void Bailout(const char* reason);
116 114
117 intptr_t AllocateBlockId() { return ++last_used_block_id_; } 115 intptr_t AllocateBlockId() { return ++last_used_block_id_; }
118 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; } 116 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; }
(...skipping 19 matching lines...) Expand all
138 intptr_t num_stack_locals() const { 136 intptr_t num_stack_locals() const {
139 return num_stack_locals_; 137 return num_stack_locals_;
140 } 138 }
141 139
142 bool IsInlining() const { return (exit_collector_ != NULL); } 140 bool IsInlining() const { return (exit_collector_ != NULL); }
143 InlineExitCollector* exit_collector() const { return exit_collector_; } 141 InlineExitCollector* exit_collector() const { return exit_collector_; }
144 142
145 intptr_t args_pushed() const { return args_pushed_; } 143 intptr_t args_pushed() const { return args_pushed_; }
146 void add_args_pushed(intptr_t n) { args_pushed_ += n; } 144 void add_args_pushed(intptr_t n) { args_pushed_ += n; }
147 145
148 // When compiling for OSR, remove blocks that are not reachable from the
149 // OSR entry point.
150 void PruneUnreachable();
151
152 private: 146 private:
153 intptr_t parameter_count() const { 147 intptr_t parameter_count() const {
154 return num_copied_params_ + num_non_copied_params_; 148 return num_copied_params_ + num_non_copied_params_;
155 } 149 }
156 intptr_t variable_count() const { 150 intptr_t variable_count() const {
157 return parameter_count() + num_stack_locals_; 151 return parameter_count() + num_stack_locals_;
158 } 152 }
159 153
160 ParsedFunction* parsed_function_; 154 ParsedFunction* parsed_function_;
161 const Array& ic_data_array_; 155 const Array& ic_data_array_;
162 156
163 const intptr_t num_copied_params_; 157 const intptr_t num_copied_params_;
164 const intptr_t num_non_copied_params_; 158 const intptr_t num_non_copied_params_;
165 const intptr_t num_stack_locals_; // Does not include any parameters. 159 const intptr_t num_stack_locals_; // Does not include any parameters.
166 InlineExitCollector* const exit_collector_; 160 InlineExitCollector* const exit_collector_;
167 161
168 intptr_t last_used_block_id_; 162 intptr_t last_used_block_id_;
169 intptr_t context_level_; 163 intptr_t context_level_;
170 intptr_t last_used_try_index_; 164 intptr_t last_used_try_index_;
171 intptr_t try_index_; 165 intptr_t try_index_;
172 GraphEntryInstr* graph_entry_; 166 GraphEntryInstr* graph_entry_;
173 167
174 // Outgoing argument stack height. 168 // Outgoing argument stack height.
175 intptr_t args_pushed_; 169 intptr_t args_pushed_;
176 170
177 // The deopt id of the OSR entry or Isolate::kNoDeoptId if not compiling
178 // for OSR.
179 const intptr_t osr_id_;
180
181 DISALLOW_IMPLICIT_CONSTRUCTORS(FlowGraphBuilder); 171 DISALLOW_IMPLICIT_CONSTRUCTORS(FlowGraphBuilder);
182 }; 172 };
183 173
184 174
185 class TestGraphVisitor; 175 class TestGraphVisitor;
186 176
187 // Translate an AstNode to a control-flow graph fragment for its effects 177 // Translate an AstNode to a control-flow graph fragment for its effects
188 // (e.g., a statement or an expression in an effect context). Implements a 178 // (e.g., a statement or an expression in an effect context). Implements a
189 // function from an AstNode and next temporary index to a graph fragment 179 // function from an AstNode and next temporary index to a graph fragment
190 // with a single entry and at most one exit. The fragment is represented by 180 // with a single entry and at most one exit. The fragment is represented by
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 222
233 // Append a 'diamond' branch and join to this graph, depending on which 223 // Append a 'diamond' branch and join to this graph, depending on which
234 // parts are reachable. Assumes this graph is open. 224 // parts are reachable. Assumes this graph is open.
235 void Join(const TestGraphVisitor& test_fragment, 225 void Join(const TestGraphVisitor& test_fragment,
236 const EffectGraphVisitor& true_fragment, 226 const EffectGraphVisitor& true_fragment,
237 const EffectGraphVisitor& false_fragment); 227 const EffectGraphVisitor& false_fragment);
238 228
239 // Append a 'while loop' test and back edge to this graph, depending on 229 // Append a 'while loop' test and back edge to this graph, depending on
240 // which parts are reachable. Afterward, the graph exit is the false 230 // which parts are reachable. Afterward, the graph exit is the false
241 // successor of the loop condition. 231 // successor of the loop condition.
242 void TieLoop(intptr_t token_pos, 232 void TieLoop(const TestGraphVisitor& test_fragment,
243 const TestGraphVisitor& test_fragment,
244 const EffectGraphVisitor& body_fragment); 233 const EffectGraphVisitor& body_fragment);
245 234
246 // Wraps a value in a push-argument instruction and adds the result to the 235 // Wraps a value in a push-argument instruction and adds the result to the
247 // graph. 236 // graph.
248 PushArgumentInstr* PushArgument(Value* value); 237 PushArgumentInstr* PushArgument(Value* value);
249 238
250 // This implementation shares state among visitors by using the builder. 239 // This implementation shares state among visitors by using the builder.
251 // The implementation is incorrect if a visitor that hits a return is not 240 // The implementation is incorrect if a visitor that hits a return is not
252 // actually added to the graph. 241 // actually added to the graph.
253 void AddReturnExit(intptr_t token_pos, Value* value); 242 void AddReturnExit(intptr_t token_pos, Value* value);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // Output parameters. 501 // Output parameters.
513 GrowableArray<TargetEntryInstr**> true_successor_addresses_; 502 GrowableArray<TargetEntryInstr**> true_successor_addresses_;
514 GrowableArray<TargetEntryInstr**> false_successor_addresses_; 503 GrowableArray<TargetEntryInstr**> false_successor_addresses_;
515 504
516 intptr_t condition_token_pos_; 505 intptr_t condition_token_pos_;
517 }; 506 };
518 507
519 } // namespace dart 508 } // namespace dart
520 509
521 #endif // VM_FLOW_GRAPH_BUILDER_H_ 510 #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