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

Side by Side Diff: src/hydrogen-dce.cc

Issue 31943002: Allow constants to be deleted by reinserting them into the graph as needed. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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.cc ('k') | src/hydrogen-instructions.cc » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void HDeadCodeEliminationPhase::RemoveDeadInstructions() { 91 void HDeadCodeEliminationPhase::RemoveDeadInstructions() {
92 ZoneList<HPhi*> worklist(graph()->blocks()->length(), zone()); 92 ZoneList<HPhi*> worklist(graph()->blocks()->length(), zone());
93 93
94 // Remove any instruction not marked kIsLive. 94 // Remove any instruction not marked kIsLive.
95 for (int i = 0; i < graph()->blocks()->length(); ++i) { 95 for (int i = 0; i < graph()->blocks()->length(); ++i) {
96 HBasicBlock* block = graph()->blocks()->at(i); 96 HBasicBlock* block = graph()->blocks()->at(i);
97 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { 97 for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
98 HInstruction* instr = it.Current(); 98 HInstruction* instr = it.Current();
99 if (!instr->CheckFlag(HValue::kIsLive)) { 99 if (!instr->CheckFlag(HValue::kIsLive)) {
100 // Instruction has not been marked live, so remove it. 100 // Instruction has not been marked live, so remove it.
101 if (!instr->IsConstant() || instr->block()->block_id() != 0) { 101 instr->DeleteAndReplaceWith(NULL);
102 // TODO(titzer): Some global constants in block 0 can be used
103 // again later, and can't currently be removed. Fix that.
104 instr->DeleteAndReplaceWith(NULL);
105 }
106 } else { 102 } else {
107 // Clear the liveness flag to leave the graph clean for the next DCE. 103 // Clear the liveness flag to leave the graph clean for the next DCE.
108 instr->ClearFlag(HValue::kIsLive); 104 instr->ClearFlag(HValue::kIsLive);
109 } 105 }
110 } 106 }
111 // Collect phis that are dead and remove them in the next pass. 107 // Collect phis that are dead and remove them in the next pass.
112 for (int j = 0; j < block->phis()->length(); j++) { 108 for (int j = 0; j < block->phis()->length(); j++) {
113 HPhi* phi = block->phis()->at(j); 109 HPhi* phi = block->phis()->at(j);
114 if (!phi->CheckFlag(HValue::kIsLive)) { 110 if (!phi->CheckFlag(HValue::kIsLive)) {
115 worklist.Add(phi, zone()); 111 worklist.Add(phi, zone());
116 } else { 112 } else {
117 phi->ClearFlag(HValue::kIsLive); 113 phi->ClearFlag(HValue::kIsLive);
118 } 114 }
119 } 115 }
120 } 116 }
121 117
122 // Process phis separately to avoid simultaneously mutating the phi list. 118 // Process phis separately to avoid simultaneously mutating the phi list.
123 while (!worklist.is_empty()) { 119 while (!worklist.is_empty()) {
124 HPhi* phi = worklist.RemoveLast(); 120 HPhi* phi = worklist.RemoveLast();
125 HBasicBlock* block = phi->block(); 121 HBasicBlock* block = phi->block();
126 phi->DeleteAndReplaceWith(NULL); 122 phi->DeleteAndReplaceWith(NULL);
127 if (phi->HasMergedIndex()) { 123 if (phi->HasMergedIndex()) {
128 block->RecordDeletedPhi(phi->merged_index()); 124 block->RecordDeletedPhi(phi->merged_index());
129 } 125 }
130 } 126 }
131 } 127 }
132 128
133 } } // namespace v8::internal 129 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698