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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 : assembler_(assembler), | 137 : assembler_(assembler), |
| 138 parsed_function_(flow_graph.parsed_function()), | 138 parsed_function_(flow_graph.parsed_function()), |
| 139 block_order_(flow_graph.reverse_postorder()), | 139 block_order_(flow_graph.reverse_postorder()), |
| 140 current_block_(NULL), | 140 current_block_(NULL), |
| 141 exception_handlers_list_(NULL), | 141 exception_handlers_list_(NULL), |
| 142 pc_descriptors_list_(NULL), | 142 pc_descriptors_list_(NULL), |
| 143 stackmap_table_builder_( | 143 stackmap_table_builder_( |
| 144 is_optimizing ? new StackmapTableBuilder() : NULL), | 144 is_optimizing ? new StackmapTableBuilder() : NULL), |
| 145 block_info_(block_order_.length()), | 145 block_info_(block_order_.length()), |
| 146 deopt_infos_(), | 146 deopt_infos_(), |
| 147 static_calls_target_table_(GrowableObjectArray::ZoneHandle( | |
| 148 GrowableObjectArray::New())), | |
| 147 is_optimizing_(is_optimizing), | 149 is_optimizing_(is_optimizing), |
| 148 may_reoptimize_(false), | 150 may_reoptimize_(false), |
| 149 bool_true_(Bool::ZoneHandle(Bool::True())), | 151 bool_true_(Bool::ZoneHandle(Bool::True())), |
| 150 bool_false_(Bool::ZoneHandle(Bool::False())), | 152 bool_false_(Bool::ZoneHandle(Bool::False())), |
| 151 double_class_(Class::ZoneHandle( | 153 double_class_(Class::ZoneHandle( |
| 152 Isolate::Current()->object_store()->double_class())), | 154 Isolate::Current()->object_store()->double_class())), |
| 153 parallel_move_resolver_(this) { | 155 parallel_move_resolver_(this) { |
| 154 ASSERT(assembler != NULL); | 156 ASSERT(assembler != NULL); |
| 155 } | 157 } |
| 156 | 158 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 intptr_t deopt_id, | 277 intptr_t deopt_id, |
| 276 intptr_t token_pos) { | 278 intptr_t token_pos) { |
| 277 pc_descriptors_list()->AddDescriptor(kind, | 279 pc_descriptors_list()->AddDescriptor(kind, |
| 278 assembler()->CodeSize(), | 280 assembler()->CodeSize(), |
| 279 deopt_id, | 281 deopt_id, |
| 280 token_pos, | 282 token_pos, |
| 281 CurrentTryIndex()); | 283 CurrentTryIndex()); |
| 282 } | 284 } |
| 283 | 285 |
| 284 | 286 |
| 287 void FlowGraphCompiler::AddStaticCallTarget(const Function& func) { | |
| 288 static_calls_target_table_.Add( | |
| 289 Smi::Handle(Smi::New(assembler()->CodeSize()))); | |
| 290 static_calls_target_table_.Add(func); | |
| 291 } | |
| 292 | |
| 293 | |
| 285 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, | 294 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, |
| 286 intptr_t token_pos) { | 295 intptr_t token_pos) { |
| 287 ASSERT(is_optimizing()); | 296 ASSERT(is_optimizing()); |
| 288 CompilerDeoptInfo* info = new CompilerDeoptInfo(deopt_id, kDeoptAtCall); | 297 CompilerDeoptInfo* info = new CompilerDeoptInfo(deopt_id, kDeoptAtCall); |
| 289 ASSERT(pending_deoptimization_env_ != NULL); | 298 ASSERT(pending_deoptimization_env_ != NULL); |
| 290 info->set_deoptimization_env(pending_deoptimization_env_); | 299 info->set_deoptimization_env(pending_deoptimization_env_); |
| 291 info->set_pc_offset(assembler()->CodeSize()); | 300 info->set_pc_offset(assembler()->CodeSize()); |
| 292 deopt_infos_.Add(info); | 301 deopt_infos_.Add(info); |
| 293 } | 302 } |
| 294 | 303 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 Smi& reason = Smi::Handle(); | 398 Smi& reason = Smi::Handle(); |
| 390 for (intptr_t i = 0; i < deopt_infos_.length(); i++) { | 399 for (intptr_t i = 0; i < deopt_infos_.length(); i++) { |
| 391 offset = Smi::New(deopt_infos_[i]->pc_offset()); | 400 offset = Smi::New(deopt_infos_[i]->pc_offset()); |
| 392 info = deopt_infos_[i]->CreateDeoptInfo(this, &builder); | 401 info = deopt_infos_[i]->CreateDeoptInfo(this, &builder); |
| 393 reason = Smi::New(deopt_infos_[i]->reason()); | 402 reason = Smi::New(deopt_infos_[i]->reason()); |
| 394 DeoptTable::SetEntry(array, i, offset, info, reason); | 403 DeoptTable::SetEntry(array, i, offset, info, reason); |
| 395 } | 404 } |
| 396 code.set_deopt_info_array(array); | 405 code.set_deopt_info_array(array); |
| 397 const Array& object_array = | 406 const Array& object_array = |
| 398 Array::Handle(Array::MakeArray(builder.object_table())); | 407 Array::Handle(Array::MakeArray(builder.object_table())); |
| 408 ASSERT(code.object_table() == Array::null()); | |
| 399 code.set_object_table(object_array); | 409 code.set_object_table(object_array); |
| 400 } | 410 } |
| 401 | 411 |
| 402 | 412 |
| 403 void FlowGraphCompiler::FinalizeStackmaps(const Code& code) { | 413 void FlowGraphCompiler::FinalizeStackmaps(const Code& code) { |
| 404 if (stackmap_table_builder_ == NULL) { | 414 if (stackmap_table_builder_ == NULL) { |
| 405 // The unoptimizing compiler has no stack maps. | 415 // The unoptimizing compiler has no stack maps. |
| 406 code.set_stackmaps(Array::Handle()); | 416 code.set_stackmaps(Array::Handle()); |
| 407 } else { | 417 } else { |
| 408 // Finalize the stack map array and add it to the code object. | 418 // Finalize the stack map array and add it to the code object. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 419 parsed_function_.function())); | 429 parsed_function_.function())); |
| 420 code.set_var_descriptors(var_descs); | 430 code.set_var_descriptors(var_descs); |
| 421 } | 431 } |
| 422 | 432 |
| 423 | 433 |
| 424 void FlowGraphCompiler::FinalizeComments(const Code& code) { | 434 void FlowGraphCompiler::FinalizeComments(const Code& code) { |
| 425 code.set_comments(assembler()->GetCodeComments()); | 435 code.set_comments(assembler()->GetCodeComments()); |
| 426 } | 436 } |
| 427 | 437 |
| 428 | 438 |
| 439 void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) { | |
|
siva
2012/11/16 23:15:23
ASSERT(code.static_calls_target_table() == Array::
srdjan
2012/11/17 00:47:24
Done.
| |
| 440 code.set_static_calls_target_table( | |
| 441 Array::Handle(Array::MakeArray(static_calls_target_table_))); | |
| 442 } | |
| 443 | |
| 444 | |
| 429 // Returns 'true' if code generation for this function is complete, i.e., | 445 // Returns 'true' if code generation for this function is complete, i.e., |
| 430 // no fall-through to regular code is needed. | 446 // no fall-through to regular code is needed. |
| 431 bool FlowGraphCompiler::TryIntrinsify() { | 447 bool FlowGraphCompiler::TryIntrinsify() { |
| 432 if (!CanOptimize()) return false; | 448 if (!CanOptimize()) return false; |
| 433 // Intrinsification skips arguments checks, therefore disable if in checked | 449 // Intrinsification skips arguments checks, therefore disable if in checked |
| 434 // mode. | 450 // mode. |
| 435 if (FLAG_intrinsify && !FLAG_enable_type_checks) { | 451 if (FLAG_intrinsify && !FLAG_enable_type_checks) { |
| 436 if (parsed_function().function().kind() == RawFunction::kImplicitGetter) { | 452 if (parsed_function().function().kind() == RawFunction::kImplicitGetter) { |
| 437 // An implicit getter must have a specific AST structure. | 453 // An implicit getter must have a specific AST structure. |
| 438 const SequenceNode& sequence_node = *parsed_function().node_sequence(); | 454 const SequenceNode& sequence_node = *parsed_function().node_sequence(); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 950 ASSERT(Utils::IsInt(31, disp)); | 966 ASSERT(Utils::IsInt(31, disp)); |
| 951 return FieldAddress(array, disp); | 967 return FieldAddress(array, disp); |
| 952 } | 968 } |
| 953 default: | 969 default: |
| 954 UNIMPLEMENTED(); | 970 UNIMPLEMENTED(); |
| 955 return FieldAddress(SPREG, 0); | 971 return FieldAddress(SPREG, 0); |
| 956 } | 972 } |
| 957 } | 973 } |
| 958 | 974 |
| 959 } // namespace dart | 975 } // namespace dart |
| OLD | NEW |