OLD | NEW |
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/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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 return parsed_function().function().has_finally(); | 171 return parsed_function().function().has_finally(); |
172 } | 172 } |
173 | 173 |
174 | 174 |
175 void FlowGraphCompiler::InitCompiler() { | 175 void FlowGraphCompiler::InitCompiler() { |
176 pc_descriptors_list_ = new DescriptorList(64); | 176 pc_descriptors_list_ = new DescriptorList(64); |
177 exception_handlers_list_ = new ExceptionHandlerList(); | 177 exception_handlers_list_ = new ExceptionHandlerList(); |
178 block_info_.Clear(); | 178 block_info_.Clear(); |
179 for (int i = 0; i < block_order_.length(); ++i) { | 179 for (int i = 0; i < block_order_.length(); ++i) { |
180 block_info_.Add(new BlockInfo()); | 180 block_info_.Add(new BlockInfo()); |
| 181 if (is_optimizing()) { |
| 182 BlockEntryInstr* entry = block_order_[i]; |
| 183 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |
| 184 Instruction* current = it.Current(); |
| 185 const ICData* ic_data = NULL; |
| 186 if (current->IsBranch()) { |
| 187 current = current->AsBranch()->comparison(); |
| 188 } |
| 189 // In optimized code, ICData is always set in the instructions. |
| 190 if (current->IsInstanceCall()) { |
| 191 ic_data = current->AsInstanceCall()->ic_data(); |
| 192 ASSERT(ic_data != NULL); |
| 193 } else if (current->IsRelationalOp()) { |
| 194 ic_data = current->AsRelationalOp()->ic_data(); |
| 195 ASSERT(ic_data != NULL); |
| 196 } else if (current->IsEqualityCompare()) { |
| 197 ic_data = current->AsEqualityCompare()->ic_data(); |
| 198 ASSERT(ic_data != NULL); |
| 199 } |
| 200 if ((ic_data != NULL) && (ic_data->NumberOfChecks() == 0)) { |
| 201 may_reoptimize_ = true; |
| 202 break; |
| 203 } |
| 204 } |
| 205 } |
181 } | 206 } |
182 } | 207 } |
183 | 208 |
184 | 209 |
185 bool FlowGraphCompiler::CanOptimize() { | 210 bool FlowGraphCompiler::CanOptimize() { |
186 return !FLAG_report_usage_count && | 211 return !FLAG_report_usage_count && |
187 (FLAG_optimization_counter_threshold >= 0); | 212 (FLAG_optimization_counter_threshold >= 0); |
188 } | 213 } |
189 | 214 |
190 | 215 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 label_address = StubCode::ClosureCallInlineCacheEntryPoint(); | 534 label_address = StubCode::ClosureCallInlineCacheEntryPoint(); |
510 ExternalLabel target_label("InlineCache", label_address); | 535 ExternalLabel target_label("InlineCache", label_address); |
511 EmitInstanceCall(&target_label, | 536 EmitInstanceCall(&target_label, |
512 ICData::ZoneHandle(ic_data.AsUnaryClassChecks()), | 537 ICData::ZoneHandle(ic_data.AsUnaryClassChecks()), |
513 arguments_descriptor, argument_count, | 538 arguments_descriptor, argument_count, |
514 deopt_id, token_pos, locs); | 539 deopt_id, token_pos, locs); |
515 return; | 540 return; |
516 } | 541 } |
517 // Emit IC call that will count and thus may need reoptimization at | 542 // Emit IC call that will count and thus may need reoptimization at |
518 // return instruction. | 543 // return instruction. |
519 may_reoptimize_ = true; | 544 ASSERT(!is_optimizing() || may_reoptimize()); |
520 switch (ic_data.num_args_tested()) { | 545 switch (ic_data.num_args_tested()) { |
521 case 1: | 546 case 1: |
522 label_address = StubCode::OneArgOptimizedCheckInlineCacheEntryPoint(); | 547 label_address = StubCode::OneArgOptimizedCheckInlineCacheEntryPoint(); |
523 break; | 548 break; |
524 case 2: | 549 case 2: |
525 label_address = StubCode::TwoArgsOptimizedCheckInlineCacheEntryPoint(); | 550 label_address = StubCode::TwoArgsOptimizedCheckInlineCacheEntryPoint(); |
526 break; | 551 break; |
527 case 3: | 552 case 3: |
528 label_address = | 553 label_address = |
529 StubCode::ThreeArgsOptimizedCheckInlineCacheEntryPoint(); | 554 StubCode::ThreeArgsOptimizedCheckInlineCacheEntryPoint(); |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 const AbstractTypeArguments& type_arguments = | 1110 const AbstractTypeArguments& type_arguments = |
1086 AbstractTypeArguments::Handle(type.arguments()); | 1111 AbstractTypeArguments::Handle(type.arguments()); |
1087 const bool is_raw_type = type_arguments.IsNull() || | 1112 const bool is_raw_type = type_arguments.IsNull() || |
1088 type_arguments.IsRaw(type_arguments.Length()); | 1113 type_arguments.IsRaw(type_arguments.Length()); |
1089 return is_raw_type; | 1114 return is_raw_type; |
1090 } | 1115 } |
1091 return true; | 1116 return true; |
1092 } | 1117 } |
1093 | 1118 |
1094 } // namespace dart | 1119 } // namespace dart |
OLD | NEW |