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

Side by Side Diff: src/compiler/move-optimizer.cc

Issue 907873002: [turbofan] make zone allocation of InstructionOperand explicit (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/register-allocator.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/move-optimizer.h" 5 #include "src/compiler/move-optimizer.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
(...skipping 11 matching lines...) Expand all
22 replacement = curr; 22 replacement = curr;
23 if (to_eliminate != nullptr) break; 23 if (to_eliminate != nullptr) break;
24 } else if (curr->destination()->Equals(move->destination())) { 24 } else if (curr->destination()->Equals(move->destination())) {
25 DCHECK(!to_eliminate); 25 DCHECK(!to_eliminate);
26 to_eliminate = curr; 26 to_eliminate = curr;
27 if (replacement != nullptr) break; 27 if (replacement != nullptr) break;
28 } 28 }
29 } 29 }
30 DCHECK(!(replacement == to_eliminate && replacement != nullptr)); 30 DCHECK(!(replacement == to_eliminate && replacement != nullptr));
31 if (replacement != nullptr) { 31 if (replacement != nullptr) {
32 auto new_source = new (zone) InstructionOperand( 32 auto new_source = InstructionOperand::New(
33 replacement->source()->kind(), replacement->source()->index()); 33 zone, replacement->source()->kind(), replacement->source()->index());
34 move->set_source(new_source); 34 move->set_source(new_source);
35 } 35 }
36 return to_eliminate; 36 return to_eliminate;
37 } 37 }
38 38
39 39
40 bool GapsCanMoveOver(Instruction* instr) { 40 bool GapsCanMoveOver(Instruction* instr) {
41 DCHECK(!instr->IsGapMoves()); 41 DCHECK(!instr->IsGapMoves());
42 return instr->IsSourcePosition() || instr->IsNop(); 42 return instr->IsSourcePosition() || instr->IsNop();
43 } 43 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (load->source()->Equals(move->source())) { 179 if (load->source()->Equals(move->source())) {
180 found = load; 180 found = load;
181 break; 181 break;
182 } 182 }
183 } 183 }
184 // Not found so insert. 184 // Not found so insert.
185 if (found == nullptr) { 185 if (found == nullptr) {
186 loads.push_back(move); 186 loads.push_back(move);
187 // Replace source with copy for later use. 187 // Replace source with copy for later use.
188 auto dest = move->destination(); 188 auto dest = move->destination();
189 move->set_destination(new (code_zone()) 189 move->set_destination(
190 InstructionOperand(dest->kind(), dest->index())); 190 InstructionOperand::New(code_zone(), dest->kind(), dest->index()));
191 continue; 191 continue;
192 } 192 }
193 if ((found->destination()->IsStackSlot() || 193 if ((found->destination()->IsStackSlot() ||
194 found->destination()->IsDoubleStackSlot()) && 194 found->destination()->IsDoubleStackSlot()) &&
195 !(move->destination()->IsStackSlot() || 195 !(move->destination()->IsStackSlot() ||
196 move->destination()->IsDoubleStackSlot())) { 196 move->destination()->IsDoubleStackSlot())) {
197 // Found a better source for this load. Smash it in place to affect other 197 // Found a better source for this load. Smash it in place to affect other
198 // loads that have already been split. 198 // loads that have already been split.
199 InstructionOperand::Kind found_kind = found->destination()->kind(); 199 InstructionOperand::Kind found_kind = found->destination()->kind();
200 int found_index = found->destination()->index(); 200 int found_index = found->destination()->index();
201 auto next_dest = 201 auto next_dest =
202 new (code_zone()) InstructionOperand(found_kind, found_index); 202 InstructionOperand::New(code_zone(), found_kind, found_index);
203 auto dest = move->destination(); 203 auto dest = move->destination();
204 found->destination()->ConvertTo(dest->kind(), dest->index()); 204 found->destination()->ConvertTo(dest->kind(), dest->index());
205 move->set_destination(next_dest); 205 move->set_destination(next_dest);
206 } 206 }
207 // move from load destination. 207 // move from load destination.
208 move->set_source(found->destination()); 208 move->set_source(found->destination());
209 new_moves.push_back(move); 209 new_moves.push_back(move);
210 } 210 }
211 loads.clear(); 211 loads.clear();
212 if (new_moves.empty()) return; 212 if (new_moves.empty()) return;
213 // Insert all new moves into slot 1. 213 // Insert all new moves into slot 1.
214 auto slot_1 = gap->GetOrCreateParallelMove( 214 auto slot_1 = gap->GetOrCreateParallelMove(
215 static_cast<GapInstruction::InnerPosition>(1), code_zone()); 215 static_cast<GapInstruction::InnerPosition>(1), code_zone());
216 DCHECK(slot_1->move_operands()->is_empty()); 216 DCHECK(slot_1->move_operands()->is_empty());
217 slot_1->move_operands()->AddBlock(MoveOperands(nullptr, nullptr), 217 slot_1->move_operands()->AddBlock(MoveOperands(nullptr, nullptr),
218 static_cast<int>(new_moves.size()), 218 static_cast<int>(new_moves.size()),
219 code_zone()); 219 code_zone());
220 auto it = slot_1->move_operands()->begin(); 220 auto it = slot_1->move_operands()->begin();
221 for (auto new_move : new_moves) { 221 for (auto new_move : new_moves) {
222 std::swap(*new_move, *it); 222 std::swap(*new_move, *it);
223 ++it; 223 ++it;
224 } 224 }
225 DCHECK_EQ(it, slot_1->move_operands()->end()); 225 DCHECK_EQ(it, slot_1->move_operands()->end());
226 new_moves.clear(); 226 new_moves.clear();
227 } 227 }
228 228
229 } // namespace compiler 229 } // namespace compiler
230 } // namespace internal 230 } // namespace internal
231 } // namespace v8 231 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/register-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698