| 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/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/cha.h" | 10 #include "vm/cha.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 isolate_->object_store()->float64x2_class())), | 201 isolate_->object_store()->float64x2_class())), |
| 202 int32x4_class_(Class::ZoneHandle( | 202 int32x4_class_(Class::ZoneHandle( |
| 203 isolate_->object_store()->int32x4_class())), | 203 isolate_->object_store()->int32x4_class())), |
| 204 list_class_(Class::ZoneHandle( | 204 list_class_(Class::ZoneHandle( |
| 205 Library::Handle(Library::CoreLibrary()). | 205 Library::Handle(Library::CoreLibrary()). |
| 206 LookupClass(Symbols::List()))), | 206 LookupClass(Symbols::List()))), |
| 207 parallel_move_resolver_(this), | 207 parallel_move_resolver_(this), |
| 208 pending_deoptimization_env_(NULL), | 208 pending_deoptimization_env_(NULL), |
| 209 lazy_deopt_pc_offset_(Code::kInvalidPc), | 209 lazy_deopt_pc_offset_(Code::kInvalidPc), |
| 210 deopt_id_to_ic_data_(NULL), | 210 deopt_id_to_ic_data_(NULL), |
| 211 edge_counters_array_(Array::ZoneHandle()), |
| 211 inlined_code_intervals_(Array::ZoneHandle(Object::empty_array().raw())), | 212 inlined_code_intervals_(Array::ZoneHandle(Object::empty_array().raw())), |
| 212 inline_id_to_function_(inline_id_to_function), | 213 inline_id_to_function_(inline_id_to_function), |
| 213 caller_inline_id_(caller_inline_id) { | 214 caller_inline_id_(caller_inline_id) { |
| 214 ASSERT(flow_graph->parsed_function().function().raw() == | 215 ASSERT(flow_graph->parsed_function().function().raw() == |
| 215 parsed_function.function().raw()); | 216 parsed_function.function().raw()); |
| 216 if (!is_optimizing) { | 217 if (!is_optimizing) { |
| 217 const intptr_t len = isolate()->deopt_id(); | 218 const intptr_t len = isolate()->deopt_id(); |
| 218 deopt_id_to_ic_data_ = new(zone()) ZoneGrowableArray<const ICData*>(len); | 219 deopt_id_to_ic_data_ = new(zone()) ZoneGrowableArray<const ICData*>(len); |
| 219 deopt_id_to_ic_data_->SetLength(len); | 220 deopt_id_to_ic_data_->SetLength(len); |
| 220 for (intptr_t i = 0; i < len; i++) { | 221 for (intptr_t i = 0; i < len; i++) { |
| 221 (*deopt_id_to_ic_data_)[i] = NULL; | 222 (*deopt_id_to_ic_data_)[i] = NULL; |
| 222 } | 223 } |
| 223 const Array& old_saved_icdata = Array::Handle(zone(), | 224 // TODO(fschneider): Abstract iteration into ICDataArrayIterator. |
| 225 const Array& old_saved_ic_data = Array::Handle(zone(), |
| 224 flow_graph->function().ic_data_array()); | 226 flow_graph->function().ic_data_array()); |
| 225 const intptr_t saved_len = | 227 const intptr_t saved_len = |
| 226 old_saved_icdata.IsNull() ? 0 : old_saved_icdata.Length(); | 228 old_saved_ic_data.IsNull() ? 0 : old_saved_ic_data.Length(); |
| 227 for (intptr_t i = 0; i < saved_len; i++) { | 229 for (intptr_t i = 1; i < saved_len; i++) { |
| 228 ICData& icd = ICData::ZoneHandle(zone()); | 230 ICData& ic_data = ICData::ZoneHandle(zone()); |
| 229 icd ^= old_saved_icdata.At(i); | 231 ic_data ^= old_saved_ic_data.At(i); |
| 230 (*deopt_id_to_ic_data_)[icd.deopt_id()] = &icd; | 232 (*deopt_id_to_ic_data_)[ic_data.deopt_id()] = &ic_data; |
| 231 } | 233 } |
| 232 } | 234 } |
| 233 ASSERT(assembler != NULL); | 235 ASSERT(assembler != NULL); |
| 234 ASSERT(!list_class_.IsNull()); | 236 ASSERT(!list_class_.IsNull()); |
| 235 } | 237 } |
| 236 | 238 |
| 237 | 239 |
| 238 void FlowGraphCompiler::InitCompiler() { | 240 void FlowGraphCompiler::InitCompiler() { |
| 239 pc_descriptors_list_ = new(zone()) DescriptorList(64); | 241 pc_descriptors_list_ = new(zone()) DescriptorList(64); |
| 240 exception_handlers_list_ = new(zone())ExceptionHandlerList(); | 242 exception_handlers_list_ = new(zone())ExceptionHandlerList(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 277 } |
| 276 } | 278 } |
| 277 } | 279 } |
| 278 } | 280 } |
| 279 } | 281 } |
| 280 if (is_leaf) { | 282 if (is_leaf) { |
| 281 // Remove the stack overflow check at function entry. | 283 // Remove the stack overflow check at function entry. |
| 282 Instruction* first = flow_graph_.graph_entry()->normal_entry()->next(); | 284 Instruction* first = flow_graph_.graph_entry()->normal_entry()->next(); |
| 283 if (first->IsCheckStackOverflow()) first->RemoveFromGraph(); | 285 if (first->IsCheckStackOverflow()) first->RemoveFromGraph(); |
| 284 } | 286 } |
| 287 if (!is_optimizing()) { |
| 288 // Initialize edge counter array. |
| 289 const intptr_t num_counters = flow_graph_.preorder().length(); |
| 290 const Array& edge_counters = |
| 291 Array::Handle(Array::New(num_counters, Heap::kOld)); |
| 292 const Smi& zero_smi = Smi::Handle(Smi::New(0)); |
| 293 for (intptr_t i = 0; i < num_counters; ++i) { |
| 294 edge_counters.SetAt(i, zero_smi); |
| 295 } |
| 296 edge_counters_array_ = edge_counters.raw(); |
| 297 } |
| 285 } | 298 } |
| 286 | 299 |
| 287 | 300 |
| 288 bool FlowGraphCompiler::CanOptimize() { | 301 bool FlowGraphCompiler::CanOptimize() { |
| 289 return FLAG_optimization_counter_threshold >= 0; | 302 return FLAG_optimization_counter_threshold >= 0; |
| 290 } | 303 } |
| 291 | 304 |
| 292 | 305 |
| 293 bool FlowGraphCompiler::CanOptimizeFunction() const { | 306 bool FlowGraphCompiler::CanOptimizeFunction() const { |
| 294 return CanOptimize() && !parsed_function().function().HasBreakpoint(); | 307 return CanOptimize() && !parsed_function().function().HasBreakpoint(); |
| (...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 | 1850 |
| 1838 | 1851 |
| 1839 void FlowGraphCompiler::FrameStateClear() { | 1852 void FlowGraphCompiler::FrameStateClear() { |
| 1840 ASSERT(!is_optimizing()); | 1853 ASSERT(!is_optimizing()); |
| 1841 frame_state_.TruncateTo(0); | 1854 frame_state_.TruncateTo(0); |
| 1842 } | 1855 } |
| 1843 #endif | 1856 #endif |
| 1844 | 1857 |
| 1845 | 1858 |
| 1846 } // namespace dart | 1859 } // namespace dart |
| OLD | NEW |