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

Side by Side Diff: src/hydrogen.cc

Issue 7114004: Add support for hydrogen control instructions with >2 successor blocks. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: addressed comments and fixed ARM build Created 9 years, 6 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 | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('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 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
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.Done(); it.Advance()) {
161 end->FirstSuccessor()->RegisterPredecessor(this); 161 it.Current()->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
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.Done(); it.Advance()) {
405 PushBlock(end->SecondSuccessor()); 402 PushBlock(it.Current());
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 688 }
691 } 689 }
692 690
693 691
694 void HGraph::PostorderLoopBlocks(HLoopInformation* loop, 692 void HGraph::PostorderLoopBlocks(HLoopInformation* loop,
695 BitVector* visited, 693 BitVector* visited,
696 ZoneList<HBasicBlock*>* order, 694 ZoneList<HBasicBlock*>* order,
697 HBasicBlock* loop_header) { 695 HBasicBlock* loop_header) {
698 for (int i = 0; i < loop->blocks()->length(); ++i) { 696 for (int i = 0; i < loop->blocks()->length(); ++i) {
699 HBasicBlock* b = loop->blocks()->at(i); 697 HBasicBlock* b = loop->blocks()->at(i);
700 Postorder(b->end()->SecondSuccessor(), visited, order, loop_header); 698 for (HSuccessorIterator it(b->end()); !it.Done(); it.Advance()) {
701 Postorder(b->end()->FirstSuccessor(), visited, order, loop_header); 699 Postorder(it.Current(), visited, order, loop_header);
700 }
702 if (b->IsLoopHeader() && b != loop->loop_header()) { 701 if (b->IsLoopHeader() && b != loop->loop_header()) {
703 PostorderLoopBlocks(b->loop_information(), visited, order, loop_header); 702 PostorderLoopBlocks(b->loop_information(), visited, order, loop_header);
704 } 703 }
705 } 704 }
706 } 705 }
707 706
708 707
709 void HGraph::Postorder(HBasicBlock* block, 708 void HGraph::Postorder(HBasicBlock* block,
710 BitVector* visited, 709 BitVector* visited,
711 ZoneList<HBasicBlock*>* order, 710 ZoneList<HBasicBlock*>* order,
712 HBasicBlock* loop_header) { 711 HBasicBlock* loop_header) {
713 if (block == NULL || visited->Contains(block->block_id())) return; 712 if (block == NULL || visited->Contains(block->block_id())) return;
714 if (block->parent_loop_header() != loop_header) return; 713 if (block->parent_loop_header() != loop_header) return;
715 visited->Add(block->block_id()); 714 visited->Add(block->block_id());
716 if (block->IsLoopHeader()) { 715 if (block->IsLoopHeader()) {
717 PostorderLoopBlocks(block->loop_information(), visited, order, loop_header); 716 PostorderLoopBlocks(block->loop_information(), visited, order, loop_header);
718 Postorder(block->end()->SecondSuccessor(), visited, order, block); 717 for (HSuccessorIterator it(block->end()); !it.Done(); it.Advance()) {
719 Postorder(block->end()->FirstSuccessor(), visited, order, block); 718 Postorder(it.Current(), visited, order, block);
719 }
720 } else { 720 } else {
721 Postorder(block->end()->SecondSuccessor(), visited, order, loop_header); 721 for (HSuccessorIterator it(block->end()); !it.Done(); it.Advance()) {
722 Postorder(block->end()->FirstSuccessor(), visited, order, loop_header); 722 Postorder(it.Current(), visited, order, loop_header);
723 }
723 } 724 }
724 ASSERT(block->end()->FirstSuccessor() == NULL || 725 ASSERT(block->end()->FirstSuccessor() == NULL ||
725 order->Contains(block->end()->FirstSuccessor()) || 726 order->Contains(block->end()->FirstSuccessor()) ||
726 block->end()->FirstSuccessor()->IsLoopHeader()); 727 block->end()->FirstSuccessor()->IsLoopHeader());
727 ASSERT(block->end()->SecondSuccessor() == NULL || 728 ASSERT(block->end()->SecondSuccessor() == NULL ||
728 order->Contains(block->end()->SecondSuccessor()) || 729 order->Contains(block->end()->SecondSuccessor()) ||
729 block->end()->SecondSuccessor()->IsLoopHeader()); 730 block->end()->SecondSuccessor()->IsLoopHeader());
730 order->Add(block); 731 order->Add(block);
731 } 732 }
732 733
(...skipping 5399 matching lines...) Expand 10 before | Expand all | Expand 10 after
6132 PrintIndent(); 6133 PrintIndent();
6133 trace_.Add("predecessors"); 6134 trace_.Add("predecessors");
6134 for (int j = 0; j < current->predecessors()->length(); ++j) { 6135 for (int j = 0; j < current->predecessors()->length(); ++j) {
6135 trace_.Add(" \"B%d\"", current->predecessors()->at(j)->block_id()); 6136 trace_.Add(" \"B%d\"", current->predecessors()->at(j)->block_id());
6136 } 6137 }
6137 trace_.Add("\n"); 6138 trace_.Add("\n");
6138 } else { 6139 } else {
6139 PrintEmptyProperty("predecessors"); 6140 PrintEmptyProperty("predecessors");
6140 } 6141 }
6141 6142
6142 if (current->end() == NULL || current->end()->FirstSuccessor() == NULL) { 6143 if (current->end()->SuccessorCount() == 0) {
6143 PrintEmptyProperty("successors"); 6144 PrintEmptyProperty("successors");
6144 } else if (current->end()->SecondSuccessor() == NULL) { 6145 } else {
6145 PrintBlockProperty("successors", 6146 PrintIndent();
6146 current->end()->FirstSuccessor()->block_id()); 6147 trace_.Add("successors");
6147 } else { 6148 for (HSuccessorIterator it(current->end()); !it.Done(); it.Advance()) {
6148 PrintBlockProperty("successors", 6149 trace_.Add(" \"B%d\"", it.Current()->block_id());
6149 current->end()->FirstSuccessor()->block_id(), 6150 }
6150 current->end()->SecondSuccessor()->block_id()); 6151 trace_.Add("\n");
6151 } 6152 }
6152 6153
6153 PrintEmptyProperty("xhandlers"); 6154 PrintEmptyProperty("xhandlers");
6154 PrintEmptyProperty("flags"); 6155 PrintEmptyProperty("flags");
6155 6156
6156 if (current->dominator() != NULL) { 6157 if (current->dominator() != NULL) {
6157 PrintBlockProperty("dominator", current->dominator()->block_id()); 6158 PrintBlockProperty("dominator", current->dominator()->block_id());
6158 } 6159 }
6159 6160
6160 if (chunk != NULL) { 6161 if (chunk != NULL) {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
6400 } 6401 }
6401 } 6402 }
6402 6403
6403 #ifdef DEBUG 6404 #ifdef DEBUG
6404 if (graph_ != NULL) graph_->Verify(); 6405 if (graph_ != NULL) graph_->Verify();
6405 if (allocator_ != NULL) allocator_->Verify(); 6406 if (allocator_ != NULL) allocator_->Verify();
6406 #endif 6407 #endif
6407 } 6408 }
6408 6409
6409 } } // namespace v8::internal 6410 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698