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

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

Issue 2894953002: Support inlining of calls where type arguments are passed to generic functions. (Closed)
Patch Set: work in progress Created 3 years, 5 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"
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 CompleteRange(tail, Location::kRegister); 689 CompleteRange(tail, Location::kRegister);
690 } 690 }
691 ConvertAllUses(range); 691 ConvertAllUses(range);
692 } 692 }
693 return; 693 return;
694 } 694 }
695 #endif 695 #endif
696 696
697 // Save the range end because it may change below. 697 // Save the range end because it may change below.
698 intptr_t range_end = range->End(); 698 intptr_t range_end = range->End();
699 bool is_type_args_param = false;
699 if (defn->IsParameter()) { 700 if (defn->IsParameter()) {
700 ParameterInstr* param = defn->AsParameter(); 701 ParameterInstr* param = defn->AsParameter();
701 // Assert that copied and non-copied parameters are mutually exclusive. 702 // Assert that copied and non-copied parameters are mutually exclusive.
702 // This might change in the future and, if so, the index will be wrong. 703 // This might change in the future and, if so, the index will be wrong.
703 ASSERT((flow_graph_.num_copied_params() == 0) || 704 ASSERT((flow_graph_.num_copied_params() == 0) ||
704 (flow_graph_.num_non_copied_params() == 0)); 705 (flow_graph_.num_non_copied_params() == 0));
705 intptr_t slot_index = param->index(); 706 intptr_t slot_index = param->index();
707 ASSERT(slot_index >= 0); // TODO(regis): Can we encounter a type args here?
706 ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG)); 708 ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG));
707 if (param->base_reg() == FPREG) { 709 if (param->base_reg() == FPREG) {
708 // Slot index for the leftmost copied parameter is 0. 710 // Slot index for the leftmost copied parameter is 0.
709 // Slot index for the rightmost fixed parameter is -1. 711 // Slot index for the rightmost fixed parameter is -1.
710 slot_index -= flow_graph_.num_non_copied_params(); 712 slot_index -= flow_graph_.num_non_copied_params();
711 } 713 }
712 714
713 #if defined(TARGET_ARCH_DBC) 715 #if defined(TARGET_ARCH_DBC)
714 ASSERT(param->base_reg() == FPREG); 716 ASSERT(param->base_reg() == FPREG);
715 if (slot_index >= 0) { 717 if (slot_index >= 0) {
716 AssignSafepoints(defn, range); 718 AssignSafepoints(defn, range);
717 range->finger()->Initialize(range); 719 range->finger()->Initialize(range);
718 range->set_assigned_location(Location::RegisterLocation(slot_index)); 720 range->set_assigned_location(Location::RegisterLocation(slot_index));
719 SplitInitialDefinitionAt(range, kNormalEntryPos); 721 SplitInitialDefinitionAt(range, kNormalEntryPos);
720 ConvertAllUses(range); 722 ConvertAllUses(range);
721 return; 723 return;
722 } 724 }
723 #endif // defined(TARGET_ARCH_DBC) 725 #endif // defined(TARGET_ARCH_DBC)
724 range->set_assigned_location( 726 range->set_assigned_location(
725 Location::StackSlot(slot_index, param->base_reg())); 727 Location::StackSlot(slot_index, param->base_reg()));
726 range->set_spill_slot(Location::StackSlot(slot_index, param->base_reg())); 728 range->set_spill_slot(Location::StackSlot(slot_index, param->base_reg()));
727 729
728 } else if (defn->IsCurrentContext()) { 730 } else if (defn->IsSpecialParameter()) {
731 SpecialParameterInstr* param = defn->AsSpecialParameter();
732 if (param->kind() == SpecialParameterInstr::kContext) {
729 #if !defined(TARGET_ARCH_DBC) 733 #if !defined(TARGET_ARCH_DBC)
730 const Register context_reg = CTX; 734 const Register context_reg = CTX;
731 #else 735 #else
732 const intptr_t context_reg = flow_graph_.num_copied_params(); 736 const intptr_t context_reg = flow_graph_.num_copied_params();
733 #endif 737 #endif
734 738
735 AssignSafepoints(defn, range); 739 AssignSafepoints(defn, range);
736 range->finger()->Initialize(range); 740 range->finger()->Initialize(range);
737 range->set_assigned_location(Location::RegisterLocation(context_reg)); 741 range->set_assigned_location(Location::RegisterLocation(context_reg));
738 if (range->End() > kNormalEntryPos) { 742 if (range->End() > kNormalEntryPos) {
739 LiveRange* tail = range->SplitAt(kNormalEntryPos); 743 LiveRange* tail = range->SplitAt(kNormalEntryPos);
740 CompleteRange(tail, Location::kRegister); 744 CompleteRange(tail, Location::kRegister);
745 }
746 ConvertAllUses(range);
747 return;
741 } 748 }
742 ConvertAllUses(range); 749 ASSERT(param->kind() == SpecialParameterInstr::kTypeArgs);
743 return; 750 is_type_args_param = true;
751 #if defined(TARGET_ARCH_DBC)
752 UNIMPLEMENTED();
753 #endif
754 const intptr_t slot_index = flow_graph_.num_copied_params();
755 range->set_assigned_location(Location::StackSlot(slot_index, FPREG));
756 range->set_spill_slot(Location::StackSlot(slot_index, FPREG));
744 } else { 757 } else {
745 ConstantInstr* constant = defn->AsConstant(); 758 ConstantInstr* constant = defn->AsConstant();
746 ASSERT(constant != NULL); 759 ASSERT(constant != NULL);
747 range->set_assigned_location(Location::Constant(constant)); 760 range->set_assigned_location(Location::Constant(constant));
748 range->set_spill_slot(Location::Constant(constant)); 761 range->set_spill_slot(Location::Constant(constant));
749 } 762 }
750 AssignSafepoints(defn, range); 763 AssignSafepoints(defn, range);
751 range->finger()->Initialize(range); 764 range->finger()->Initialize(range);
752 UsePosition* use = 765 UsePosition* use =
753 range->finger()->FirstRegisterBeneficialUse(block->start_pos()); 766 range->finger()->FirstRegisterBeneficialUse(block->start_pos());
754 if (use != NULL) { 767 if (use != NULL) {
755 LiveRange* tail = SplitBetween(range, block->start_pos(), use->pos()); 768 LiveRange* tail = SplitBetween(range, block->start_pos(), use->pos());
756 // Parameters and constants are tagged, so allocated to CPU registers. 769 // Parameters and constants are tagged, so allocated to CPU registers.
757 CompleteRange(tail, Location::kRegister); 770 CompleteRange(tail, Location::kRegister);
758 } 771 }
759 ConvertAllUses(range); 772 ConvertAllUses(range);
760 if (defn->IsParameter() && (range->spill_slot().stack_index() >= 0)) { 773 if ((defn->IsParameter() || is_type_args_param) &&
774 (range->spill_slot().stack_index() >= 0)) {
761 // Parameters above the frame pointer consume spill slots and are marked 775 // Parameters above the frame pointer consume spill slots and are marked
762 // in stack maps. 776 // in stack maps.
763 spill_slots_.Add(range_end); 777 spill_slots_.Add(range_end);
764 quad_spill_slots_.Add(false); 778 quad_spill_slots_.Add(false);
765 untagged_spill_slots_.Add(false); 779 untagged_spill_slots_.Add(false);
766 // Note, all incoming parameters are assumed to be tagged. 780 // Note, all incoming parameters are assumed to be tagged.
767 MarkAsObjectAtSafepoints(range); 781 MarkAsObjectAtSafepoints(range);
768 } else if (defn->IsConstant() && block->IsCatchBlockEntry()) { 782 } else if (defn->IsConstant() && block->IsCatchBlockEntry()) {
769 // Constants at catch block entries consume spill slots. 783 // Constants at catch block entries consume spill slots.
770 spill_slots_.Add(range_end); 784 spill_slots_.Add(range_end);
(...skipping 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 FlowGraphPrinter printer(flow_graph_, true); 3103 FlowGraphPrinter printer(flow_graph_, true);
3090 printer.PrintBlocks(); 3104 printer.PrintBlocks();
3091 #endif 3105 #endif
3092 } 3106 }
3093 THR_Print("----------------------------------------------\n"); 3107 THR_Print("----------------------------------------------\n");
3094 } 3108 }
3095 } 3109 }
3096 3110
3097 3111
3098 } // namespace dart 3112 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698