Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 range->MarkHasOnlyUnconstrainedUsesInLoop(block_info->loop_id()); | 605 range->MarkHasOnlyUnconstrainedUsesInLoop(block_info->loop_id()); |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 } | 608 } |
| 609 | 609 |
| 610 if (block->IsJoinEntry()) { | 610 if (block->IsJoinEntry()) { |
| 611 ConnectIncomingPhiMoves(block->AsJoinEntry()); | 611 ConnectIncomingPhiMoves(block->AsJoinEntry()); |
| 612 } else if (block->IsCatchBlockEntry()) { | 612 } else if (block->IsCatchBlockEntry()) { |
| 613 // Process initial definitions. | 613 // Process initial definitions. |
| 614 CatchBlockEntryInstr* catch_entry = block->AsCatchBlockEntry(); | 614 CatchBlockEntryInstr* catch_entry = block->AsCatchBlockEntry(); |
| 615 #if defined(TARGET_ARCH_DBC) | |
| 616 // TODO(vegorov) support try-catch/finally for DBC. | |
| 617 flow_graph_.parsed_function().Bailout("FlowGraphAllocator", "Catch"); | |
| 618 #endif | |
| 619 | 615 |
| 620 ProcessEnvironmentUses(catch_entry, catch_entry); // For lazy deopt | 616 ProcessEnvironmentUses(catch_entry, catch_entry); // For lazy deopt |
| 621 | 617 |
| 622 for (intptr_t i = 0; | 618 for (intptr_t i = 0; |
| 623 i < catch_entry->initial_definitions()->length(); | 619 i < catch_entry->initial_definitions()->length(); |
| 624 i++) { | 620 i++) { |
| 625 Definition* defn = (*catch_entry->initial_definitions())[i]; | 621 Definition* defn = (*catch_entry->initial_definitions())[i]; |
| 626 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); | 622 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); |
| 627 range->DefineAt(catch_entry->start_pos()); // Defined at block entry. | 623 range->DefineAt(catch_entry->start_pos()); // Defined at block entry. |
| 628 ProcessInitialDefinition(defn, range, catch_entry); | 624 ProcessInitialDefinition(defn, range, catch_entry); |
| 629 } | 625 } |
| 630 // Block the two fixed registers used by CatchBlockEntryInstr from the | 626 // Block the two fixed registers used by CatchBlockEntryInstr from the |
| 631 // block start to until the end of the instruction so that they are | 627 // block start to until the end of the instruction so that they are |
| 632 // preserved. | 628 // preserved. |
| 633 intptr_t start = catch_entry->start_pos(); | 629 intptr_t start = catch_entry->start_pos(); |
| 634 BlockLocation(Location::RegisterLocation(kExceptionObjectReg), | 630 #if !defined(TARGET_ARCH_DBC) |
| 631 intptr_t exception_reg = kExceptionObjectReg; | |
| 632 intptr_t stacktrace_reg = kStackTraceObjectReg; | |
| 633 #else | |
| 634 intptr_t exception_reg = -catch_entry->exception_var().index() - 1; | |
|
zra
2016/10/04 15:22:48
Can you use LocalVarIndex() in stack_frame_dbc.h
Florian Schneider
2016/10/04 17:01:04
Done. Here and in CatchBlockEntryInstr::EmitNative
| |
| 635 intptr_t stacktrace_reg = -catch_entry->stacktrace_var().index() - 1; | |
| 636 #endif | |
| 637 BlockLocation(Location::RegisterLocation(exception_reg), | |
| 635 start, | 638 start, |
| 636 ToInstructionEnd(start)); | 639 ToInstructionEnd(start)); |
| 637 BlockLocation(Location::RegisterLocation(kStackTraceObjectReg), | 640 BlockLocation(Location::RegisterLocation(stacktrace_reg), |
| 638 start, | 641 start, |
| 639 ToInstructionEnd(start)); | 642 ToInstructionEnd(start)); |
| 640 } | 643 } |
| 641 } | 644 } |
| 642 | 645 |
| 643 // Process incoming parameters and constants. Do this after all other | 646 // Process incoming parameters and constants. Do this after all other |
| 644 // instructions so that safepoints for all calls have already been found. | 647 // instructions so that safepoints for all calls have already been found. |
| 645 GraphEntryInstr* graph_entry = flow_graph_.graph_entry(); | 648 GraphEntryInstr* graph_entry = flow_graph_.graph_entry(); |
| 646 for (intptr_t i = 0; i < graph_entry->initial_definitions()->length(); i++) { | 649 for (intptr_t i = 0; i < graph_entry->initial_definitions()->length(); i++) { |
| 647 Definition* defn = (*graph_entry->initial_definitions())[i]; | 650 Definition* defn = (*graph_entry->initial_definitions())[i]; |
| 648 ASSERT(!defn->HasPairRepresentation()); | 651 ASSERT(!defn->HasPairRepresentation()); |
| 649 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); | 652 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); |
| 650 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); | 653 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); |
| 651 range->DefineAt(graph_entry->start_pos()); | 654 range->DefineAt(graph_entry->start_pos()); |
| 652 ProcessInitialDefinition(defn, range, graph_entry); | 655 ProcessInitialDefinition(defn, range, graph_entry); |
| 653 } | 656 } |
| 654 } | 657 } |
| 655 | 658 |
| 656 | 659 |
| 657 void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, | 660 void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, |
| 658 LiveRange* range, | 661 LiveRange* range, |
| 659 BlockEntryInstr* block) { | 662 BlockEntryInstr* block) { |
| 663 #if !defined(TARGET_ARCH_DBC) | |
| 660 // Save the range end because it may change below. | 664 // Save the range end because it may change below. |
| 661 intptr_t range_end = range->End(); | 665 intptr_t range_end = range->End(); |
| 666 #endif | |
| 662 if (defn->IsParameter()) { | 667 if (defn->IsParameter()) { |
| 663 ParameterInstr* param = defn->AsParameter(); | 668 ParameterInstr* param = defn->AsParameter(); |
| 664 // Assert that copied and non-copied parameters are mutually exclusive. | 669 // Assert that copied and non-copied parameters are mutually exclusive. |
| 665 // This might change in the future and, if so, the index will be wrong. | 670 // This might change in the future and, if so, the index will be wrong. |
| 666 ASSERT((flow_graph_.num_copied_params() == 0) || | 671 ASSERT((flow_graph_.num_copied_params() == 0) || |
| 667 (flow_graph_.num_non_copied_params() == 0)); | 672 (flow_graph_.num_non_copied_params() == 0)); |
| 668 intptr_t slot_index = param->index(); | 673 intptr_t slot_index = param->index(); |
| 669 ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG)); | 674 ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG)); |
| 670 if (param->base_reg() == FPREG) { | 675 if (param->base_reg() == FPREG) { |
| 671 // Slot index for the leftmost copied parameter is 0. | 676 // Slot index for the leftmost copied parameter is 0. |
| 672 // Slot index for the rightmost fixed parameter is -1. | 677 // Slot index for the rightmost fixed parameter is -1. |
| 673 slot_index -= flow_graph_.num_non_copied_params(); | 678 slot_index -= flow_graph_.num_non_copied_params(); |
| 674 } | 679 } |
| 675 | 680 |
| 676 #if defined(TARGET_ARCH_DBC) | 681 #if defined(TARGET_ARCH_DBC) |
| 677 ASSERT(param->base_reg() == FPREG); | 682 ASSERT(param->base_reg() == FPREG); |
| 678 if (slot_index >= 0) { | 683 if (slot_index >= 0) { |
| 679 AssignSafepoints(defn, range); | 684 AssignSafepoints(defn, range); |
| 680 range->finger()->Initialize(range); | 685 range->finger()->Initialize(range); |
| 681 range->set_assigned_location(Location::RegisterLocation(slot_index)); | 686 range->set_assigned_location(Location::RegisterLocation(slot_index)); |
| 682 if (range->End() > kNormalEntryPos) { | 687 if (block->IsGraphEntry() && range->End() > kNormalEntryPos) { |
|
zra
2016/10/04 15:22:48
Parens around >
Florian Schneider
2016/10/04 17:01:04
Done.
| |
| 683 LiveRange* tail = range->SplitAt(kNormalEntryPos); | 688 LiveRange* tail = range->SplitAt(kNormalEntryPos); |
| 684 CompleteRange(tail, Location::kRegister); | 689 CompleteRange(tail, Location::kRegister); |
| 685 } | 690 } |
| 686 ConvertAllUses(range); | 691 ConvertAllUses(range); |
| 687 return; | 692 return; |
| 688 } | 693 } |
| 689 #endif // defined(TARGET_ARCH_DBC) | 694 #endif // defined(TARGET_ARCH_DBC) |
| 690 range->set_assigned_location(Location::StackSlot(slot_index, | 695 range->set_assigned_location(Location::StackSlot(slot_index, |
| 691 param->base_reg())); | 696 param->base_reg())); |
| 692 range->set_spill_slot(Location::StackSlot(slot_index, | 697 range->set_spill_slot(Location::StackSlot(slot_index, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 719 UsePosition* use = | 724 UsePosition* use = |
| 720 range->finger()->FirstRegisterBeneficialUse(block->start_pos()); | 725 range->finger()->FirstRegisterBeneficialUse(block->start_pos()); |
| 721 if (use != NULL) { | 726 if (use != NULL) { |
| 722 LiveRange* tail = | 727 LiveRange* tail = |
| 723 SplitBetween(range, block->start_pos(), use->pos()); | 728 SplitBetween(range, block->start_pos(), use->pos()); |
| 724 // Parameters and constants are tagged, so allocated to CPU registers. | 729 // Parameters and constants are tagged, so allocated to CPU registers. |
| 725 CompleteRange(tail, Location::kRegister); | 730 CompleteRange(tail, Location::kRegister); |
| 726 } | 731 } |
| 727 ConvertAllUses(range); | 732 ConvertAllUses(range); |
| 728 if (defn->IsParameter() && (range->spill_slot().stack_index() >= 0)) { | 733 if (defn->IsParameter() && (range->spill_slot().stack_index() >= 0)) { |
| 734 #if !defined(TARGET_ARCH_DBC) | |
|
zra
2016/10/04 15:22:48
Maybe it would be cleaner to try to use only one #
Florian Schneider
2016/10/04 17:01:04
Done.
| |
| 729 // Parameters above the frame pointer consume spill slots and are marked | 735 // Parameters above the frame pointer consume spill slots and are marked |
| 730 // in stack maps. | 736 // in stack maps. |
| 731 spill_slots_.Add(range_end); | 737 spill_slots_.Add(range_end); |
| 732 quad_spill_slots_.Add(false); | 738 quad_spill_slots_.Add(false); |
| 733 untagged_spill_slots_.Add(false); | 739 untagged_spill_slots_.Add(false); |
| 740 #endif | |
| 734 // Note, all incoming parameters are assumed to be tagged. | 741 // Note, all incoming parameters are assumed to be tagged. |
| 735 MarkAsObjectAtSafepoints(range); | 742 MarkAsObjectAtSafepoints(range); |
| 736 } else if (defn->IsConstant() && block->IsCatchBlockEntry()) { | 743 } else if (defn->IsConstant() && block->IsCatchBlockEntry()) { |
| 744 #if !defined(TARGET_ARCH_DBC) | |
| 737 // Constants at catch block entries consume spill slots. | 745 // Constants at catch block entries consume spill slots. |
| 738 spill_slots_.Add(range_end); | 746 spill_slots_.Add(range_end); |
| 739 quad_spill_slots_.Add(false); | 747 quad_spill_slots_.Add(false); |
| 740 untagged_spill_slots_.Add(false); | 748 untagged_spill_slots_.Add(false); |
| 749 #endif | |
| 741 } | 750 } |
| 742 } | 751 } |
| 743 | 752 |
| 744 | 753 |
| 745 static Location::Kind RegisterKindFromPolicy(Location loc) { | 754 static Location::Kind RegisterKindFromPolicy(Location loc) { |
| 746 if (loc.policy() == Location::kRequiresFpuRegister) { | 755 if (loc.policy() == Location::kRequiresFpuRegister) { |
| 747 return Location::kFpuRegister; | 756 return Location::kFpuRegister; |
| 748 } else { | 757 } else { |
| 749 return Location::kRegister; | 758 return Location::kRegister; |
| 750 } | 759 } |
| (...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3113 FlowGraphPrinter printer(flow_graph_, true); | 3122 FlowGraphPrinter printer(flow_graph_, true); |
| 3114 printer.PrintBlocks(); | 3123 printer.PrintBlocks(); |
| 3115 #endif | 3124 #endif |
| 3116 } | 3125 } |
| 3117 THR_Print("----------------------------------------------\n"); | 3126 THR_Print("----------------------------------------------\n"); |
| 3118 } | 3127 } |
| 3119 } | 3128 } |
| 3120 | 3129 |
| 3121 | 3130 |
| 3122 } // namespace dart | 3131 } // namespace dart |
| OLD | NEW |