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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 environment->ClearHistory(); | 151 environment->ClearHistory(); |
152 return instr; | 152 return instr; |
153 } | 153 } |
154 | 154 |
155 | 155 |
156 void HBasicBlock::Finish(HControlInstruction* end) { | 156 void HBasicBlock::Finish(HControlInstruction* end) { |
157 ASSERT(!IsFinished()); | 157 ASSERT(!IsFinished()); |
158 AddInstruction(end); | 158 AddInstruction(end); |
159 end_ = end; | 159 end_ = end; |
160 if (end->FirstSuccessor() != NULL) { | 160 for (HSuccessorIterator it(end); it.HasNext(); it.Advance()) { |
161 end->FirstSuccessor()->RegisterPredecessor(this); | 161 it.Next()->RegisterPredecessor(this); |
162 if (end->SecondSuccessor() != NULL) { | |
163 end->SecondSuccessor()->RegisterPredecessor(this); | |
164 } | |
165 } | 162 } |
166 } | 163 } |
167 | 164 |
168 | 165 |
169 void HBasicBlock::Goto(HBasicBlock* block, bool include_stack_check) { | 166 void HBasicBlock::Goto(HBasicBlock* block, bool include_stack_check) { |
170 if (block->IsInlineReturnTarget()) { | 167 if (block->IsInlineReturnTarget()) { |
171 AddInstruction(new(zone()) HLeaveInlined); | 168 AddInstruction(new(zone()) HLeaveInlined); |
172 last_environment_ = last_environment()->outer(); | 169 last_environment_ = last_environment()->outer(); |
173 } | 170 } |
174 AddSimulate(AstNode::kNoNumber); | 171 AddSimulate(AstNode::kNoNumber); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 !reachable_.Contains(block->block_id())) { | 391 !reachable_.Contains(block->block_id())) { |
395 reachable_.Add(block->block_id()); | 392 reachable_.Add(block->block_id()); |
396 stack_.Add(block); | 393 stack_.Add(block); |
397 visited_count_++; | 394 visited_count_++; |
398 } | 395 } |
399 } | 396 } |
400 | 397 |
401 void Analyze() { | 398 void Analyze() { |
402 while (!stack_.is_empty()) { | 399 while (!stack_.is_empty()) { |
403 HControlInstruction* end = stack_.RemoveLast()->end(); | 400 HControlInstruction* end = stack_.RemoveLast()->end(); |
404 PushBlock(end->FirstSuccessor()); | 401 for (HSuccessorIterator it(end); it.HasNext(); it.Advance()) { |
405 PushBlock(end->SecondSuccessor()); | 402 PushBlock(it.Next()); |
| 403 } |
406 } | 404 } |
407 } | 405 } |
408 | 406 |
409 int visited_count_; | 407 int visited_count_; |
410 ZoneList<HBasicBlock*> stack_; | 408 ZoneList<HBasicBlock*> stack_; |
411 BitVector reachable_; | 409 BitVector reachable_; |
412 HBasicBlock* dont_visit_; | 410 HBasicBlock* dont_visit_; |
413 }; | 411 }; |
414 | 412 |
415 | 413 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 } | 682 } |
685 } | 683 } |
686 | 684 |
687 | 685 |
688 void HGraph::PostorderLoopBlocks(HLoopInformation* loop, | 686 void HGraph::PostorderLoopBlocks(HLoopInformation* loop, |
689 BitVector* visited, | 687 BitVector* visited, |
690 ZoneList<HBasicBlock*>* order, | 688 ZoneList<HBasicBlock*>* order, |
691 HBasicBlock* loop_header) { | 689 HBasicBlock* loop_header) { |
692 for (int i = 0; i < loop->blocks()->length(); ++i) { | 690 for (int i = 0; i < loop->blocks()->length(); ++i) { |
693 HBasicBlock* b = loop->blocks()->at(i); | 691 HBasicBlock* b = loop->blocks()->at(i); |
694 Postorder(b->end()->SecondSuccessor(), visited, order, loop_header); | 692 for (HSuccessorIterator it(b->end()); it.HasNext(); it.Advance()) { |
695 Postorder(b->end()->FirstSuccessor(), visited, order, loop_header); | 693 Postorder(it.Next(), visited, order, loop_header); |
| 694 } |
696 if (b->IsLoopHeader() && b != loop->loop_header()) { | 695 if (b->IsLoopHeader() && b != loop->loop_header()) { |
697 PostorderLoopBlocks(b->loop_information(), visited, order, loop_header); | 696 PostorderLoopBlocks(b->loop_information(), visited, order, loop_header); |
698 } | 697 } |
699 } | 698 } |
700 } | 699 } |
701 | 700 |
702 | 701 |
703 void HGraph::Postorder(HBasicBlock* block, | 702 void HGraph::Postorder(HBasicBlock* block, |
704 BitVector* visited, | 703 BitVector* visited, |
705 ZoneList<HBasicBlock*>* order, | 704 ZoneList<HBasicBlock*>* order, |
706 HBasicBlock* loop_header) { | 705 HBasicBlock* loop_header) { |
707 if (block == NULL || visited->Contains(block->block_id())) return; | 706 if (block == NULL || visited->Contains(block->block_id())) return; |
708 if (block->parent_loop_header() != loop_header) return; | 707 if (block->parent_loop_header() != loop_header) return; |
709 visited->Add(block->block_id()); | 708 visited->Add(block->block_id()); |
710 if (block->IsLoopHeader()) { | 709 if (block->IsLoopHeader()) { |
711 PostorderLoopBlocks(block->loop_information(), visited, order, loop_header); | 710 PostorderLoopBlocks(block->loop_information(), visited, order, loop_header); |
712 Postorder(block->end()->SecondSuccessor(), visited, order, block); | 711 for (HSuccessorIterator it(block->end()); it.HasNext(); it.Advance()) { |
713 Postorder(block->end()->FirstSuccessor(), visited, order, block); | 712 Postorder(it.Next(), visited, order, block); |
| 713 } |
714 } else { | 714 } else { |
715 Postorder(block->end()->SecondSuccessor(), visited, order, loop_header); | 715 for (HSuccessorIterator it(block->end()); it.HasNext(); it.Advance()) { |
716 Postorder(block->end()->FirstSuccessor(), visited, order, loop_header); | 716 Postorder(it.Next(), visited, order, loop_header); |
| 717 } |
717 } | 718 } |
718 ASSERT(block->end()->FirstSuccessor() == NULL || | 719 ASSERT(block->end()->FirstSuccessor() == NULL || |
719 order->Contains(block->end()->FirstSuccessor()) || | 720 order->Contains(block->end()->FirstSuccessor()) || |
720 block->end()->FirstSuccessor()->IsLoopHeader()); | 721 block->end()->FirstSuccessor()->IsLoopHeader()); |
721 ASSERT(block->end()->SecondSuccessor() == NULL || | 722 ASSERT(block->end()->SecondSuccessor() == NULL || |
722 order->Contains(block->end()->SecondSuccessor()) || | 723 order->Contains(block->end()->SecondSuccessor()) || |
723 block->end()->SecondSuccessor()->IsLoopHeader()); | 724 block->end()->SecondSuccessor()->IsLoopHeader()); |
724 order->Add(block); | 725 order->Add(block); |
725 } | 726 } |
726 | 727 |
(...skipping 5235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5962 PrintIndent(); | 5963 PrintIndent(); |
5963 trace_.Add("predecessors"); | 5964 trace_.Add("predecessors"); |
5964 for (int j = 0; j < current->predecessors()->length(); ++j) { | 5965 for (int j = 0; j < current->predecessors()->length(); ++j) { |
5965 trace_.Add(" \"B%d\"", current->predecessors()->at(j)->block_id()); | 5966 trace_.Add(" \"B%d\"", current->predecessors()->at(j)->block_id()); |
5966 } | 5967 } |
5967 trace_.Add("\n"); | 5968 trace_.Add("\n"); |
5968 } else { | 5969 } else { |
5969 PrintEmptyProperty("predecessors"); | 5970 PrintEmptyProperty("predecessors"); |
5970 } | 5971 } |
5971 | 5972 |
5972 if (current->end() == NULL || current->end()->FirstSuccessor() == NULL) { | 5973 if (current->end()->SuccessorCount() == 0) { |
5973 PrintEmptyProperty("successors"); | 5974 PrintEmptyProperty("successors"); |
5974 } else if (current->end()->SecondSuccessor() == NULL) { | 5975 } else { |
5975 PrintBlockProperty("successors", | 5976 PrintIndent(); |
5976 current->end()->FirstSuccessor()->block_id()); | 5977 trace_.Add("successors"); |
5977 } else { | 5978 for (HSuccessorIterator it(current->end()); it.HasNext(); it.Advance()) { |
5978 PrintBlockProperty("successors", | 5979 trace_.Add(" \"B%d\"", it.Next()->block_id()); |
5979 current->end()->FirstSuccessor()->block_id(), | 5980 } |
5980 current->end()->SecondSuccessor()->block_id()); | 5981 trace_.Add("\n"); |
5981 } | 5982 } |
5982 | 5983 |
5983 PrintEmptyProperty("xhandlers"); | 5984 PrintEmptyProperty("xhandlers"); |
5984 PrintEmptyProperty("flags"); | 5985 PrintEmptyProperty("flags"); |
5985 | 5986 |
5986 if (current->dominator() != NULL) { | 5987 if (current->dominator() != NULL) { |
5987 PrintBlockProperty("dominator", current->dominator()->block_id()); | 5988 PrintBlockProperty("dominator", current->dominator()->block_id()); |
5988 } | 5989 } |
5989 | 5990 |
5990 if (chunk != NULL) { | 5991 if (chunk != NULL) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6230 } | 6231 } |
6231 } | 6232 } |
6232 | 6233 |
6233 #ifdef DEBUG | 6234 #ifdef DEBUG |
6234 if (graph_ != NULL) graph_->Verify(); | 6235 if (graph_ != NULL) graph_->Verify(); |
6235 if (allocator_ != NULL) allocator_->Verify(); | 6236 if (allocator_ != NULL) allocator_->Verify(); |
6236 #endif | 6237 #endif |
6237 } | 6238 } |
6238 | 6239 |
6239 } } // namespace v8::internal | 6240 } } // namespace v8::internal |
OLD | NEW |