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.h" | 10 #include "vm/flow_graph.h" |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 ParameterInstr* param = val->definition()->AsParameter(); | 524 ParameterInstr* param = val->definition()->AsParameter(); |
525 if (param == NULL) continue; | 525 if (param == NULL) continue; |
526 | 526 |
527 // Handle the parameters specially. They are spilled on entry. | 527 // Handle the parameters specially. They are spilled on entry. |
528 LiveRange* range = GetLiveRange(param->ssa_temp_index()); | 528 LiveRange* range = GetLiveRange(param->ssa_temp_index()); |
529 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); | 529 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); |
530 range->DefineAt(graph_entry->start_pos()); | 530 range->DefineAt(graph_entry->start_pos()); |
531 | 531 |
532 // Assert that copied and non-copied parameters are mutually exclusive. | 532 // Assert that copied and non-copied parameters are mutually exclusive. |
533 // This might change in the future and, if so, the index will be wrong. | 533 // This might change in the future and, if so, the index will be wrong. |
534 ASSERT(flow_graph_.copied_parameter_count() == 0 || | 534 ASSERT((flow_graph_.num_copied_params() == 0) || |
535 flow_graph_.non_copied_parameter_count() == 0); | 535 (flow_graph_.num_non_copied_params() == 0)); |
536 // Slot index for the leftmost copied parameter is 0. | 536 // Slot index for the leftmost copied parameter is 0. |
537 intptr_t slot_index = param->index(); | 537 intptr_t slot_index = param->index(); |
538 // Slot index for the rightmost fixed parameter is -1. | 538 // Slot index for the rightmost fixed parameter is -1. |
539 slot_index -= flow_graph_.non_copied_parameter_count(); | 539 slot_index -= flow_graph_.num_non_copied_params(); |
540 | 540 |
541 range->set_assigned_location(Location::StackSlot(slot_index)); | 541 range->set_assigned_location(Location::StackSlot(slot_index)); |
542 range->set_spill_slot(Location::StackSlot(slot_index)); | 542 range->set_spill_slot(Location::StackSlot(slot_index)); |
543 if (flow_graph_.copied_parameter_count() > 0) { | 543 if (flow_graph_.num_copied_params() > 0) { |
544 ASSERT(spill_slots_.length() == slot_index); | 544 ASSERT(spill_slots_.length() == slot_index); |
545 spill_slots_.Add(range->End()); | 545 spill_slots_.Add(range->End()); |
546 } | 546 } |
547 | 547 |
548 AssignSafepoints(range); | 548 AssignSafepoints(range); |
549 | 549 |
550 range->finger()->Initialize(range); | 550 range->finger()->Initialize(range); |
551 UsePosition* use = | 551 UsePosition* use = |
552 range->finger()->FirstRegisterBeneficialUse(graph_entry->start_pos()); | 552 range->finger()->FirstRegisterBeneficialUse(graph_entry->start_pos()); |
553 if (use != NULL) { | 553 if (use != NULL) { |
554 LiveRange* tail = | 554 LiveRange* tail = |
555 SplitBetween(range, graph_entry->start_pos(), use->pos()); | 555 SplitBetween(range, graph_entry->start_pos(), use->pos()); |
556 // All incoming parameters are tagged. | 556 // All incoming parameters are tagged. |
557 CompleteRange(tail, Location::kRegister); | 557 CompleteRange(tail, Location::kRegister); |
558 } | 558 } |
559 ConvertAllUses(range); | 559 ConvertAllUses(range); |
560 if (flow_graph_.copied_parameter_count() > 0) { | 560 if (flow_graph_.num_copied_params() > 0) { |
561 MarkAsObjectAtSafepoints(range); | 561 MarkAsObjectAtSafepoints(range); |
562 } | 562 } |
563 } | 563 } |
564 | 564 |
565 // Process global constants. | 565 // Process global constants. |
566 ConstantInstr* null_defn = graph_entry->constant_null(); | 566 ConstantInstr* null_defn = graph_entry->constant_null(); |
567 LiveRange* range = GetLiveRange(null_defn->ssa_temp_index()); | 567 LiveRange* range = GetLiveRange(null_defn->ssa_temp_index()); |
568 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); | 568 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); |
569 range->DefineAt(graph_entry->start_pos()); | 569 range->DefineAt(graph_entry->start_pos()); |
570 range->set_assigned_location(Location::Constant(null_defn->value())); | 570 range->set_assigned_location(Location::Constant(null_defn->value())); |
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", | 2183 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", |
2184 function.ToFullyQualifiedCString()); | 2184 function.ToFullyQualifiedCString()); |
2185 FlowGraphPrinter printer(flow_graph_, true); | 2185 FlowGraphPrinter printer(flow_graph_, true); |
2186 printer.PrintBlocks(); | 2186 printer.PrintBlocks(); |
2187 OS::Print("----------------------------------------------\n"); | 2187 OS::Print("----------------------------------------------\n"); |
2188 } | 2188 } |
2189 } | 2189 } |
2190 | 2190 |
2191 | 2191 |
2192 } // namespace dart | 2192 } // namespace dart |
OLD | NEW |