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

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

Issue 11269040: More inlining flags and tuned heuristics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improved heuristics. Created 8 years, 1 month 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"
(...skipping 10 matching lines...) Expand all
21 public: 21 public:
22 explicit FlowGraphBuilder(const ParsedFunction& parsed_function); 22 explicit FlowGraphBuilder(const ParsedFunction& parsed_function);
23 23
24 enum InliningContext { 24 enum InliningContext {
25 kNotInlining, 25 kNotInlining,
26 kValueContext, 26 kValueContext,
27 kEffectContext, 27 kEffectContext,
28 kTestContext 28 kTestContext
29 }; 29 };
30 30
31 FlowGraph* BuildGraph(InliningContext context); 31 FlowGraph* BuildGraph(InliningContext context, intptr_t initial_loop_depth);
32 32
33 const ParsedFunction& parsed_function() const { return parsed_function_; } 33 const ParsedFunction& parsed_function() const { return parsed_function_; }
34 34
35 void Bailout(const char* reason); 35 void Bailout(const char* reason);
36 36
37 intptr_t AllocateBlockId() { return ++last_used_block_id_; } 37 intptr_t AllocateBlockId() { return ++last_used_block_id_; }
38 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; } 38 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; }
39 39
40 void set_context_level(intptr_t value) { context_level_ = value; } 40 void set_context_level(intptr_t value) { context_level_ = value; }
41 intptr_t context_level() const { return context_level_; } 41 intptr_t context_level() const { return context_level_; }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // (e.g., a statement or an expression in an effect context). Implements a 99 // (e.g., a statement or an expression in an effect context). Implements a
100 // function from an AstNode and next temporary index to a graph fragment 100 // function from an AstNode and next temporary index to a graph fragment
101 // with a single entry and at most one exit. The fragment is represented by 101 // with a single entry and at most one exit. The fragment is represented by
102 // an (entry, exit) pair of Instruction pointers: 102 // an (entry, exit) pair of Instruction pointers:
103 // 103 //
104 // - (NULL, NULL): an empty and open graph fragment 104 // - (NULL, NULL): an empty and open graph fragment
105 // - (i0, NULL): a closed graph fragment which has only non-local exits 105 // - (i0, NULL): a closed graph fragment which has only non-local exits
106 // - (i0, i1): an open graph fragment 106 // - (i0, i1): an open graph fragment
107 class EffectGraphVisitor : public AstNodeVisitor { 107 class EffectGraphVisitor : public AstNodeVisitor {
108 public: 108 public:
109 EffectGraphVisitor(FlowGraphBuilder* owner, intptr_t temp_index) 109 EffectGraphVisitor(FlowGraphBuilder* owner,
110 intptr_t temp_index,
111 intptr_t loop_depth)
110 : owner_(owner), 112 : owner_(owner),
111 temp_index_(temp_index), 113 temp_index_(temp_index),
112 entry_(NULL), 114 entry_(NULL),
113 exit_(NULL) { } 115 exit_(NULL),
116 loop_depth_(loop_depth) { }
114 117
115 #define DEFINE_VISIT(type, name) virtual void Visit##type(type* node); 118 #define DEFINE_VISIT(type, name) virtual void Visit##type(type* node);
116 NODE_LIST(DEFINE_VISIT) 119 NODE_LIST(DEFINE_VISIT)
117 #undef DEFINE_VISIT 120 #undef DEFINE_VISIT
118 121
119 FlowGraphBuilder* owner() const { return owner_; } 122 FlowGraphBuilder* owner() const { return owner_; }
120 intptr_t temp_index() const { return temp_index_; } 123 intptr_t temp_index() const { return temp_index_; }
124 intptr_t loop_depth() const { return loop_depth_; }
121 Instruction* entry() const { return entry_; } 125 Instruction* entry() const { return entry_; }
122 Instruction* exit() const { return exit_; } 126 Instruction* exit() const { return exit_; }
123 127
124 bool is_empty() const { return entry_ == NULL; } 128 bool is_empty() const { return entry_ == NULL; }
125 bool is_open() const { return is_empty() || exit_ != NULL; } 129 bool is_open() const { return is_empty() || exit_ != NULL; }
126 130
127 void Bailout(const char* reason); 131 void Bailout(const char* reason);
128 void InlineBailout(const char* reason); 132 void InlineBailout(const char* reason);
129 133
130 // Append a graph fragment to this graph. Assumes this graph is open. 134 // Append a graph fragment to this graph. Assumes this graph is open.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 285
282 // Shared global state. 286 // Shared global state.
283 FlowGraphBuilder* owner_; 287 FlowGraphBuilder* owner_;
284 288
285 // Input parameters. 289 // Input parameters.
286 intptr_t temp_index_; 290 intptr_t temp_index_;
287 291
288 // Output parameters. 292 // Output parameters.
289 Instruction* entry_; 293 Instruction* entry_;
290 Instruction* exit_; 294 Instruction* exit_;
295
296 // Internal state.
297 const intptr_t loop_depth_;
291 }; 298 };
292 299
293 300
294 // Translate an AstNode to a control-flow graph fragment for both its effects 301 // Translate an AstNode to a control-flow graph fragment for both its effects
295 // and value (e.g., for an expression in a value context). Implements a 302 // and value (e.g., for an expression in a value context). Implements a
296 // function from an AstNode and next temporary index to a graph fragment (as 303 // function from an AstNode and next temporary index to a graph fragment (as
297 // in the EffectGraphVisitor), a next temporary index, and an intermediate 304 // in the EffectGraphVisitor), a next temporary index, and an intermediate
298 // language Value. 305 // language Value.
299 class ValueGraphVisitor : public EffectGraphVisitor { 306 class ValueGraphVisitor : public EffectGraphVisitor {
300 public: 307 public:
301 ValueGraphVisitor(FlowGraphBuilder* owner, intptr_t temp_index) 308 ValueGraphVisitor(FlowGraphBuilder* owner,
302 : EffectGraphVisitor(owner, temp_index), value_(NULL) { } 309 intptr_t temp_index,
310 intptr_t loop_depth)
311 : EffectGraphVisitor(owner, temp_index, loop_depth), value_(NULL) { }
303 312
304 // Visit functions overridden by this class. 313 // Visit functions overridden by this class.
305 virtual void VisitLiteralNode(LiteralNode* node); 314 virtual void VisitLiteralNode(LiteralNode* node);
306 virtual void VisitAssignableNode(AssignableNode* node); 315 virtual void VisitAssignableNode(AssignableNode* node);
307 virtual void VisitConstructorCallNode(ConstructorCallNode* node); 316 virtual void VisitConstructorCallNode(ConstructorCallNode* node);
308 virtual void VisitBinaryOpNode(BinaryOpNode* node); 317 virtual void VisitBinaryOpNode(BinaryOpNode* node);
309 virtual void VisitConditionalExprNode(ConditionalExprNode* node); 318 virtual void VisitConditionalExprNode(ConditionalExprNode* node);
310 virtual void VisitLoadLocalNode(LoadLocalNode* node); 319 virtual void VisitLoadLocalNode(LoadLocalNode* node);
311 virtual void VisitStoreLocalNode(StoreLocalNode* node); 320 virtual void VisitStoreLocalNode(StoreLocalNode* node);
312 virtual void VisitStoreIndexedNode(StoreIndexedNode* node); 321 virtual void VisitStoreIndexedNode(StoreIndexedNode* node);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // 362 //
354 // We expect that AstNode in test contexts either have only nonlocal exits 363 // We expect that AstNode in test contexts either have only nonlocal exits
355 // or else control flow has both true and false successors. 364 // or else control flow has both true and false successors.
356 // 365 //
357 // The cis and token_pos are used in checked mode to verify that the 366 // The cis and token_pos are used in checked mode to verify that the
358 // condition of the test is of type bool. 367 // condition of the test is of type bool.
359 class TestGraphVisitor : public ValueGraphVisitor { 368 class TestGraphVisitor : public ValueGraphVisitor {
360 public: 369 public:
361 TestGraphVisitor(FlowGraphBuilder* owner, 370 TestGraphVisitor(FlowGraphBuilder* owner,
362 intptr_t temp_index, 371 intptr_t temp_index,
372 intptr_t loop_depth,
363 intptr_t condition_token_pos) 373 intptr_t condition_token_pos)
364 : ValueGraphVisitor(owner, temp_index), 374 : ValueGraphVisitor(owner, temp_index, loop_depth),
365 true_successor_addresses_(1), 375 true_successor_addresses_(1),
366 false_successor_addresses_(1), 376 false_successor_addresses_(1),
367 condition_token_pos_(condition_token_pos) { } 377 condition_token_pos_(condition_token_pos) { }
368 378
369 void IfFalseGoto(JoinEntryInstr* join) const; 379 void IfFalseGoto(JoinEntryInstr* join) const;
370 void IfTrueGoto(JoinEntryInstr* join) const; 380 void IfTrueGoto(JoinEntryInstr* join) const;
371 381
372 BlockEntryInstr* CreateTrueSuccessor() const; 382 BlockEntryInstr* CreateTrueSuccessor() const;
373 BlockEntryInstr* CreateFalseSuccessor() const; 383 BlockEntryInstr* CreateFalseSuccessor() const;
374 384
(...skipping 23 matching lines...) Expand all
398 // Output parameters. 408 // Output parameters.
399 GrowableArray<TargetEntryInstr**> true_successor_addresses_; 409 GrowableArray<TargetEntryInstr**> true_successor_addresses_;
400 GrowableArray<TargetEntryInstr**> false_successor_addresses_; 410 GrowableArray<TargetEntryInstr**> false_successor_addresses_;
401 411
402 intptr_t condition_token_pos_; 412 intptr_t condition_token_pos_;
403 }; 413 };
404 414
405 } // namespace dart 415 } // namespace dart
406 416
407 #endif // VM_FLOW_GRAPH_BUILDER_H_ 417 #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