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

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

Issue 14135006: Reapply "Incrementally recompute dominators when inlining." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 // An InliningContext collects the exits from an inlined function during 19 // An InliningContext collects the exits from an inlined function during
20 // graph construction so they can be plugged into the caller's flow graph. 20 // graph construction so they can be plugged into the caller's flow graph.
21 class InliningContext: public ValueObject { 21 class InliningContext: public ValueObject {
22 public: 22 public:
23 InliningContext() : exits_(4) { } 23 InliningContext(FlowGraph* caller_graph, Definition* call)
24 : caller_graph_(caller_graph), call_(call), exits_(4) { }
24 25
25 void AddExit(ReturnInstr* exit); 26 void AddExit(ReturnInstr* exit);
26 27
27 // Inline a flow graph at a call site. 28 // Inline a flow graph at a call site.
28 // 29 //
29 // Assumes the callee graph was computed by BuildGraph with an inlining 30 // Assumes the callee graph was computed by BuildGraph with an inlining
30 // context and transformed to SSA with ComputeSSA with a correct virtual 31 // context and transformed to SSA with ComputeSSA with a correct virtual
31 // register number, and that the use lists have been correctly computed. 32 // register number, and that the use lists have been correctly computed.
32 // 33 //
33 // After inlining the caller graph will correctly have adjusted the 34 // After inlining the caller graph will have correctly adjusted the use
34 // pre/post orders, the dominator tree and the use lists. 35 // lists. The block orders will need to be recomputed, and the dominator
35 void ReplaceCall(FlowGraph* caller_graph, 36 // tree will need to be recomputed if it is marked invalid in the caller
36 Definition* call, 37 // graph.
37 FlowGraph* callee_graph); 38 void ReplaceCall(FlowGraph* callee_graph);
38 39
39 private: 40 private:
40 struct Data { 41 struct Data {
41 BlockEntryInstr* exit_block; 42 BlockEntryInstr* exit_block;
42 ReturnInstr* exit_return; 43 ReturnInstr* exit_return;
43 }; 44 };
44 45
45 static void PrepareGraphs(FlowGraph* caller_graph, 46 void PrepareGraphs(FlowGraph* caller_graph);
46 Definition* call,
47 FlowGraph* callee_graph);
48 47
49 BlockEntryInstr* ExitBlockAt(intptr_t i) const { 48 BlockEntryInstr* ExitBlockAt(intptr_t i) const {
50 ASSERT(exits_[i].exit_block != NULL); 49 ASSERT(exits_[i].exit_block != NULL);
51 return exits_[i].exit_block; 50 return exits_[i].exit_block;
52 } 51 }
53 Instruction* LastInstructionAt(intptr_t i) const { 52 Instruction* LastInstructionAt(intptr_t i) const {
54 return exits_[i].exit_return->previous(); 53 return exits_[i].exit_return->previous();
55 } 54 }
56 Value* ValueAt(intptr_t i) const { 55 Value* ValueAt(intptr_t i) const {
57 return exits_[i].exit_return->value(); 56 return exits_[i].exit_return->value();
58 } 57 }
59 58
60 static int LowestBlockIdFirst(const Data* a, const Data* b); 59 static int LowestBlockIdFirst(const Data* a, const Data* b);
61 void SortExits(); 60 void SortExits();
62 61
62 Definition* JoinReturns(BlockEntryInstr** exit_block,
63 Instruction** last_instruction);
64
65 FlowGraph* caller_graph_;
66 Definition* call_;
63 GrowableArray<Data> exits_; 67 GrowableArray<Data> exits_;
64 }; 68 };
65 69
66 70
67 // Build a flow graph from a parsed function's AST. 71 // Build a flow graph from a parsed function's AST.
68 class FlowGraphBuilder: public ValueObject { 72 class FlowGraphBuilder: public ValueObject {
69 public: 73 public:
70 // The inlining context is NULL if not inlining. 74 // The inlining context is NULL if not inlining.
71 FlowGraphBuilder(const ParsedFunction& parsed_function, 75 FlowGraphBuilder(const ParsedFunction& parsed_function,
72 InliningContext* inlining_context); 76 InliningContext* inlining_context);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // Output parameters. 451 // Output parameters.
448 GrowableArray<TargetEntryInstr**> true_successor_addresses_; 452 GrowableArray<TargetEntryInstr**> true_successor_addresses_;
449 GrowableArray<TargetEntryInstr**> false_successor_addresses_; 453 GrowableArray<TargetEntryInstr**> false_successor_addresses_;
450 454
451 intptr_t condition_token_pos_; 455 intptr_t condition_token_pos_;
452 }; 456 };
453 457
454 } // namespace dart 458 } // namespace dart
455 459
456 #endif // VM_FLOW_GRAPH_BUILDER_H_ 460 #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