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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 mint_class_(Class::ZoneHandle( | 192 mint_class_(Class::ZoneHandle( |
193 isolate_->object_store()->mint_class())), | 193 isolate_->object_store()->mint_class())), |
194 float32x4_class_(Class::ZoneHandle( | 194 float32x4_class_(Class::ZoneHandle( |
195 isolate_->object_store()->float32x4_class())), | 195 isolate_->object_store()->float32x4_class())), |
196 float64x2_class_(Class::ZoneHandle( | 196 float64x2_class_(Class::ZoneHandle( |
197 isolate_->object_store()->float64x2_class())), | 197 isolate_->object_store()->float64x2_class())), |
198 int32x4_class_(Class::ZoneHandle( | 198 int32x4_class_(Class::ZoneHandle( |
199 isolate_->object_store()->int32x4_class())), | 199 isolate_->object_store()->int32x4_class())), |
200 list_class_(Class::ZoneHandle( | 200 list_class_(Class::ZoneHandle( |
201 Library::Handle(Library::CoreLibrary()). | 201 Library::Handle(Library::CoreLibrary()). |
202 LookupClass(Symbols::List()))), | 202 LookupClass(Symbols::List()))), |
siva
2015/09/26 00:18:32
I was wondering if it make sense to store these in
Florian Schneider
2015/09/28 09:19:43
Maybe. On the other hand they are only needed for
siva
2015/09/28 17:01:29
Agreed it is done once per compilation but we have
| |
203 parallel_move_resolver_(this), | 203 parallel_move_resolver_(this), |
204 pending_deoptimization_env_(NULL), | 204 pending_deoptimization_env_(NULL), |
205 entry_patch_pc_offset_(Code::kInvalidPc), | 205 entry_patch_pc_offset_(Code::kInvalidPc), |
206 patch_code_pc_offset_(Code::kInvalidPc), | 206 patch_code_pc_offset_(Code::kInvalidPc), |
207 lazy_deopt_pc_offset_(Code::kInvalidPc), | 207 lazy_deopt_pc_offset_(Code::kInvalidPc), |
208 deopt_id_to_ic_data_(NULL), | 208 deopt_id_to_ic_data_(NULL), |
209 edge_counters_array_(Array::ZoneHandle()), | |
209 inlined_code_intervals_(Array::ZoneHandle(Object::empty_array().raw())), | 210 inlined_code_intervals_(Array::ZoneHandle(Object::empty_array().raw())), |
210 inline_id_to_function_(inline_id_to_function), | 211 inline_id_to_function_(inline_id_to_function), |
211 caller_inline_id_(caller_inline_id) { | 212 caller_inline_id_(caller_inline_id) { |
212 ASSERT(flow_graph->parsed_function().function().raw() == | 213 ASSERT(flow_graph->parsed_function().function().raw() == |
213 parsed_function.function().raw()); | 214 parsed_function.function().raw()); |
214 if (!is_optimizing) { | 215 if (!is_optimizing) { |
215 const intptr_t len = isolate()->deopt_id(); | 216 const intptr_t len = isolate()->deopt_id(); |
216 deopt_id_to_ic_data_ = new(zone()) ZoneGrowableArray<const ICData*>(len); | 217 deopt_id_to_ic_data_ = new(zone()) ZoneGrowableArray<const ICData*>(len); |
217 deopt_id_to_ic_data_->SetLength(len); | 218 deopt_id_to_ic_data_->SetLength(len); |
218 for (intptr_t i = 0; i < len; i++) { | 219 for (intptr_t i = 0; i < len; i++) { |
219 (*deopt_id_to_ic_data_)[i] = NULL; | 220 (*deopt_id_to_ic_data_)[i] = NULL; |
220 } | 221 } |
221 const Array& old_saved_icdata = Array::Handle(zone(), | 222 // TODO(fschneider): Abstract iteration into ICDataArrayIterator. |
223 const Array& old_saved_ic_data = Array::Handle(zone(), | |
222 flow_graph->function().ic_data_array()); | 224 flow_graph->function().ic_data_array()); |
223 const intptr_t saved_len = | 225 const intptr_t saved_len = |
224 old_saved_icdata.IsNull() ? 0 : old_saved_icdata.Length(); | 226 old_saved_ic_data.IsNull() ? 0 : old_saved_ic_data.Length(); |
225 for (intptr_t i = 0; i < saved_len; i++) { | 227 for (intptr_t i = 1; i < saved_len; i++) { |
226 ICData& icd = ICData::ZoneHandle(zone()); | 228 ICData& ic_data = ICData::ZoneHandle(zone()); |
227 icd ^= old_saved_icdata.At(i); | 229 ic_data ^= old_saved_ic_data.At(i); |
228 (*deopt_id_to_ic_data_)[icd.deopt_id()] = &icd; | 230 (*deopt_id_to_ic_data_)[ic_data.deopt_id()] = &ic_data; |
229 } | 231 } |
230 } | 232 } |
231 ASSERT(assembler != NULL); | 233 ASSERT(assembler != NULL); |
232 ASSERT(!list_class_.IsNull()); | 234 ASSERT(!list_class_.IsNull()); |
233 } | 235 } |
234 | 236 |
235 | 237 |
236 void FlowGraphCompiler::InitCompiler() { | 238 void FlowGraphCompiler::InitCompiler() { |
237 pc_descriptors_list_ = new(zone()) DescriptorList(64); | 239 pc_descriptors_list_ = new(zone()) DescriptorList(64); |
238 exception_handlers_list_ = new(zone())ExceptionHandlerList(); | 240 exception_handlers_list_ = new(zone())ExceptionHandlerList(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 } | 275 } |
274 } | 276 } |
275 } | 277 } |
276 } | 278 } |
277 } | 279 } |
278 if (is_leaf) { | 280 if (is_leaf) { |
279 // Remove the stack overflow check at function entry. | 281 // Remove the stack overflow check at function entry. |
280 Instruction* first = flow_graph_.graph_entry()->normal_entry()->next(); | 282 Instruction* first = flow_graph_.graph_entry()->normal_entry()->next(); |
281 if (first->IsCheckStackOverflow()) first->RemoveFromGraph(); | 283 if (first->IsCheckStackOverflow()) first->RemoveFromGraph(); |
282 } | 284 } |
285 if (!is_optimizing()) { | |
286 // Initialize edge counter array. | |
287 const intptr_t num_counters = flow_graph_.preorder().length(); | |
288 const Array& edge_counters = | |
289 Array::Handle(Array::New(num_counters, Heap::kOld)); | |
290 const Smi& zero_smi = Smi::Handle(Smi::New(0)); | |
291 for (intptr_t i = 0; i < num_counters; ++i) { | |
292 edge_counters.SetAt(i, zero_smi); | |
293 } | |
294 edge_counters_array_ = edge_counters.raw(); | |
295 } | |
283 } | 296 } |
284 | 297 |
285 | 298 |
286 bool FlowGraphCompiler::CanOptimize() { | 299 bool FlowGraphCompiler::CanOptimize() { |
287 return FLAG_optimization_counter_threshold >= 0; | 300 return FLAG_optimization_counter_threshold >= 0; |
288 } | 301 } |
289 | 302 |
290 | 303 |
291 bool FlowGraphCompiler::CanOptimizeFunction() const { | 304 bool FlowGraphCompiler::CanOptimizeFunction() const { |
292 return CanOptimize() && !parsed_function().function().HasBreakpoint(); | 305 return CanOptimize() && !parsed_function().function().HasBreakpoint(); |
(...skipping 1544 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 |