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

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

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 | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_inliner.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 #include "vm/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/code_descriptors.h" 9 #include "vm/code_descriptors.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 last_used_try_index_(CatchClauseNode::kInvalidTryIndex), 55 last_used_try_index_(CatchClauseNode::kInvalidTryIndex),
56 try_index_(CatchClauseNode::kInvalidTryIndex), 56 try_index_(CatchClauseNode::kInvalidTryIndex),
57 graph_entry_(NULL) { } 57 graph_entry_(NULL) { }
58 58
59 59
60 void FlowGraphBuilder::AddCatchEntry(TargetEntryInstr* entry) { 60 void FlowGraphBuilder::AddCatchEntry(TargetEntryInstr* entry) {
61 graph_entry_->AddCatchEntry(entry); 61 graph_entry_->AddCatchEntry(entry);
62 } 62 }
63 63
64 64
65 InliningContext* InliningContext::Create(Definition* call) {
66 return new ValueInliningContext();
67 }
68
69
70 void InliningContext::PrepareGraphs(FlowGraph* caller_graph, 65 void InliningContext::PrepareGraphs(FlowGraph* caller_graph,
71 Definition* call, 66 Definition* call,
72 FlowGraph* callee_graph) { 67 FlowGraph* callee_graph) {
73 ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1); 68 ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1);
74 ASSERT(callee_graph->max_block_id() > caller_graph->max_block_id()); 69 ASSERT(callee_graph->max_block_id() > caller_graph->max_block_id());
75 ASSERT(callee_graph->max_virtual_register_number() > 70 ASSERT(callee_graph->max_virtual_register_number() >
76 caller_graph->max_virtual_register_number()); 71 caller_graph->max_virtual_register_number());
77 72
78 // Adjust the caller's maximum block id and current SSA temp index. 73 // Adjust the caller's maximum block id and current SSA temp index.
79 caller_graph->set_max_block_id(callee_graph->max_block_id()); 74 caller_graph->set_max_block_id(callee_graph->max_block_id());
(...skipping 10 matching lines...) Expand all
90 Instruction* instr = it.Current(); 85 Instruction* instr = it.Current();
91 // TODO(zerny): Avoid creating unnecessary environments. Note that some 86 // TODO(zerny): Avoid creating unnecessary environments. Note that some
92 // optimizations need deoptimization info for non-deoptable instructions, 87 // optimizations need deoptimization info for non-deoptable instructions,
93 // eg, LICM on GOTOs. 88 // eg, LICM on GOTOs.
94 if (instr->env() != NULL) call->env()->DeepCopyToOuter(instr); 89 if (instr->env() != NULL) call->env()->DeepCopyToOuter(instr);
95 } 90 }
96 } 91 }
97 } 92 }
98 93
99 94
100 void ValueInliningContext::AddExit(ReturnInstr* exit) { 95 void InliningContext::AddExit(ReturnInstr* exit) {
101 Data data = { NULL, exit }; 96 Data data = { NULL, exit };
102 exits_.Add(data); 97 exits_.Add(data);
103 } 98 }
104 99
105 100
106 int ValueInliningContext::LowestBlockIdFirst(const Data* a, const Data* b) { 101 int InliningContext::LowestBlockIdFirst(const Data* a, const Data* b) {
107 return (a->exit_block->block_id() - b->exit_block->block_id()); 102 return (a->exit_block->block_id() - b->exit_block->block_id());
108 } 103 }
109 104
110 105
111 void ValueInliningContext::SortExits() { 106 void InliningContext::SortExits() {
112 // Assign block entries here because we did not necessarily know them when 107 // Assign block entries here because we did not necessarily know them when
113 // the return exit was added to the array. 108 // the return exit was added to the array.
114 for (int i = 0; i < exits_.length(); ++i) { 109 for (int i = 0; i < exits_.length(); ++i) {
115 exits_[i].exit_block = exits_[i].exit_return->GetBlock(); 110 exits_[i].exit_block = exits_[i].exit_return->GetBlock();
116 } 111 }
117 exits_.Sort(LowestBlockIdFirst); 112 exits_.Sort(LowestBlockIdFirst);
118 } 113 }
119 114
120 115
121 void ValueInliningContext::ReplaceCall(FlowGraph* caller_graph, 116 void InliningContext::ReplaceCall(FlowGraph* caller_graph,
122 Definition* call, 117 Definition* call,
123 FlowGraph* callee_graph) { 118 FlowGraph* callee_graph) {
124 ASSERT(call->previous() != NULL); 119 ASSERT(call->previous() != NULL);
125 ASSERT(call->next() != NULL); 120 ASSERT(call->next() != NULL);
126 PrepareGraphs(caller_graph, call, callee_graph); 121 PrepareGraphs(caller_graph, call, callee_graph);
127 122
128 BlockEntryInstr* caller_entry = call->GetBlock(); 123 BlockEntryInstr* caller_entry = call->GetBlock();
129 TargetEntryInstr* callee_entry = callee_graph->graph_entry()->normal_entry(); 124 TargetEntryInstr* callee_entry = callee_graph->graph_entry()->normal_entry();
130 125
131 // Insert the callee graph into the caller graph. First sort the list of 126 // Insert the callee graph into the caller graph. First sort the list of
132 // exits by block id (recording block entries as a side effect). 127 // exits by block id (recording block entries as a side effect).
133 SortExits(); 128 SortExits();
(...skipping 3164 matching lines...) Expand 10 before | Expand all | Expand 10 after
3298 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3293 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3299 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3294 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3300 OS::SNPrint(chars, len, kFormat, function_name, reason); 3295 OS::SNPrint(chars, len, kFormat, function_name, reason);
3301 const Error& error = Error::Handle( 3296 const Error& error = Error::Handle(
3302 LanguageError::New(String::Handle(String::New(chars)))); 3297 LanguageError::New(String::Handle(String::New(chars))));
3303 Isolate::Current()->long_jump_base()->Jump(1, error); 3298 Isolate::Current()->long_jump_base()->Jump(1, error);
3304 } 3299 }
3305 3300
3306 3301
3307 } // namespace dart 3302 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698