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

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

Issue 12518009: Remove virtual functions on class InliningContext. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « no previous file | 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 abstraction of the graph context in which an inlined call occurs. 19 // An InliningContext collects the exits from an inlined function during
20 class InliningContext: public ZoneAllocated { 20 // graph construction so they can be plugged into the caller's flow graph.
21 class InliningContext: public ValueObject {
21 public: 22 public:
22 // Create the appropriate inlining context for the flow graph context of a 23 InliningContext() : exits_(4) { }
23 // call.
24 static InliningContext* Create(Definition* call);
25 24
26 virtual void AddExit(ReturnInstr* exit) = 0; 25 void AddExit(ReturnInstr* exit);
27 26
28 // Inline a flow graph at a call site. 27 // Inline a flow graph at a call site.
29 // 28 //
30 // Assumes the callee graph was computed by BuildGraph with an inlining 29 // Assumes the callee graph was computed by BuildGraph with an inlining
31 // context and transformed to SSA with ComputeSSA with a correct virtual 30 // context and transformed to SSA with ComputeSSA with a correct virtual
32 // register number, and that the use lists have been correctly computed. 31 // register number, and that the use lists have been correctly computed.
33 // 32 //
34 // After inlining the caller graph will correctly have adjusted the 33 // After inlining the caller graph will correctly have adjusted the
35 // pre/post orders, the dominator tree and the use lists. 34 // pre/post orders, the dominator tree and the use lists.
36 virtual void ReplaceCall(FlowGraph* caller_graph, 35 void ReplaceCall(FlowGraph* caller_graph,
37 Definition* call, 36 Definition* call,
38 FlowGraph* callee_graph) = 0; 37 FlowGraph* callee_graph);
39
40 protected:
41 static void PrepareGraphs(FlowGraph* caller_graph,
42 Definition* call,
43 FlowGraph* callee_graph);
44 };
45
46
47 // The context of a call inlined for its value (including calls inlined for
48 // their effects, i.e., when the value is ignored). Collects normal exit
49 // blocks and return values.
50 class ValueInliningContext: public InliningContext {
51 public:
52 ValueInliningContext() : exits_(4) { }
53
54 virtual void AddExit(ReturnInstr* exit);
55
56 virtual void ReplaceCall(FlowGraph* caller_graph,
57 Definition* call,
58 FlowGraph* callee_graph);
59 38
60 private: 39 private:
61 struct Data { 40 struct Data {
62 BlockEntryInstr* exit_block; 41 BlockEntryInstr* exit_block;
63 ReturnInstr* exit_return; 42 ReturnInstr* exit_return;
64 }; 43 };
65 44
45 static void PrepareGraphs(FlowGraph* caller_graph,
46 Definition* call,
47 FlowGraph* callee_graph);
48
66 BlockEntryInstr* ExitBlockAt(intptr_t i) const { 49 BlockEntryInstr* ExitBlockAt(intptr_t i) const {
67 ASSERT(exits_[i].exit_block != NULL); 50 ASSERT(exits_[i].exit_block != NULL);
68 return exits_[i].exit_block; 51 return exits_[i].exit_block;
69 } 52 }
70 Instruction* LastInstructionAt(intptr_t i) const { 53 Instruction* LastInstructionAt(intptr_t i) const {
71 return exits_[i].exit_return->previous(); 54 return exits_[i].exit_return->previous();
72 } 55 }
73 Value* ValueAt(intptr_t i) const { 56 Value* ValueAt(intptr_t i) const {
74 return exits_[i].exit_return->value(); 57 return exits_[i].exit_return->value();
75 } 58 }
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 // Output parameters. 445 // Output parameters.
463 GrowableArray<TargetEntryInstr**> true_successor_addresses_; 446 GrowableArray<TargetEntryInstr**> true_successor_addresses_;
464 GrowableArray<TargetEntryInstr**> false_successor_addresses_; 447 GrowableArray<TargetEntryInstr**> false_successor_addresses_;
465 448
466 intptr_t condition_token_pos_; 449 intptr_t condition_token_pos_;
467 }; 450 };
468 451
469 } // namespace dart 452 } // namespace dart
470 453
471 #endif // VM_FLOW_GRAPH_BUILDER_H_ 454 #endif // VM_FLOW_GRAPH_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698