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

Side by Side Diff: src/hydrogen.cc

Issue 7514005: slight HGraph::CreateGraph refactor (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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') | no next file » | 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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 order->Contains(block->end()->SecondSuccessor()) || 729 order->Contains(block->end()->SecondSuccessor()) ||
730 block->end()->SecondSuccessor()->IsLoopHeader()); 730 block->end()->SecondSuccessor()->IsLoopHeader());
731 order->Add(block); 731 order->Add(block);
732 } 732 }
733 733
734 734
735 void HGraph::AssignDominators() { 735 void HGraph::AssignDominators() {
736 HPhase phase("Assign dominators", this); 736 HPhase phase("Assign dominators", this);
737 for (int i = 0; i < blocks_.length(); ++i) { 737 for (int i = 0; i < blocks_.length(); ++i) {
738 if (blocks_[i]->IsLoopHeader()) { 738 if (blocks_[i]->IsLoopHeader()) {
739 // Only the first predecessor of a loop header is from outside the loop.
740 // All others are back edges, and thus cannot dominate the loop header.
739 blocks_[i]->AssignCommonDominator(blocks_[i]->predecessors()->first()); 741 blocks_[i]->AssignCommonDominator(blocks_[i]->predecessors()->first());
740 } else { 742 } else {
741 for (int j = 0; j < blocks_[i]->predecessors()->length(); ++j) { 743 for (int j = 0; j < blocks_[i]->predecessors()->length(); ++j) {
742 blocks_[i]->AssignCommonDominator(blocks_[i]->predecessors()->at(j)); 744 blocks_[i]->AssignCommonDominator(blocks_[i]->predecessors()->at(j));
743 } 745 }
744 } 746 }
745 } 747 }
748 }
746 749
747 // Propagate flag marking blocks containing unconditional deoptimize. 750 // Mark all blocks that are dominated by an unconditional soft deoptimize to
751 // prevent code motion across those blocks.
752 void HGraph::PropagateDeoptimizingMark()
753 {
754 HPhase phase("Propagate deoptimizing mark", this);
748 MarkAsDeoptimizingRecursively(entry_block()); 755 MarkAsDeoptimizingRecursively(entry_block());
749 } 756 }
750 757
751
752 // Mark all blocks that are dominated by an unconditional deoptimize.
753 void HGraph::MarkAsDeoptimizingRecursively(HBasicBlock* block) { 758 void HGraph::MarkAsDeoptimizingRecursively(HBasicBlock* block) {
754 for (int i = 0; i < block->dominated_blocks()->length(); ++i) { 759 for (int i = 0; i < block->dominated_blocks()->length(); ++i) {
755 HBasicBlock* dominated = block->dominated_blocks()->at(i); 760 HBasicBlock* dominated = block->dominated_blocks()->at(i);
756 if (block->IsDeoptimizing()) dominated->MarkAsDeoptimizing(); 761 if (block->IsDeoptimizing()) dominated->MarkAsDeoptimizing();
757 MarkAsDeoptimizingRecursively(dominated); 762 MarkAsDeoptimizingRecursively(dominated);
758 } 763 }
759 } 764 }
760 765
761 void HGraph::EliminateRedundantPhis() { 766 void HGraph::EliminateRedundantPhis() {
762 HPhase phase("Redundant phi elimination", this); 767 HPhase phase("Redundant phi elimination", this);
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 2293
2289 if (current_block() != NULL) { 2294 if (current_block() != NULL) {
2290 HReturn* instr = new(zone()) HReturn(graph()->GetConstantUndefined()); 2295 HReturn* instr = new(zone()) HReturn(graph()->GetConstantUndefined());
2291 current_block()->FinishExit(instr); 2296 current_block()->FinishExit(instr);
2292 set_current_block(NULL); 2297 set_current_block(NULL);
2293 } 2298 }
2294 } 2299 }
2295 2300
2296 graph()->OrderBlocks(); 2301 graph()->OrderBlocks();
2297 graph()->AssignDominators(); 2302 graph()->AssignDominators();
2303 graph()->PropagateDeoptimizingMark();
2298 graph()->EliminateRedundantPhis(); 2304 graph()->EliminateRedundantPhis();
2299 if (FLAG_eliminate_dead_phis) graph()->EliminateUnreachablePhis(); 2305 if (FLAG_eliminate_dead_phis) graph()->EliminateUnreachablePhis();
2300 if (!graph()->CollectPhis()) { 2306 if (!graph()->CollectPhis()) {
2301 Bailout("Unsupported phi-use"); 2307 Bailout("Unsupported phi-use");
2302 return NULL; 2308 return NULL;
2303 } 2309 }
2304 2310
2305 HInferRepresentation rep(graph()); 2311 HInferRepresentation rep(graph());
2306 rep.Analyze(); 2312 rep.Analyze();
2307 2313
(...skipping 4418 matching lines...) Expand 10 before | Expand all | Expand 10 after
6726 } 6732 }
6727 } 6733 }
6728 6734
6729 #ifdef DEBUG 6735 #ifdef DEBUG
6730 if (graph_ != NULL) graph_->Verify(); 6736 if (graph_ != NULL) graph_->Verify();
6731 if (allocator_ != NULL) allocator_->Verify(); 6737 if (allocator_ != NULL) allocator_->Verify();
6732 #endif 6738 #endif
6733 } 6739 }
6734 6740
6735 } } // namespace v8::internal 6741 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698