OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 environment->ClearHistory(); | 150 environment->ClearHistory(); |
151 return instr; | 151 return instr; |
152 } | 152 } |
153 | 153 |
154 | 154 |
155 void HBasicBlock::Finish(HControlInstruction* end) { | 155 void HBasicBlock::Finish(HControlInstruction* end) { |
156 ASSERT(!IsFinished()); | 156 ASSERT(!IsFinished()); |
157 AddInstruction(end); | 157 AddInstruction(end); |
158 end_ = end; | 158 end_ = end; |
159 if (end->FirstSuccessor() != NULL) { | 159 for (HSuccessorIterator it(end); it.HasNext(); it.Advance()) { |
160 end->FirstSuccessor()->RegisterPredecessor(this); | 160 it.Next()->RegisterPredecessor(this); |
161 if (end->SecondSuccessor() != NULL) { | |
162 end->SecondSuccessor()->RegisterPredecessor(this); | |
163 } | |
164 } | 161 } |
165 } | 162 } |
166 | 163 |
167 | 164 |
168 void HBasicBlock::Goto(HBasicBlock* block, bool include_stack_check) { | 165 void HBasicBlock::Goto(HBasicBlock* block, bool include_stack_check) { |
169 if (block->IsInlineReturnTarget()) { | 166 if (block->IsInlineReturnTarget()) { |
170 AddInstruction(new(zone()) HLeaveInlined); | 167 AddInstruction(new(zone()) HLeaveInlined); |
171 last_environment_ = last_environment()->outer(); | 168 last_environment_ = last_environment()->outer(); |
172 } | 169 } |
173 AddSimulate(AstNode::kNoNumber); | 170 AddSimulate(AstNode::kNoNumber); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 !reachable_.Contains(block->block_id())) { | 390 !reachable_.Contains(block->block_id())) { |
394 reachable_.Add(block->block_id()); | 391 reachable_.Add(block->block_id()); |
395 stack_.Add(block); | 392 stack_.Add(block); |
396 visited_count_++; | 393 visited_count_++; |
397 } | 394 } |
398 } | 395 } |
399 | 396 |
400 void Analyze() { | 397 void Analyze() { |
401 while (!stack_.is_empty()) { | 398 while (!stack_.is_empty()) { |
402 HControlInstruction* end = stack_.RemoveLast()->end(); | 399 HControlInstruction* end = stack_.RemoveLast()->end(); |
403 PushBlock(end->FirstSuccessor()); | 400 for (HSuccessorIterator it(end); it.HasNext(); it.Advance()) { |
404 PushBlock(end->SecondSuccessor()); | 401 PushBlock(it.Next()); |
| 402 } |
405 } | 403 } |
406 } | 404 } |
407 | 405 |
408 int visited_count_; | 406 int visited_count_; |
409 ZoneList<HBasicBlock*> stack_; | 407 ZoneList<HBasicBlock*> stack_; |
410 BitVector reachable_; | 408 BitVector reachable_; |
411 HBasicBlock* dont_visit_; | 409 HBasicBlock* dont_visit_; |
412 }; | 410 }; |
413 | 411 |
414 | 412 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 687 } |
690 } | 688 } |
691 | 689 |
692 | 690 |
693 void HGraph::PostorderLoopBlocks(HLoopInformation* loop, | 691 void HGraph::PostorderLoopBlocks(HLoopInformation* loop, |
694 BitVector* visited, | 692 BitVector* visited, |
695 ZoneList<HBasicBlock*>* order, | 693 ZoneList<HBasicBlock*>* order, |
696 HBasicBlock* loop_header) { | 694 HBasicBlock* loop_header) { |
697 for (int i = 0; i < loop->blocks()->length(); ++i) { | 695 for (int i = 0; i < loop->blocks()->length(); ++i) { |
698 HBasicBlock* b = loop->blocks()->at(i); | 696 HBasicBlock* b = loop->blocks()->at(i); |
699 Postorder(b->end()->SecondSuccessor(), visited, order, loop_header); | 697 for (HSuccessorIterator it(b->end()); it.HasNext(); it.Advance()) { |
700 Postorder(b->end()->FirstSuccessor(), visited, order, loop_header); | 698 Postorder(it.Next(), visited, order, loop_header); |
| 699 } |
701 if (b->IsLoopHeader() && b != loop->loop_header()) { | 700 if (b->IsLoopHeader() && b != loop->loop_header()) { |
702 PostorderLoopBlocks(b->loop_information(), visited, order, loop_header); | 701 PostorderLoopBlocks(b->loop_information(), visited, order, loop_header); |
703 } | 702 } |
704 } | 703 } |
705 } | 704 } |
706 | 705 |
707 | 706 |
708 void HGraph::Postorder(HBasicBlock* block, | 707 void HGraph::Postorder(HBasicBlock* block, |
709 BitVector* visited, | 708 BitVector* visited, |
710 ZoneList<HBasicBlock*>* order, | 709 ZoneList<HBasicBlock*>* order, |
711 HBasicBlock* loop_header) { | 710 HBasicBlock* loop_header) { |
712 if (block == NULL || visited->Contains(block->block_id())) return; | 711 if (block == NULL || visited->Contains(block->block_id())) return; |
713 if (block->parent_loop_header() != loop_header) return; | 712 if (block->parent_loop_header() != loop_header) return; |
714 visited->Add(block->block_id()); | 713 visited->Add(block->block_id()); |
715 if (block->IsLoopHeader()) { | 714 if (block->IsLoopHeader()) { |
716 PostorderLoopBlocks(block->loop_information(), visited, order, loop_header); | 715 PostorderLoopBlocks(block->loop_information(), visited, order, loop_header); |
717 Postorder(block->end()->SecondSuccessor(), visited, order, block); | 716 for (HSuccessorIterator it(block->end()); it.HasNext(); it.Advance()) { |
718 Postorder(block->end()->FirstSuccessor(), visited, order, block); | 717 Postorder(it.Next(), visited, order, block); |
| 718 } |
719 } else { | 719 } else { |
720 Postorder(block->end()->SecondSuccessor(), visited, order, loop_header); | 720 for (HSuccessorIterator it(block->end()); it.HasNext(); it.Advance()) { |
721 Postorder(block->end()->FirstSuccessor(), visited, order, loop_header); | 721 Postorder(it.Next(), visited, order, loop_header); |
| 722 } |
722 } | 723 } |
723 ASSERT(block->end()->FirstSuccessor() == NULL || | 724 ASSERT(block->end()->FirstSuccessor() == NULL || |
724 order->Contains(block->end()->FirstSuccessor()) || | 725 order->Contains(block->end()->FirstSuccessor()) || |
725 block->end()->FirstSuccessor()->IsLoopHeader()); | 726 block->end()->FirstSuccessor()->IsLoopHeader()); |
726 ASSERT(block->end()->SecondSuccessor() == NULL || | 727 ASSERT(block->end()->SecondSuccessor() == NULL || |
727 order->Contains(block->end()->SecondSuccessor()) || | 728 order->Contains(block->end()->SecondSuccessor()) || |
728 block->end()->SecondSuccessor()->IsLoopHeader()); | 729 block->end()->SecondSuccessor()->IsLoopHeader()); |
729 order->Add(block); | 730 order->Add(block); |
730 } | 731 } |
731 | 732 |
(...skipping 5347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6079 PrintIndent(); | 6080 PrintIndent(); |
6080 trace_.Add("predecessors"); | 6081 trace_.Add("predecessors"); |
6081 for (int j = 0; j < current->predecessors()->length(); ++j) { | 6082 for (int j = 0; j < current->predecessors()->length(); ++j) { |
6082 trace_.Add(" \"B%d\"", current->predecessors()->at(j)->block_id()); | 6083 trace_.Add(" \"B%d\"", current->predecessors()->at(j)->block_id()); |
6083 } | 6084 } |
6084 trace_.Add("\n"); | 6085 trace_.Add("\n"); |
6085 } else { | 6086 } else { |
6086 PrintEmptyProperty("predecessors"); | 6087 PrintEmptyProperty("predecessors"); |
6087 } | 6088 } |
6088 | 6089 |
6089 if (current->end() == NULL || current->end()->FirstSuccessor() == NULL) { | 6090 if (current->end()->SuccessorCount() == 0) { |
6090 PrintEmptyProperty("successors"); | 6091 PrintEmptyProperty("successors"); |
6091 } else if (current->end()->SecondSuccessor() == NULL) { | 6092 } else { |
6092 PrintBlockProperty("successors", | 6093 PrintIndent(); |
6093 current->end()->FirstSuccessor()->block_id()); | 6094 trace_.Add("successors"); |
6094 } else { | 6095 for (HSuccessorIterator it(current->end()); it.HasNext(); it.Advance()) { |
6095 PrintBlockProperty("successors", | 6096 trace_.Add(" \"B%d\"", it.Next()->block_id()); |
6096 current->end()->FirstSuccessor()->block_id(), | 6097 } |
6097 current->end()->SecondSuccessor()->block_id()); | 6098 trace_.Add("\n"); |
6098 } | 6099 } |
6099 | 6100 |
6100 PrintEmptyProperty("xhandlers"); | 6101 PrintEmptyProperty("xhandlers"); |
6101 PrintEmptyProperty("flags"); | 6102 PrintEmptyProperty("flags"); |
6102 | 6103 |
6103 if (current->dominator() != NULL) { | 6104 if (current->dominator() != NULL) { |
6104 PrintBlockProperty("dominator", current->dominator()->block_id()); | 6105 PrintBlockProperty("dominator", current->dominator()->block_id()); |
6105 } | 6106 } |
6106 | 6107 |
6107 if (chunk != NULL) { | 6108 if (chunk != NULL) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6347 } | 6348 } |
6348 } | 6349 } |
6349 | 6350 |
6350 #ifdef DEBUG | 6351 #ifdef DEBUG |
6351 if (graph_ != NULL) graph_->Verify(); | 6352 if (graph_ != NULL) graph_->Verify(); |
6352 if (allocator_ != NULL) allocator_->Verify(); | 6353 if (allocator_ != NULL) allocator_->Verify(); |
6353 #endif | 6354 #endif |
6354 } | 6355 } |
6355 | 6356 |
6356 } } // namespace v8::internal | 6357 } } // namespace v8::internal |
OLD | NEW |