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

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

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