Chromium Code Reviews| 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/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 assembler()->CodeSize(), | 293 assembler()->CodeSize(), |
| 294 deopt_id, | 294 deopt_id, |
| 295 token_pos, | 295 token_pos, |
| 296 CurrentTryIndex()); | 296 CurrentTryIndex()); |
| 297 } | 297 } |
| 298 | 298 |
| 299 | 299 |
| 300 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, | 300 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, |
| 301 intptr_t token_pos) { | 301 intptr_t token_pos) { |
| 302 ASSERT(is_optimizing()); | 302 ASSERT(is_optimizing()); |
| 303 const intptr_t deopt_index = deopt_infos_.length(); | |
| 304 CompilerDeoptInfo* info = new CompilerDeoptInfo(deopt_id, kDeoptAtCall); | 303 CompilerDeoptInfo* info = new CompilerDeoptInfo(deopt_id, kDeoptAtCall); |
| 305 ASSERT(pending_deoptimization_env_ != NULL); | 304 ASSERT(pending_deoptimization_env_ != NULL); |
| 306 info->set_deoptimization_env(pending_deoptimization_env_); | 305 info->set_deoptimization_env(pending_deoptimization_env_); |
| 306 info->set_pc_offset(assembler()->CodeSize()); | |
| 307 deopt_infos_.Add(info); | 307 deopt_infos_.Add(info); |
| 308 pc_descriptors_list()->AddDeoptIndex(assembler()->CodeSize(), | |
| 309 deopt_id, | |
| 310 kDeoptAtCall, | |
| 311 deopt_index); | |
| 312 } | 308 } |
| 313 | 309 |
| 314 | 310 |
| 315 void FlowGraphCompiler::RecordSafepoint(LocationSummary* locs) { | 311 void FlowGraphCompiler::RecordSafepoint(LocationSummary* locs) { |
| 316 if (is_optimizing()) { | 312 if (is_optimizing()) { |
| 317 BitmapBuilder* bitmap = locs->stack_bitmap(); | 313 BitmapBuilder* bitmap = locs->stack_bitmap(); |
| 318 ASSERT(bitmap != NULL); | 314 ASSERT(bitmap != NULL); |
| 319 ASSERT(bitmap->Length() <= StackSize()); | 315 ASSERT(bitmap->Length() <= StackSize()); |
| 320 // Pad the bitmap out to describe all the spill slots. | 316 // Pad the bitmap out to describe all the spill slots. |
| 321 bitmap->SetLength(StackSize()); | 317 bitmap->SetLength(StackSize()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) { | 382 void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) { |
| 387 ASSERT(pc_descriptors_list_ != NULL); | 383 ASSERT(pc_descriptors_list_ != NULL); |
| 388 const PcDescriptors& descriptors = PcDescriptors::Handle( | 384 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 389 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); | 385 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); |
| 390 if (!is_optimizing_) descriptors.Verify(parsed_function_.function()); | 386 if (!is_optimizing_) descriptors.Verify(parsed_function_.function()); |
| 391 code.set_pc_descriptors(descriptors); | 387 code.set_pc_descriptors(descriptors); |
| 392 } | 388 } |
| 393 | 389 |
| 394 | 390 |
| 395 void FlowGraphCompiler::FinalizeDeoptInfo(const Code& code) { | 391 void FlowGraphCompiler::FinalizeDeoptInfo(const Code& code) { |
| 392 // An entry is a triple of (pc_offset, deopt_info, deopt_reason). | |
| 393 const int kEntrySize = 3; | |
|
srdjan
2012/09/28 21:00:26
Use a dedicated class to describe the structure of
Kevin Millikin (Google)
2012/10/01 09:38:56
Done.
| |
| 396 const Array& array = | 394 const Array& array = |
| 397 Array::Handle(Array::New(deopt_infos_.length(), Heap::kOld)); | 395 Array::Handle(Array::New(deopt_infos_.length() * kEntrySize, Heap::kOld)); |
| 396 Smi& offset = Smi::Handle(); | |
| 398 DeoptInfo& info = DeoptInfo::Handle(); | 397 DeoptInfo& info = DeoptInfo::Handle(); |
| 399 for (intptr_t i = 0; i < deopt_infos_.length(); i++) { | 398 Smi& reason = Smi::Handle(); |
| 399 for (intptr_t i = 0, j = 0; i < deopt_infos_.length(); i++) { | |
| 400 offset = Smi::New(deopt_infos_[i]->pc_offset()); | |
| 400 info = deopt_infos_[i]->CreateDeoptInfo(this); | 401 info = deopt_infos_[i]->CreateDeoptInfo(this); |
| 401 array.SetAt(i, info); | 402 reason = Smi::New(deopt_infos_[i]->reason()); |
| 403 array.SetAt(j++, offset); | |
| 404 array.SetAt(j++, info); | |
| 405 array.SetAt(j++, reason); | |
| 402 } | 406 } |
| 403 code.set_deopt_info_array(array); | 407 code.set_deopt_info_array(array); |
| 404 const Array& object_array = Array::Handle(Array::MakeArray(object_table_)); | 408 const Array& object_array = Array::Handle(Array::MakeArray(object_table_)); |
| 405 code.set_object_table(object_array); | 409 code.set_object_table(object_array); |
| 406 } | 410 } |
| 407 | 411 |
| 408 | 412 |
| 409 void FlowGraphCompiler::FinalizeStackmaps(const Code& code) { | 413 void FlowGraphCompiler::FinalizeStackmaps(const Code& code) { |
| 410 if (stackmap_table_builder_ == NULL) { | 414 if (stackmap_table_builder_ == NULL) { |
| 411 // The unoptimizing compiler has no stack maps. | 415 // The unoptimizing compiler has no stack maps. |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 case ABOVE: return unsigned_left > unsigned_right; | 902 case ABOVE: return unsigned_left > unsigned_right; |
| 899 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; | 903 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; |
| 900 default: | 904 default: |
| 901 UNIMPLEMENTED(); | 905 UNIMPLEMENTED(); |
| 902 return false; | 906 return false; |
| 903 } | 907 } |
| 904 } | 908 } |
| 905 | 909 |
| 906 | 910 |
| 907 } // namespace dart | 911 } // namespace dart |
| OLD | NEW |