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

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: out/DebugIA32/dart --ignore-unrecognized-flags /usr/local/google/home/zerny/src/dart/dart/tests/co1… 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
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 279
276 // Shared global state. 280 // Shared global state.
277 FlowGraphBuilder* owner_; 281 FlowGraphBuilder* owner_;
278 282
279 // Input parameters. 283 // Input parameters.
280 intptr_t temp_index_; 284 intptr_t temp_index_;
281 285
282 // Output parameters. 286 // Output parameters.
283 Instruction* entry_; 287 Instruction* entry_;
284 Instruction* exit_; 288 Instruction* exit_;
289
290 // Internal state.
291 intptr_t loop_depth_;
285 }; 292 };
286 293
287 294
288 // Translate an AstNode to a control-flow graph fragment for both its effects 295 // Translate an AstNode to a control-flow graph fragment for both its effects
289 // and value (e.g., for an expression in a value context). Implements a 296 // and value (e.g., for an expression in a value context). Implements a
290 // function from an AstNode and next temporary index to a graph fragment (as 297 // function from an AstNode and next temporary index to a graph fragment (as
291 // in the EffectGraphVisitor), a next temporary index, and an intermediate 298 // in the EffectGraphVisitor), a next temporary index, and an intermediate
292 // language Value. 299 // language Value.
293 class ValueGraphVisitor : public EffectGraphVisitor { 300 class ValueGraphVisitor : public EffectGraphVisitor {
294 public: 301 public:
295 ValueGraphVisitor(FlowGraphBuilder* owner, intptr_t temp_index) 302 ValueGraphVisitor(FlowGraphBuilder* owner,
296 : EffectGraphVisitor(owner, temp_index), value_(NULL) { } 303 intptr_t temp_index,
304 intptr_t loop_depth)
305 : EffectGraphVisitor(owner, temp_index, loop_depth), value_(NULL) { }
297 306
298 // Visit functions overridden by this class. 307 // Visit functions overridden by this class.
299 virtual void VisitLiteralNode(LiteralNode* node); 308 virtual void VisitLiteralNode(LiteralNode* node);
300 virtual void VisitAssignableNode(AssignableNode* node); 309 virtual void VisitAssignableNode(AssignableNode* node);
301 virtual void VisitConstructorCallNode(ConstructorCallNode* node); 310 virtual void VisitConstructorCallNode(ConstructorCallNode* node);
302 virtual void VisitBinaryOpNode(BinaryOpNode* node); 311 virtual void VisitBinaryOpNode(BinaryOpNode* node);
303 virtual void VisitConditionalExprNode(ConditionalExprNode* node); 312 virtual void VisitConditionalExprNode(ConditionalExprNode* node);
304 virtual void VisitLoadLocalNode(LoadLocalNode* node); 313 virtual void VisitLoadLocalNode(LoadLocalNode* node);
305 virtual void VisitStoreLocalNode(StoreLocalNode* node); 314 virtual void VisitStoreLocalNode(StoreLocalNode* node);
306 virtual void VisitStoreIndexedNode(StoreIndexedNode* node); 315 virtual void VisitStoreIndexedNode(StoreIndexedNode* node);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // 356 //
348 // We expect that AstNode in test contexts either have only nonlocal exits 357 // We expect that AstNode in test contexts either have only nonlocal exits
349 // or else control flow has both true and false successors. 358 // or else control flow has both true and false successors.
350 // 359 //
351 // The cis and token_pos are used in checked mode to verify that the 360 // The cis and token_pos are used in checked mode to verify that the
352 // condition of the test is of type bool. 361 // condition of the test is of type bool.
353 class TestGraphVisitor : public ValueGraphVisitor { 362 class TestGraphVisitor : public ValueGraphVisitor {
354 public: 363 public:
355 TestGraphVisitor(FlowGraphBuilder* owner, 364 TestGraphVisitor(FlowGraphBuilder* owner,
356 intptr_t temp_index, 365 intptr_t temp_index,
366 intptr_t loop_depth,
357 intptr_t condition_token_pos) 367 intptr_t condition_token_pos)
358 : ValueGraphVisitor(owner, temp_index), 368 : ValueGraphVisitor(owner, temp_index, loop_depth),
359 true_successor_addresses_(1), 369 true_successor_addresses_(1),
360 false_successor_addresses_(1), 370 false_successor_addresses_(1),
361 condition_token_pos_(condition_token_pos) { } 371 condition_token_pos_(condition_token_pos) { }
362 372
363 void IfFalseGoto(JoinEntryInstr* join) const; 373 void IfFalseGoto(JoinEntryInstr* join) const;
364 void IfTrueGoto(JoinEntryInstr* join) const; 374 void IfTrueGoto(JoinEntryInstr* join) const;
365 375
366 BlockEntryInstr* CreateTrueSuccessor() const; 376 BlockEntryInstr* CreateTrueSuccessor() const;
367 BlockEntryInstr* CreateFalseSuccessor() const; 377 BlockEntryInstr* CreateFalseSuccessor() const;
368 378
(...skipping 23 matching lines...) Expand all
392 // Output parameters. 402 // Output parameters.
393 GrowableArray<TargetEntryInstr**> true_successor_addresses_; 403 GrowableArray<TargetEntryInstr**> true_successor_addresses_;
394 GrowableArray<TargetEntryInstr**> false_successor_addresses_; 404 GrowableArray<TargetEntryInstr**> false_successor_addresses_;
395 405
396 intptr_t condition_token_pos_; 406 intptr_t condition_token_pos_;
397 }; 407 };
398 408
399 } // namespace dart 409 } // namespace dart
400 410
401 #endif // VM_FLOW_GRAPH_BUILDER_H_ 411 #endif // VM_FLOW_GRAPH_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698