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

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

Issue 1050803002: [turbofan] cleanup InstructionOperand a little (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 8 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/mips64/code-generator-mips64.cc ('k') | src/compiler/ppc/code-generator-ppc.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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 if (load->source()->Equals(move->source())) { 249 if (load->source()->Equals(move->source())) {
250 found = load; 250 found = load;
251 break; 251 break;
252 } 252 }
253 } 253 }
254 // Not found so insert. 254 // Not found so insert.
255 if (found == nullptr) { 255 if (found == nullptr) {
256 loads.push_back(move); 256 loads.push_back(move);
257 // Replace source with copy for later use. 257 // Replace source with copy for later use.
258 auto dest = move->destination(); 258 auto dest = move->destination();
259 move->set_destination( 259 move->set_destination(InstructionOperand::New(code_zone(), *dest));
260 InstructionOperand::New(code_zone(), dest->kind(), dest->index()));
261 continue; 260 continue;
262 } 261 }
263 if ((found->destination()->IsStackSlot() || 262 if ((found->destination()->IsStackSlot() ||
264 found->destination()->IsDoubleStackSlot()) && 263 found->destination()->IsDoubleStackSlot()) &&
265 !(move->destination()->IsStackSlot() || 264 !(move->destination()->IsStackSlot() ||
266 move->destination()->IsDoubleStackSlot())) { 265 move->destination()->IsDoubleStackSlot())) {
267 // Found a better source for this load. Smash it in place to affect other 266 // Found a better source for this load. Smash it in place to affect other
268 // loads that have already been split. 267 // loads that have already been split.
269 InstructionOperand::Kind found_kind = found->destination()->kind();
270 int found_index = found->destination()->index();
271 auto next_dest = 268 auto next_dest =
272 InstructionOperand::New(code_zone(), found_kind, found_index); 269 InstructionOperand::New(code_zone(), *found->destination());
273 auto dest = move->destination(); 270 auto dest = move->destination();
274 found->destination()->ConvertTo(dest->kind(), dest->index()); 271 InstructionOperand::ReplaceWith(found->destination(), dest);
275 move->set_destination(next_dest); 272 move->set_destination(next_dest);
276 } 273 }
277 // move from load destination. 274 // move from load destination.
278 move->set_source(found->destination()); 275 move->set_source(found->destination());
279 new_moves.push_back(move); 276 new_moves.push_back(move);
280 } 277 }
281 loads.clear(); 278 loads.clear();
282 if (new_moves.empty()) return; 279 if (new_moves.empty()) return;
283 // Insert all new moves into slot 1. 280 // Insert all new moves into slot 1.
284 auto slot_1 = instr->GetOrCreateParallelMove( 281 auto slot_1 = instr->GetOrCreateParallelMove(
285 static_cast<Instruction::GapPosition>(1), code_zone()); 282 static_cast<Instruction::GapPosition>(1), code_zone());
286 DCHECK(slot_1->move_operands()->is_empty()); 283 DCHECK(slot_1->move_operands()->is_empty());
287 slot_1->move_operands()->AddBlock(MoveOperands(nullptr, nullptr), 284 slot_1->move_operands()->AddBlock(MoveOperands(nullptr, nullptr),
288 static_cast<int>(new_moves.size()), 285 static_cast<int>(new_moves.size()),
289 code_zone()); 286 code_zone());
290 auto it = slot_1->move_operands()->begin(); 287 auto it = slot_1->move_operands()->begin();
291 for (auto new_move : new_moves) { 288 for (auto new_move : new_moves) {
292 std::swap(*new_move, *it); 289 std::swap(*new_move, *it);
293 ++it; 290 ++it;
294 } 291 }
295 DCHECK_EQ(it, slot_1->move_operands()->end()); 292 DCHECK_EQ(it, slot_1->move_operands()->end());
296 new_moves.clear(); 293 new_moves.clear();
297 } 294 }
298 295
299 } // namespace compiler 296 } // namespace compiler
300 } // namespace internal 297 } // namespace internal
301 } // namespace v8 298 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/mips64/code-generator-mips64.cc ('k') | src/compiler/ppc/code-generator-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698