Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: runtime/vm/flow_graph_allocator.cc

Issue 2388093003: VM: Make optimized try-catch work in DBC. (Closed)
Patch Set: addressed comments, fix bug in CheckClass Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "vm/flow_graph_compiler.h" 11 #include "vm/flow_graph_compiler.h"
12 #include "vm/log.h" 12 #include "vm/log.h"
13 #include "vm/parser.h" 13 #include "vm/parser.h"
14 #include "vm/stack_frame.h"
14 15
15 namespace dart { 16 namespace dart {
16 17
17 #if defined(DEBUG) 18 #if defined(DEBUG)
18 #define TRACE_ALLOC(statement) \ 19 #define TRACE_ALLOC(statement) \
19 do { \ 20 do { \
20 if (FLAG_trace_ssa_allocator) statement; \ 21 if (FLAG_trace_ssa_allocator) statement; \
21 } while (0) 22 } while (0)
22 #else 23 #else
23 #define TRACE_ALLOC(statement) 24 #define TRACE_ALLOC(statement)
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 range->MarkHasOnlyUnconstrainedUsesInLoop(block_info->loop_id()); 606 range->MarkHasOnlyUnconstrainedUsesInLoop(block_info->loop_id());
606 } 607 }
607 } 608 }
608 } 609 }
609 610
610 if (block->IsJoinEntry()) { 611 if (block->IsJoinEntry()) {
611 ConnectIncomingPhiMoves(block->AsJoinEntry()); 612 ConnectIncomingPhiMoves(block->AsJoinEntry());
612 } else if (block->IsCatchBlockEntry()) { 613 } else if (block->IsCatchBlockEntry()) {
613 // Process initial definitions. 614 // Process initial definitions.
614 CatchBlockEntryInstr* catch_entry = block->AsCatchBlockEntry(); 615 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 616
620 ProcessEnvironmentUses(catch_entry, catch_entry); // For lazy deopt 617 ProcessEnvironmentUses(catch_entry, catch_entry); // For lazy deopt
621 618
622 for (intptr_t i = 0; 619 for (intptr_t i = 0;
623 i < catch_entry->initial_definitions()->length(); 620 i < catch_entry->initial_definitions()->length();
624 i++) { 621 i++) {
625 Definition* defn = (*catch_entry->initial_definitions())[i]; 622 Definition* defn = (*catch_entry->initial_definitions())[i];
626 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); 623 LiveRange* range = GetLiveRange(defn->ssa_temp_index());
627 range->DefineAt(catch_entry->start_pos()); // Defined at block entry. 624 range->DefineAt(catch_entry->start_pos()); // Defined at block entry.
628 ProcessInitialDefinition(defn, range, catch_entry); 625 ProcessInitialDefinition(defn, range, catch_entry);
629 } 626 }
630 // Block the two fixed registers used by CatchBlockEntryInstr from the 627 // Block the two fixed registers used by CatchBlockEntryInstr from the
631 // block start to until the end of the instruction so that they are 628 // block start to until the end of the instruction so that they are
632 // preserved. 629 // preserved.
633 intptr_t start = catch_entry->start_pos(); 630 intptr_t start = catch_entry->start_pos();
634 BlockLocation(Location::RegisterLocation(kExceptionObjectReg), 631 #if !defined(TARGET_ARCH_DBC)
632 const Register exception_reg = kExceptionObjectReg;
633 const Register stacktrace_reg = kStackTraceObjectReg;
634 #else
635 const intptr_t exception_reg =
636 LocalVarIndex(0, catch_entry->exception_var().index());
637 const intptr_t stacktrace_reg =
638 LocalVarIndex(0, catch_entry->stacktrace_var().index());
639 #endif
640 BlockLocation(Location::RegisterLocation(exception_reg),
635 start, 641 start,
636 ToInstructionEnd(start)); 642 ToInstructionEnd(start));
637 BlockLocation(Location::RegisterLocation(kStackTraceObjectReg), 643 BlockLocation(Location::RegisterLocation(stacktrace_reg),
638 start, 644 start,
639 ToInstructionEnd(start)); 645 ToInstructionEnd(start));
640 } 646 }
641 } 647 }
642 648
643 // Process incoming parameters and constants. Do this after all other 649 // Process incoming parameters and constants. Do this after all other
644 // instructions so that safepoints for all calls have already been found. 650 // instructions so that safepoints for all calls have already been found.
645 GraphEntryInstr* graph_entry = flow_graph_.graph_entry(); 651 GraphEntryInstr* graph_entry = flow_graph_.graph_entry();
646 for (intptr_t i = 0; i < graph_entry->initial_definitions()->length(); i++) { 652 for (intptr_t i = 0; i < graph_entry->initial_definitions()->length(); i++) {
647 Definition* defn = (*graph_entry->initial_definitions())[i]; 653 Definition* defn = (*graph_entry->initial_definitions())[i];
648 ASSERT(!defn->HasPairRepresentation()); 654 ASSERT(!defn->HasPairRepresentation());
649 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); 655 LiveRange* range = GetLiveRange(defn->ssa_temp_index());
650 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); 656 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos());
651 range->DefineAt(graph_entry->start_pos()); 657 range->DefineAt(graph_entry->start_pos());
652 ProcessInitialDefinition(defn, range, graph_entry); 658 ProcessInitialDefinition(defn, range, graph_entry);
653 } 659 }
654 } 660 }
655 661
656 662
657 void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn, 663 void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn,
658 LiveRange* range, 664 LiveRange* range,
659 BlockEntryInstr* block) { 665 BlockEntryInstr* block) {
666 #if !defined(TARGET_ARCH_DBC)
660 // Save the range end because it may change below. 667 // Save the range end because it may change below.
661 intptr_t range_end = range->End(); 668 intptr_t range_end = range->End();
669 #endif
662 if (defn->IsParameter()) { 670 if (defn->IsParameter()) {
663 ParameterInstr* param = defn->AsParameter(); 671 ParameterInstr* param = defn->AsParameter();
664 // Assert that copied and non-copied parameters are mutually exclusive. 672 // 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. 673 // This might change in the future and, if so, the index will be wrong.
666 ASSERT((flow_graph_.num_copied_params() == 0) || 674 ASSERT((flow_graph_.num_copied_params() == 0) ||
667 (flow_graph_.num_non_copied_params() == 0)); 675 (flow_graph_.num_non_copied_params() == 0));
668 intptr_t slot_index = param->index(); 676 intptr_t slot_index = param->index();
669 ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG)); 677 ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG));
670 if (param->base_reg() == FPREG) { 678 if (param->base_reg() == FPREG) {
671 // Slot index for the leftmost copied parameter is 0. 679 // Slot index for the leftmost copied parameter is 0.
672 // Slot index for the rightmost fixed parameter is -1. 680 // Slot index for the rightmost fixed parameter is -1.
673 slot_index -= flow_graph_.num_non_copied_params(); 681 slot_index -= flow_graph_.num_non_copied_params();
674 } 682 }
675 683
676 #if defined(TARGET_ARCH_DBC) 684 #if defined(TARGET_ARCH_DBC)
677 ASSERT(param->base_reg() == FPREG); 685 ASSERT(param->base_reg() == FPREG);
678 if (slot_index >= 0) { 686 if (slot_index >= 0) {
679 AssignSafepoints(defn, range); 687 AssignSafepoints(defn, range);
680 range->finger()->Initialize(range); 688 range->finger()->Initialize(range);
681 range->set_assigned_location(Location::RegisterLocation(slot_index)); 689 range->set_assigned_location(Location::RegisterLocation(slot_index));
682 if (range->End() > kNormalEntryPos) { 690 if (block->IsGraphEntry() && (range->End() > kNormalEntryPos)) {
683 LiveRange* tail = range->SplitAt(kNormalEntryPos); 691 LiveRange* tail = range->SplitAt(kNormalEntryPos);
684 CompleteRange(tail, Location::kRegister); 692 CompleteRange(tail, Location::kRegister);
685 } 693 }
686 ConvertAllUses(range); 694 ConvertAllUses(range);
687 return; 695 return;
688 } 696 }
689 #endif // defined(TARGET_ARCH_DBC) 697 #endif // defined(TARGET_ARCH_DBC)
690 range->set_assigned_location(Location::StackSlot(slot_index, 698 range->set_assigned_location(Location::StackSlot(slot_index,
691 param->base_reg())); 699 param->base_reg()));
692 range->set_spill_slot(Location::StackSlot(slot_index, 700 range->set_spill_slot(Location::StackSlot(slot_index,
(...skipping 25 matching lines...) Expand all
718 range->finger()->Initialize(range); 726 range->finger()->Initialize(range);
719 UsePosition* use = 727 UsePosition* use =
720 range->finger()->FirstRegisterBeneficialUse(block->start_pos()); 728 range->finger()->FirstRegisterBeneficialUse(block->start_pos());
721 if (use != NULL) { 729 if (use != NULL) {
722 LiveRange* tail = 730 LiveRange* tail =
723 SplitBetween(range, block->start_pos(), use->pos()); 731 SplitBetween(range, block->start_pos(), use->pos());
724 // Parameters and constants are tagged, so allocated to CPU registers. 732 // Parameters and constants are tagged, so allocated to CPU registers.
725 CompleteRange(tail, Location::kRegister); 733 CompleteRange(tail, Location::kRegister);
726 } 734 }
727 ConvertAllUses(range); 735 ConvertAllUses(range);
728 if (defn->IsParameter() && (range->spill_slot().stack_index() >= 0)) { 736 if (defn->IsParameter() && (range->spill_slot().stack_index() >= 0)) {
Vyacheslav Egorov (Google) 2016/10/04 17:07:54 I thought we don't support spilling on DBC. How do
Florian Schneider 2016/10/04 17:11:02 You're right. This should be UNREACHABLE() in DBC.
Vyacheslav Egorov (Google) 2016/10/04 17:55:31 I am still not completely sure how this stuff mana
737 #if !defined(TARGET_ARCH_DBC)
729 // Parameters above the frame pointer consume spill slots and are marked 738 // Parameters above the frame pointer consume spill slots and are marked
730 // in stack maps. 739 // in stack maps.
731 spill_slots_.Add(range_end); 740 spill_slots_.Add(range_end);
732 quad_spill_slots_.Add(false); 741 quad_spill_slots_.Add(false);
733 untagged_spill_slots_.Add(false); 742 untagged_spill_slots_.Add(false);
734 // Note, all incoming parameters are assumed to be tagged. 743 // Note, all incoming parameters are assumed to be tagged.
735 MarkAsObjectAtSafepoints(range); 744 MarkAsObjectAtSafepoints(range);
736 } else if (defn->IsConstant() && block->IsCatchBlockEntry()) { 745 } else if (defn->IsConstant() && block->IsCatchBlockEntry()) {
737 // Constants at catch block entries consume spill slots. 746 // Constants at catch block entries consume spill slots.
738 spill_slots_.Add(range_end); 747 spill_slots_.Add(range_end);
739 quad_spill_slots_.Add(false); 748 quad_spill_slots_.Add(false);
740 untagged_spill_slots_.Add(false); 749 untagged_spill_slots_.Add(false);
750 #else
751 MarkAsObjectAtSafepoints(range);
752 #endif
741 } 753 }
742 } 754 }
743 755
744 756
745 static Location::Kind RegisterKindFromPolicy(Location loc) { 757 static Location::Kind RegisterKindFromPolicy(Location loc) {
746 if (loc.policy() == Location::kRequiresFpuRegister) { 758 if (loc.policy() == Location::kRequiresFpuRegister) {
747 return Location::kFpuRegister; 759 return Location::kFpuRegister;
748 } else { 760 } else {
749 return Location::kRegister; 761 return Location::kRegister;
750 } 762 }
(...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3113 FlowGraphPrinter printer(flow_graph_, true); 3125 FlowGraphPrinter printer(flow_graph_, true);
3114 printer.PrintBlocks(); 3126 printer.PrintBlocks();
3115 #endif 3127 #endif
3116 } 3128 }
3117 THR_Print("----------------------------------------------\n"); 3129 THR_Print("----------------------------------------------\n");
3118 } 3130 }
3119 } 3131 }
3120 3132
3121 3133
3122 } // namespace dart 3134 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.cc » ('j') | runtime/vm/intermediate_language_dbc.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698