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

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

Issue 2388093003: VM: Make optimized try-catch work in DBC. (Closed)
Patch Set: new test file 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)
667 if (block->IsCatchBlockEntry()) {
668 if (defn->IsParameter()) {
669 ParameterInstr* param = defn->AsParameter();
670 intptr_t slot_index = param->index();
671 AssignSafepoints(defn, range);
672 range->finger()->Initialize(range);
673 slot_index = kNumberOfCpuRegisters - 1 - slot_index;
674 range->set_assigned_location(Location::RegisterLocation(slot_index));
Vyacheslav Egorov (Google) 2016/10/13 15:02:04 Some of this code is repeated below just with kNo
Florian Schneider 2016/10/13 17:24:03 Done.
675 if (range->End() > block->lifetime_position() + 2) {
676 LiveRange* tail = range->SplitAt(block->lifetime_position() + 2);
677 CompleteRange(tail, Location::kRegister);
678 }
679 ConvertAllUses(range);
680 BlockLocation(Location::RegisterLocation(slot_index), 0, kMaxPosition);
681 } else {
682 ConstantInstr* constant = defn->AsConstant();
683 ASSERT(constant != NULL);
684 range->set_assigned_location(Location::Constant(constant));
685 range->set_spill_slot(Location::Constant(constant));
686 AssignSafepoints(defn, range);
687 range->finger()->Initialize(range);
688 UsePosition* use =
689 range->finger()->FirstRegisterBeneficialUse(block->start_pos());
690 if (use != NULL) {
691 LiveRange* tail =
692 SplitBetween(range, block->start_pos(), use->pos());
693 // Parameters and constants are tagged, so allocated to CPU registers.
694 CompleteRange(tail, Location::kRegister);
Vyacheslav Egorov (Google) 2016/10/13 15:02:04 we have UnboxedConstantInstr (which inherits from
Florian Schneider 2016/10/13 17:24:03 Done.
695 }
696 ConvertAllUses(range);
697 }
698 return;
699 }
700 #endif
701
660 // Save the range end because it may change below. 702 // Save the range end because it may change below.
661 intptr_t range_end = range->End(); 703 intptr_t range_end = range->End();
662 if (defn->IsParameter()) { 704 if (defn->IsParameter()) {
663 ParameterInstr* param = defn->AsParameter(); 705 ParameterInstr* param = defn->AsParameter();
664 // Assert that copied and non-copied parameters are mutually exclusive. 706 // 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. 707 // This might change in the future and, if so, the index will be wrong.
666 ASSERT((flow_graph_.num_copied_params() == 0) || 708 ASSERT((flow_graph_.num_copied_params() == 0) ||
667 (flow_graph_.num_non_copied_params() == 0)); 709 (flow_graph_.num_non_copied_params() == 0));
668 intptr_t slot_index = param->index(); 710 intptr_t slot_index = param->index();
669 ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG)); 711 ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG));
(...skipping 2443 matching lines...) Expand 10 before | Expand all | Expand 10 after
3113 FlowGraphPrinter printer(flow_graph_, true); 3155 FlowGraphPrinter printer(flow_graph_, true);
3114 printer.PrintBlocks(); 3156 printer.PrintBlocks();
3115 #endif 3157 #endif
3116 } 3158 }
3117 THR_Print("----------------------------------------------\n"); 3159 THR_Print("----------------------------------------------\n");
3118 } 3160 }
3119 } 3161 }
3120 3162
3121 3163
3122 } // namespace dart 3164 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698