Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
| 6 | 6 |
| 7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
| 8 | 8 |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 | 153 |
| 154 bool FlowGraphCompiler::HasFinally() const { | 154 bool FlowGraphCompiler::HasFinally() const { |
| 155 return parsed_function().function().has_finally(); | 155 return parsed_function().function().has_finally(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 | 158 |
| 159 void FlowGraphCompiler::InitCompiler() { | 159 void FlowGraphCompiler::InitCompiler() { |
| 160 pc_descriptors_list_ = new DescriptorList(64); | 160 pc_descriptors_list_ = new DescriptorList(64); |
| 161 exception_handlers_list_ = new ExceptionHandlerList(); | 161 exception_handlers_list_ = new ExceptionHandlerList(); |
| 162 block_info_.Clear(); | 162 block_info_.Clear(); |
| 163 bool is_leaf = !parsed_function().function().IsClosureFunction() && | |
| 164 is_optimizing(); | |
| 163 for (int i = 0; i < block_order_.length(); ++i) { | 165 for (int i = 0; i < block_order_.length(); ++i) { |
| 164 block_info_.Add(new BlockInfo()); | 166 block_info_.Add(new BlockInfo()); |
| 165 if (is_optimizing()) { | 167 if (is_optimizing()) { |
| 166 BlockEntryInstr* entry = block_order_[i]; | 168 BlockEntryInstr* entry = block_order_[i]; |
| 167 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { | 169 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |
| 168 Instruction* current = it.Current(); | 170 Instruction* current = it.Current(); |
| 169 const ICData* ic_data = NULL; | 171 const ICData* ic_data = NULL; |
| 170 if (current->IsBranch()) { | 172 if (current->IsBranch()) { |
| 171 current = current->AsBranch()->comparison(); | 173 current = current->AsBranch()->comparison(); |
| 172 } | 174 } |
| 173 // In optimized code, ICData is always set in the instructions. | 175 // In optimized code, ICData is always set in the instructions. |
| 174 if (current->IsInstanceCall()) { | 176 if (current->IsInstanceCall()) { |
| 175 ic_data = current->AsInstanceCall()->ic_data(); | 177 ic_data = current->AsInstanceCall()->ic_data(); |
| 176 ASSERT(ic_data != NULL); | 178 ASSERT(ic_data != NULL); |
| 177 } else if (current->IsRelationalOp()) { | 179 } else if (current->IsRelationalOp()) { |
| 178 ic_data = current->AsRelationalOp()->ic_data(); | 180 ic_data = current->AsRelationalOp()->ic_data(); |
| 179 ASSERT(ic_data != NULL); | 181 ASSERT(ic_data != NULL); |
| 180 } else if (current->IsEqualityCompare()) { | 182 } else if (current->IsEqualityCompare()) { |
| 181 ic_data = current->AsEqualityCompare()->ic_data(); | 183 ic_data = current->AsEqualityCompare()->ic_data(); |
| 182 ASSERT(ic_data != NULL); | 184 ASSERT(ic_data != NULL); |
| 183 } | 185 } |
| 184 if ((ic_data != NULL) && (ic_data->NumberOfChecks() == 0)) { | 186 if ((ic_data != NULL) && (ic_data->NumberOfChecks() == 0)) { |
| 185 may_reoptimize_ = true; | 187 may_reoptimize_ = true; |
| 186 break; | 188 break; |
| 187 } | 189 } |
| 190 if (is_leaf && !current->IsCheckStackOverflow()) { | |
| 191 // Note that we do no care if the code contains instructions that | |
| 192 // can deoptimize. | |
| 193 LocationSummary* locs = current->locs(); | |
| 194 if (locs != NULL && locs->can_call()) { | |
| 195 is_leaf = false; | |
| 196 } | |
| 197 } | |
| 188 } | 198 } |
| 189 } | 199 } |
| 190 } | 200 } |
| 201 if (is_leaf) { | |
| 202 BlockEntryInstr* entry = block_order_[1]; | |
|
Kevin Millikin (Google)
2013/04/18 10:05:28
I don't think we should rely on properties of the
srdjan
2013/04/18 18:15:57
Yes, using: flow_graph_.graph_entry()->normal_entr
| |
| 203 ASSERT(entry != NULL); | |
| 204 CheckStackOverflowInstr* check = entry->next()->AsCheckStackOverflow(); | |
| 205 ASSERT(check != NULL); | |
| 206 check->RemoveFromGraph(); | |
| 207 } | |
| 191 } | 208 } |
| 192 | 209 |
| 193 | 210 |
| 194 bool FlowGraphCompiler::CanOptimize() { | 211 bool FlowGraphCompiler::CanOptimize() { |
| 195 return !FLAG_report_usage_count && | 212 return !FLAG_report_usage_count && |
| 196 (FLAG_optimization_counter_threshold >= 0); | 213 (FLAG_optimization_counter_threshold >= 0); |
| 197 } | 214 } |
| 198 | 215 |
| 199 | 216 |
| 200 bool FlowGraphCompiler::CanOptimizeFunction() const { | 217 bool FlowGraphCompiler::CanOptimizeFunction() const { |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1124 if (i != largest_ix) { | 1141 if (i != largest_ix) { |
| 1125 // Swap. | 1142 // Swap. |
| 1126 CidTarget temp = (*sorted)[i]; | 1143 CidTarget temp = (*sorted)[i]; |
| 1127 (*sorted)[i] = (*sorted)[largest_ix]; | 1144 (*sorted)[i] = (*sorted)[largest_ix]; |
| 1128 (*sorted)[largest_ix] = temp; | 1145 (*sorted)[largest_ix] = temp; |
| 1129 } | 1146 } |
| 1130 } | 1147 } |
| 1131 } | 1148 } |
| 1132 | 1149 |
| 1133 } // namespace dart | 1150 } // namespace dart |
| OLD | NEW |