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