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

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

Issue 868913002: Add Zone-based handle allocation interface and reduce use of Isolate-based interfaces. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 use = use->next(); 533 use = use->next();
534 } 534 }
535 return true; 535 return true;
536 } 536 }
537 537
538 538
539 void FlowGraphAllocator::BuildLiveRanges() { 539 void FlowGraphAllocator::BuildLiveRanges() {
540 const intptr_t block_count = postorder_.length(); 540 const intptr_t block_count = postorder_.length();
541 ASSERT(postorder_.Last()->IsGraphEntry()); 541 ASSERT(postorder_.Last()->IsGraphEntry());
542 BitVector* current_interference_set = NULL; 542 BitVector* current_interference_set = NULL;
543 Isolate* isolate = flow_graph_.isolate(); 543 Zone* zone = flow_graph_.zone();
544 for (intptr_t i = 0; i < (block_count - 1); i++) { 544 for (intptr_t i = 0; i < (block_count - 1); i++) {
545 BlockEntryInstr* block = postorder_[i]; 545 BlockEntryInstr* block = postorder_[i];
546 546
547 BlockInfo* block_info = BlockInfoAt(block->start_pos()); 547 BlockInfo* block_info = BlockInfoAt(block->start_pos());
548 548
549 // For every SSA value that is live out of this block, create an interval 549 // For every SSA value that is live out of this block, create an interval
550 // that covers the whole block. It will be shortened if we encounter a 550 // that covers the whole block. It will be shortened if we encounter a
551 // definition of this value in this block. 551 // definition of this value in this block.
552 for (BitVector::Iterator it(liveness_.GetLiveOutSetAt(i)); 552 for (BitVector::Iterator it(liveness_.GetLiveOutSetAt(i));
553 !it.Done(); 553 !it.Done();
554 it.Advance()) { 554 it.Advance()) {
555 LiveRange* range = GetLiveRange(it.Current()); 555 LiveRange* range = GetLiveRange(it.Current());
556 range->AddUseInterval(block->start_pos(), block->end_pos()); 556 range->AddUseInterval(block->start_pos(), block->end_pos());
557 } 557 }
558 558
559 BlockInfo* loop_header = block_info->loop_header(); 559 BlockInfo* loop_header = block_info->loop_header();
560 if ((loop_header != NULL) && (loop_header->last_block() == block)) { 560 if ((loop_header != NULL) && (loop_header->last_block() == block)) {
561 current_interference_set = new(isolate) BitVector( 561 current_interference_set = new(zone) BitVector(
562 isolate, flow_graph_.max_virtual_register_number()); 562 zone, flow_graph_.max_virtual_register_number());
563 ASSERT(loop_header->backedge_interference() == NULL); 563 ASSERT(loop_header->backedge_interference() == NULL);
564 // All values flowing into the loop header are live at the back-edge and 564 // All values flowing into the loop header are live at the back-edge and
565 // can interfere with phi moves. 565 // can interfere with phi moves.
566 current_interference_set->AddAll( 566 current_interference_set->AddAll(
567 liveness_.GetLiveInSet(loop_header->entry())); 567 liveness_.GetLiveInSet(loop_header->entry()));
568 loop_header->set_backedge_interference( 568 loop_header->set_backedge_interference(
569 current_interference_set); 569 current_interference_set);
570 } 570 }
571 571
572 // Connect outgoing phi-moves that were created in NumberInstructions 572 // Connect outgoing phi-moves that were created in NumberInstructions
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 // 875 //
876 876
877 if (env->Length() == 0) { 877 if (env->Length() == 0) {
878 env = env->outer(); 878 env = env->outer();
879 continue; 879 continue;
880 } 880 }
881 881
882 const intptr_t block_start_pos = block->start_pos(); 882 const intptr_t block_start_pos = block->start_pos();
883 const intptr_t use_pos = current->lifetime_position() + 1; 883 const intptr_t use_pos = current->lifetime_position() + 1;
884 884
885 Location* locations = 885 Location* locations = flow_graph_.zone()->Alloc<Location>(env->Length());
886 Isolate::Current()->current_zone()->Alloc<Location>(env->Length());
887 886
888 for (intptr_t i = 0; i < env->Length(); ++i) { 887 for (intptr_t i = 0; i < env->Length(); ++i) {
889 Value* value = env->ValueAt(i); 888 Value* value = env->ValueAt(i);
890 Definition* def = value->definition(); 889 Definition* def = value->definition();
891 if (def->HasPairRepresentation()) { 890 if (def->HasPairRepresentation()) {
892 locations[i] = Location::Pair(Location::Any(), Location::Any()); 891 locations[i] = Location::Pair(Location::Any(), Location::Any());
893 } else { 892 } else {
894 locations[i] = Location::Any(); 893 locations[i] = Location::Any();
895 } 894 }
896 895
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 const intptr_t block_start_pos, 948 const intptr_t block_start_pos,
950 const intptr_t use_pos, 949 const intptr_t use_pos,
951 MaterializeObjectInstr* mat) { 950 MaterializeObjectInstr* mat) {
952 // Materialization can occur several times in the same environment. 951 // Materialization can occur several times in the same environment.
953 // Check if we already processed this one. 952 // Check if we already processed this one.
954 if (mat->locations() != NULL) { 953 if (mat->locations() != NULL) {
955 return; // Already processed. 954 return; // Already processed.
956 } 955 }
957 956
958 // Initialize location for every input of the MaterializeObject instruction. 957 // Initialize location for every input of the MaterializeObject instruction.
959 Location* locations = 958 Location* locations = flow_graph_.zone()->Alloc<Location>(mat->InputCount());
960 Isolate::Current()->current_zone()->Alloc<Location>(mat->InputCount());
961 mat->set_locations(locations); 959 mat->set_locations(locations);
962 960
963 for (intptr_t i = 0; i < mat->InputCount(); ++i) { 961 for (intptr_t i = 0; i < mat->InputCount(); ++i) {
964 Definition* def = mat->InputAt(i)->definition(); 962 Definition* def = mat->InputAt(i)->definition();
965 963
966 ConstantInstr* constant = def->AsConstant(); 964 ConstantInstr* constant = def->AsConstant();
967 if (constant != NULL) { 965 if (constant != NULL) {
968 locations[i] = Location::Constant(constant); 966 locations[i] = Location::Constant(constant);
969 continue; 967 continue;
970 } 968 }
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 allocated_head); 2016 allocated_head);
2019 if (pos < intersection) intersection = pos; 2017 if (pos < intersection) intersection = pos;
2020 } 2018 }
2021 return intersection; 2019 return intersection;
2022 } 2020 }
2023 2021
2024 2022
2025 void ReachingDefs::AddPhi(PhiInstr* phi) { 2023 void ReachingDefs::AddPhi(PhiInstr* phi) {
2026 // TODO(johnmccutchan): Fix handling of PhiInstr with PairLocation. 2024 // TODO(johnmccutchan): Fix handling of PhiInstr with PairLocation.
2027 if (phi->reaching_defs() == NULL) { 2025 if (phi->reaching_defs() == NULL) {
2028 Isolate* isolate = Isolate::Current(); 2026 Zone* zone = flow_graph_.zone();
2029 phi->set_reaching_defs(new(isolate) BitVector( 2027 phi->set_reaching_defs(new(zone) BitVector(
2030 isolate, flow_graph_.max_virtual_register_number())); 2028 zone, flow_graph_.max_virtual_register_number()));
2031 2029
2032 // Compute initial set reaching defs set. 2030 // Compute initial set reaching defs set.
2033 bool depends_on_phi = false; 2031 bool depends_on_phi = false;
2034 for (intptr_t i = 0; i < phi->InputCount(); i++) { 2032 for (intptr_t i = 0; i < phi->InputCount(); i++) {
2035 Definition* input = phi->InputAt(i)->definition(); 2033 Definition* input = phi->InputAt(i)->definition();
2036 if (input->IsPhi()) { 2034 if (input->IsPhi()) {
2037 depends_on_phi = true; 2035 depends_on_phi = true;
2038 } 2036 }
2039 phi->reaching_defs()->Add(input->ssa_temp_index()); 2037 phi->reaching_defs()->Add(input->ssa_temp_index());
2040 } 2038 }
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
2972 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", 2970 OS::Print("-- [after ssa allocator] ir [%s] -------------\n",
2973 function.ToFullyQualifiedCString()); 2971 function.ToFullyQualifiedCString());
2974 FlowGraphPrinter printer(flow_graph_, true); 2972 FlowGraphPrinter printer(flow_graph_, true);
2975 printer.PrintBlocks(); 2973 printer.PrintBlocks();
2976 OS::Print("----------------------------------------------\n"); 2974 OS::Print("----------------------------------------------\n");
2977 } 2975 }
2978 } 2976 }
2979 2977
2980 2978
2981 } // namespace dart 2979 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698