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

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

Issue 504143003: Support Int32 representation for selected binary operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 // Slot index for the leftmost copied parameter is 0. 616 // Slot index for the leftmost copied parameter is 0.
617 intptr_t slot_index = param->index(); 617 intptr_t slot_index = param->index();
618 // Slot index for the rightmost fixed parameter is -1. 618 // Slot index for the rightmost fixed parameter is -1.
619 slot_index -= flow_graph_.num_non_copied_params(); 619 slot_index -= flow_graph_.num_non_copied_params();
620 620
621 range->set_assigned_location(Location::StackSlot(slot_index)); 621 range->set_assigned_location(Location::StackSlot(slot_index));
622 range->set_spill_slot(Location::StackSlot(slot_index)); 622 range->set_spill_slot(Location::StackSlot(slot_index));
623 } else { 623 } else {
624 ConstantInstr* constant = defn->AsConstant(); 624 ConstantInstr* constant = defn->AsConstant();
625 ASSERT(constant != NULL); 625 ASSERT(constant != NULL);
626 range->set_assigned_location(Location::Constant(constant->value())); 626 range->set_assigned_location(Location::Constant(constant));
627 range->set_spill_slot(Location::Constant(constant->value())); 627 range->set_spill_slot(Location::Constant(constant));
628 } 628 }
629 AssignSafepoints(defn, range); 629 AssignSafepoints(defn, range);
630 range->finger()->Initialize(range); 630 range->finger()->Initialize(range);
631 UsePosition* use = 631 UsePosition* use =
632 range->finger()->FirstRegisterBeneficialUse(block->start_pos()); 632 range->finger()->FirstRegisterBeneficialUse(block->start_pos());
633 if (use != NULL) { 633 if (use != NULL) {
634 LiveRange* tail = 634 LiveRange* tail =
635 SplitBetween(range, block->start_pos(), use->pos()); 635 SplitBetween(range, block->start_pos(), use->pos());
636 // Parameters and constants are tagged, so allocated to CPU registers. 636 // Parameters and constants are tagged, so allocated to CPU registers.
637 CompleteRange(tail, Location::kRegister); 637 CompleteRange(tail, Location::kRegister);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 // Record the corresponding phi input use for each phi. 727 // Record the corresponding phi input use for each phi.
728 intptr_t move_idx = 0; 728 intptr_t move_idx = 0;
729 for (PhiIterator it(join); !it.Done(); it.Advance()) { 729 for (PhiIterator it(join); !it.Done(); it.Advance()) {
730 // TODO(johnmccutchan): Fix handling of PhiInstr with PairLocation. 730 // TODO(johnmccutchan): Fix handling of PhiInstr with PairLocation.
731 PhiInstr* phi = it.Current(); 731 PhiInstr* phi = it.Current();
732 Value* val = phi->InputAt(pred_idx); 732 Value* val = phi->InputAt(pred_idx);
733 MoveOperands* move = parallel_move->MoveOperandsAt(move_idx); 733 MoveOperands* move = parallel_move->MoveOperandsAt(move_idx);
734 734
735 ConstantInstr* constant = val->definition()->AsConstant(); 735 ConstantInstr* constant = val->definition()->AsConstant();
736 if (constant != NULL) { 736 if (constant != NULL) {
737 move->set_src(Location::Constant(constant->value())); 737 move->set_src(Location::Constant(constant));
738 move_idx++; 738 move_idx++;
739 continue; 739 continue;
740 } 740 }
741 741
742 // Expected shape of live ranges: 742 // Expected shape of live ranges:
743 // 743 //
744 // g g' 744 // g g'
745 // value --* 745 // value --*
746 // 746 //
747 747
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 } 842 }
843 843
844 if (def->IsPushArgument()) { 844 if (def->IsPushArgument()) {
845 // Frame size is unknown until after allocation. 845 // Frame size is unknown until after allocation.
846 locations[i] = Location::NoLocation(); 846 locations[i] = Location::NoLocation();
847 continue; 847 continue;
848 } 848 }
849 849
850 ConstantInstr* constant = def->AsConstant(); 850 ConstantInstr* constant = def->AsConstant();
851 if (constant != NULL) { 851 if (constant != NULL) {
852 locations[i] = Location::Constant(constant->value()); 852 locations[i] = Location::Constant(constant);
853 continue; 853 continue;
854 } 854 }
855 855
856 MaterializeObjectInstr* mat = def->AsMaterializeObject(); 856 MaterializeObjectInstr* mat = def->AsMaterializeObject();
857 if (mat != NULL) { 857 if (mat != NULL) {
858 // MaterializeObject itself produces no value. But its uses 858 // MaterializeObject itself produces no value. But its uses
859 // are treated as part of the environment: allocated locations 859 // are treated as part of the environment: allocated locations
860 // will be used when building deoptimization data. 860 // will be used when building deoptimization data.
861 locations[i] = Location::NoLocation(); 861 locations[i] = Location::NoLocation();
862 ProcessMaterializationUses(block, block_start_pos, use_pos, mat); 862 ProcessMaterializationUses(block, block_start_pos, use_pos, mat);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 // Initialize location for every input of the MaterializeObject instruction. 905 // Initialize location for every input of the MaterializeObject instruction.
906 Location* locations = 906 Location* locations =
907 Isolate::Current()->current_zone()->Alloc<Location>(mat->InputCount()); 907 Isolate::Current()->current_zone()->Alloc<Location>(mat->InputCount());
908 mat->set_locations(locations); 908 mat->set_locations(locations);
909 909
910 for (intptr_t i = 0; i < mat->InputCount(); ++i) { 910 for (intptr_t i = 0; i < mat->InputCount(); ++i) {
911 Definition* def = mat->InputAt(i)->definition(); 911 Definition* def = mat->InputAt(i)->definition();
912 912
913 ConstantInstr* constant = def->AsConstant(); 913 ConstantInstr* constant = def->AsConstant();
914 if (constant != NULL) { 914 if (constant != NULL) {
915 locations[i] = Location::Constant(constant->value()); 915 locations[i] = Location::Constant(constant);
916 continue; 916 continue;
917 } 917 }
918 918
919 if (def->HasPairRepresentation()) { 919 if (def->HasPairRepresentation()) {
920 locations[i] = Location::Pair(Location::Any(), Location::Any()); 920 locations[i] = Location::Pair(Location::Any(), Location::Any());
921 PairLocation* location_pair = locations[i].AsPairLocation(); 921 PairLocation* location_pair = locations[i].AsPairLocation();
922 { 922 {
923 // First live range. 923 // First live range.
924 LiveRange* range = GetLiveRange(def->ssa_temp_index()); 924 LiveRange* range = GetLiveRange(def->ssa_temp_index());
925 range->AddUseInterval(block_start_pos, use_pos); 925 range->AddUseInterval(block_start_pos, use_pos);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 if ((range == NULL) || (range->first_use() == NULL)) { 1143 if ((range == NULL) || (range->first_use() == NULL)) {
1144 locs->set_out(0, Location::NoLocation()); 1144 locs->set_out(0, Location::NoLocation());
1145 return; 1145 return;
1146 } 1146 }
1147 1147
1148 // If this constant has only unconstrained uses convert them all 1148 // If this constant has only unconstrained uses convert them all
1149 // to use the constant directly and drop this definition. 1149 // to use the constant directly and drop this definition.
1150 // TODO(vegorov): improve allocation when we have enough registers to keep 1150 // TODO(vegorov): improve allocation when we have enough registers to keep
1151 // constants used in the loop in them. 1151 // constants used in the loop in them.
1152 if (HasOnlyUnconstrainedUses(range)) { 1152 if (HasOnlyUnconstrainedUses(range)) {
1153 const Object& value = def->AsConstant()->value(); 1153 ConstantInstr* constant_instr = def->AsConstant();
1154 range->set_assigned_location(Location::Constant(value)); 1154 range->set_assigned_location(Location::Constant(constant_instr));
1155 range->set_spill_slot(Location::Constant(value)); 1155 range->set_spill_slot(Location::Constant(constant_instr));
1156 range->finger()->Initialize(range); 1156 range->finger()->Initialize(range);
1157 ConvertAllUses(range); 1157 ConvertAllUses(range);
1158 1158
1159 locs->set_out(0, Location::NoLocation()); 1159 locs->set_out(0, Location::NoLocation());
1160 return; 1160 return;
1161 } 1161 }
1162 } 1162 }
1163 1163
1164 const intptr_t pos = current->lifetime_position(); 1164 const intptr_t pos = current->lifetime_position();
1165 ASSERT(IsInstructionStartPosition(pos)); 1165 ASSERT(IsInstructionStartPosition(pos));
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", 2917 OS::Print("-- [after ssa allocator] ir [%s] -------------\n",
2918 function.ToFullyQualifiedCString()); 2918 function.ToFullyQualifiedCString());
2919 FlowGraphPrinter printer(flow_graph_, true); 2919 FlowGraphPrinter printer(flow_graph_, true);
2920 printer.PrintBlocks(); 2920 printer.PrintBlocks();
2921 OS::Print("----------------------------------------------\n"); 2921 OS::Print("----------------------------------------------\n");
2922 } 2922 }
2923 } 2923 }
2924 2924
2925 2925
2926 } // namespace dart 2926 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698