| OLD | NEW |
| 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 use = use->next(); | 511 use = use->next(); |
| 512 } | 512 } |
| 513 return true; | 513 return true; |
| 514 } | 514 } |
| 515 | 515 |
| 516 | 516 |
| 517 void FlowGraphAllocator::BuildLiveRanges() { | 517 void FlowGraphAllocator::BuildLiveRanges() { |
| 518 const intptr_t block_count = postorder_.length(); | 518 const intptr_t block_count = postorder_.length(); |
| 519 ASSERT(postorder_.Last()->IsGraphEntry()); | 519 ASSERT(postorder_.Last()->IsGraphEntry()); |
| 520 BitVector* current_interference_set = NULL; | 520 BitVector* current_interference_set = NULL; |
| 521 Isolate* isolate = flow_graph_.isolate(); |
| 521 for (intptr_t i = 0; i < (block_count - 1); i++) { | 522 for (intptr_t i = 0; i < (block_count - 1); i++) { |
| 522 BlockEntryInstr* block = postorder_[i]; | 523 BlockEntryInstr* block = postorder_[i]; |
| 523 | 524 |
| 524 BlockInfo* block_info = BlockInfoAt(block->start_pos()); | 525 BlockInfo* block_info = BlockInfoAt(block->start_pos()); |
| 525 | 526 |
| 526 // For every SSA value that is live out of this block, create an interval | 527 // For every SSA value that is live out of this block, create an interval |
| 527 // that covers the whole block. It will be shortened if we encounter a | 528 // that covers the whole block. It will be shortened if we encounter a |
| 528 // definition of this value in this block. | 529 // definition of this value in this block. |
| 529 for (BitVector::Iterator it(liveness_.GetLiveOutSetAt(i)); | 530 for (BitVector::Iterator it(liveness_.GetLiveOutSetAt(i)); |
| 530 !it.Done(); | 531 !it.Done(); |
| 531 it.Advance()) { | 532 it.Advance()) { |
| 532 LiveRange* range = GetLiveRange(it.Current()); | 533 LiveRange* range = GetLiveRange(it.Current()); |
| 533 range->AddUseInterval(block->start_pos(), block->end_pos()); | 534 range->AddUseInterval(block->start_pos(), block->end_pos()); |
| 534 } | 535 } |
| 535 | 536 |
| 536 BlockInfo* loop_header = block_info->loop_header(); | 537 BlockInfo* loop_header = block_info->loop_header(); |
| 537 if ((loop_header != NULL) && (loop_header->last_block() == block)) { | 538 if ((loop_header != NULL) && (loop_header->last_block() == block)) { |
| 538 current_interference_set = | 539 current_interference_set = new(isolate) BitVector( |
| 539 new BitVector(flow_graph_.max_virtual_register_number()); | 540 isolate, flow_graph_.max_virtual_register_number()); |
| 540 ASSERT(loop_header->backedge_interference() == NULL); | 541 ASSERT(loop_header->backedge_interference() == NULL); |
| 541 // All values flowing into the loop header are live at the back-edge and | 542 // All values flowing into the loop header are live at the back-edge and |
| 542 // can interfere with phi moves. | 543 // can interfere with phi moves. |
| 543 current_interference_set->AddAll( | 544 current_interference_set->AddAll( |
| 544 liveness_.GetLiveInSet(loop_header->entry())); | 545 liveness_.GetLiveInSet(loop_header->entry())); |
| 545 loop_header->set_backedge_interference( | 546 loop_header->set_backedge_interference( |
| 546 current_interference_set); | 547 current_interference_set); |
| 547 } | 548 } |
| 548 | 549 |
| 549 // Connect outgoing phi-moves that were created in NumberInstructions | 550 // Connect outgoing phi-moves that were created in NumberInstructions |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1998 allocated_head); | 1999 allocated_head); |
| 1999 if (pos < intersection) intersection = pos; | 2000 if (pos < intersection) intersection = pos; |
| 2000 } | 2001 } |
| 2001 return intersection; | 2002 return intersection; |
| 2002 } | 2003 } |
| 2003 | 2004 |
| 2004 | 2005 |
| 2005 void ReachingDefs::AddPhi(PhiInstr* phi) { | 2006 void ReachingDefs::AddPhi(PhiInstr* phi) { |
| 2006 // TODO(johnmccutchan): Fix handling of PhiInstr with PairLocation. | 2007 // TODO(johnmccutchan): Fix handling of PhiInstr with PairLocation. |
| 2007 if (phi->reaching_defs() == NULL) { | 2008 if (phi->reaching_defs() == NULL) { |
| 2008 phi->set_reaching_defs( | 2009 Isolate* isolate = Isolate::Current(); |
| 2009 new BitVector(flow_graph_.max_virtual_register_number())); | 2010 phi->set_reaching_defs(new(isolate) BitVector( |
| 2011 isolate, flow_graph_.max_virtual_register_number())); |
| 2010 | 2012 |
| 2011 // Compute initial set reaching defs set. | 2013 // Compute initial set reaching defs set. |
| 2012 bool depends_on_phi = false; | 2014 bool depends_on_phi = false; |
| 2013 for (intptr_t i = 0; i < phi->InputCount(); i++) { | 2015 for (intptr_t i = 0; i < phi->InputCount(); i++) { |
| 2014 Definition* input = phi->InputAt(i)->definition(); | 2016 Definition* input = phi->InputAt(i)->definition(); |
| 2015 if (input->IsPhi()) { | 2017 if (input->IsPhi()) { |
| 2016 depends_on_phi = true; | 2018 depends_on_phi = true; |
| 2017 } | 2019 } |
| 2018 phi->reaching_defs()->Add(input->ssa_temp_index()); | 2020 phi->reaching_defs()->Add(input->ssa_temp_index()); |
| 2019 } | 2021 } |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2943 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", | 2945 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", |
| 2944 function.ToFullyQualifiedCString()); | 2946 function.ToFullyQualifiedCString()); |
| 2945 FlowGraphPrinter printer(flow_graph_, true); | 2947 FlowGraphPrinter printer(flow_graph_, true); |
| 2946 printer.PrintBlocks(); | 2948 printer.PrintBlocks(); |
| 2947 OS::Print("----------------------------------------------\n"); | 2949 OS::Print("----------------------------------------------\n"); |
| 2948 } | 2950 } |
| 2949 } | 2951 } |
| 2950 | 2952 |
| 2951 | 2953 |
| 2952 } // namespace dart | 2954 } // namespace dart |
| OLD | NEW |