| 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/flow_graph_allocator.h" | 5 #include "vm/flow_graph_allocator.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 #include "vm/il_printer.h" | 9 #include "vm/il_printer.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 // Skip parallel moves that we insert while processing instructions. | 441 // Skip parallel moves that we insert while processing instructions. |
| 442 if (!current->IsParallelMove()) { | 442 if (!current->IsParallelMove()) { |
| 443 ProcessOneInstruction(block, current); | 443 ProcessOneInstruction(block, current); |
| 444 } | 444 } |
| 445 current = current->previous(); | 445 current = current->previous(); |
| 446 } | 446 } |
| 447 | 447 |
| 448 ConnectIncomingPhiMoves(block); | 448 ConnectIncomingPhiMoves(block); |
| 449 } | 449 } |
| 450 | 450 |
| 451 const bool copied = builder_->parsed_function().copied_parameter_count() > 0; |
| 452 |
| 451 // Process incoming parameters. | 453 // Process incoming parameters. |
| 452 const intptr_t fixed_parameters_count = | 454 const intptr_t fixed_parameters_count = |
| 453 builder_->parsed_function().function().num_fixed_parameters(); | 455 builder_->parsed_function().function().num_fixed_parameters(); |
| 454 | 456 |
| 455 GraphEntryInstr* graph_entry = postorder_[block_count - 1]->AsGraphEntry(); | 457 GraphEntryInstr* graph_entry = postorder_[block_count - 1]->AsGraphEntry(); |
| 456 for (intptr_t i = 0; i < graph_entry->start_env()->values().length(); i++) { | 458 for (intptr_t i = 0; i < graph_entry->start_env()->values().length(); i++) { |
| 457 Value* val = graph_entry->start_env()->values()[i]; | 459 Value* val = graph_entry->start_env()->values()[i]; |
| 458 if (val->IsUse()) { | 460 if (val->IsUse()) { |
| 459 ParameterInstr* param = val->AsUse()->definition()->AsParameter(); | 461 ParameterInstr* param = val->AsUse()->definition()->AsParameter(); |
| 460 | 462 |
| 461 LiveRange* range = GetLiveRange(param->ssa_temp_index()); | 463 LiveRange* range = GetLiveRange(param->ssa_temp_index()); |
| 462 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); | 464 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); |
| 463 range->DefineAt(graph_entry->start_pos()); | 465 range->DefineAt(graph_entry->start_pos()); |
| 464 | 466 |
| 465 // Slot index for the rightmost parameter is -1. | 467 // Slot index for the leftmost copied parameter is 0. |
| 466 const intptr_t slot_index = param->index() - fixed_parameters_count; | 468 intptr_t slot_index = param->index(); |
| 469 if (!copied) { |
| 470 // Slot index for the rightmost fixed parameter is -1. |
| 471 slot_index -= fixed_parameters_count; |
| 472 } |
| 473 |
| 467 range->set_assigned_location(Location::StackSlot(slot_index)); | 474 range->set_assigned_location(Location::StackSlot(slot_index)); |
| 468 range->set_spill_slot(Location::StackSlot(slot_index)); | 475 range->set_spill_slot(Location::StackSlot(slot_index)); |
| 469 | 476 |
| 470 range->finger()->Initialize(range); | 477 range->finger()->Initialize(range); |
| 471 UsePosition* use = range->finger()->FirstRegisterBeneficialUse( | 478 UsePosition* use = range->finger()->FirstRegisterBeneficialUse( |
| 472 graph_entry->start_pos()); | 479 graph_entry->start_pos()); |
| 473 if (use != NULL) { | 480 if (use != NULL) { |
| 474 LiveRange* tail = SplitBetween(range, | 481 LiveRange* tail = SplitBetween(range, |
| 475 graph_entry->start_pos(), | 482 graph_entry->start_pos(), |
| 476 use->pos()); | 483 use->pos()); |
| 477 AddToUnallocated(tail); | 484 AddToUnallocated(tail); |
| 478 } | 485 } |
| 479 ConvertAllUses(range); | 486 ConvertAllUses(range); |
| 487 |
| 488 if (copied) { |
| 489 ASSERT(spill_slots_.length() == slot_index); |
| 490 spill_slots_.Add(range->End()); |
| 491 } |
| 480 } | 492 } |
| 481 } | 493 } |
| 482 } | 494 } |
| 483 | 495 |
| 484 // | 496 // |
| 485 // When describing shape of live ranges in comments below we are going to use | 497 // When describing shape of live ranges in comments below we are going to use |
| 486 // the following notation: | 498 // the following notation: |
| 487 // | 499 // |
| 488 // B block entry | 500 // B block entry |
| 489 // g g' start and end of goto instruction | 501 // g g' start and end of goto instruction |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", | 1766 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", |
| 1755 function.ToFullyQualifiedCString()); | 1767 function.ToFullyQualifiedCString()); |
| 1756 FlowGraphPrinter printer(Function::Handle(), block_order_, true); | 1768 FlowGraphPrinter printer(Function::Handle(), block_order_, true); |
| 1757 printer.PrintBlocks(); | 1769 printer.PrintBlocks(); |
| 1758 OS::Print("----------------------------------------------\n"); | 1770 OS::Print("----------------------------------------------\n"); |
| 1759 } | 1771 } |
| 1760 } | 1772 } |
| 1761 | 1773 |
| 1762 | 1774 |
| 1763 } // namespace dart | 1775 } // namespace dart |
| OLD | NEW |