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

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

Issue 948033002: [turbofan] only use two gaps (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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.cc ('k') | src/compiler/register-allocator.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 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
11 namespace { 11 namespace {
12 12
13 MoveOperands* PrepareInsertAfter(ParallelMove* left, MoveOperands* move,
14 Zone* zone) {
15 auto move_ops = left->move_operands();
16 MoveOperands* replacement = nullptr;
17 MoveOperands* to_eliminate = nullptr;
18 for (auto curr = move_ops->begin(); curr != move_ops->end(); ++curr) {
19 if (curr->IsEliminated()) continue;
20 if (curr->destination()->Equals(move->source())) {
21 DCHECK(!replacement);
22 replacement = curr;
23 if (to_eliminate != nullptr) break;
24 } else if (curr->destination()->Equals(move->destination())) {
25 DCHECK(!to_eliminate);
26 to_eliminate = curr;
27 if (replacement != nullptr) break;
28 }
29 }
30 DCHECK(!(replacement == to_eliminate && replacement != nullptr));
31 if (replacement != nullptr) {
32 auto new_source = InstructionOperand::New(
33 zone, replacement->source()->kind(), replacement->source()->index());
34 move->set_source(new_source);
35 }
36 return to_eliminate;
37 }
38
39
40 bool GapsCanMoveOver(Instruction* instr) { 13 bool GapsCanMoveOver(Instruction* instr) {
41 DCHECK(!instr->IsGapMoves()); 14 DCHECK(!instr->IsGapMoves());
42 return instr->IsSourcePosition() || instr->IsNop(); 15 return instr->IsSourcePosition() || instr->IsNop();
43 } 16 }
44 17
45 18
46 int FindFirstNonEmptySlot(GapInstruction* gap) { 19 int FindFirstNonEmptySlot(GapInstruction* gap) {
47 int i = GapInstruction::FIRST_INNER_POSITION; 20 int i = GapInstruction::FIRST_INNER_POSITION;
48 for (; i <= GapInstruction::LAST_INNER_POSITION; i++) { 21 for (; i <= GapInstruction::LAST_INNER_POSITION; i++) {
49 auto move = gap->parallel_moves()[i]; 22 auto move = gap->parallel_moves()[i];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 56
84 void MoveOptimizer::CompressMoves(MoveOpVector* eliminated, ParallelMove* left, 57 void MoveOptimizer::CompressMoves(MoveOpVector* eliminated, ParallelMove* left,
85 ParallelMove* right) { 58 ParallelMove* right) {
86 DCHECK(eliminated->empty()); 59 DCHECK(eliminated->empty());
87 auto move_ops = right->move_operands(); 60 auto move_ops = right->move_operands();
88 if (!left->move_operands()->is_empty()) { 61 if (!left->move_operands()->is_empty()) {
89 // Modify the right moves in place and collect moves that will be killed by 62 // Modify the right moves in place and collect moves that will be killed by
90 // merging the two gaps. 63 // merging the two gaps.
91 for (auto op = move_ops->begin(); op != move_ops->end(); ++op) { 64 for (auto op = move_ops->begin(); op != move_ops->end(); ++op) {
92 if (op->IsRedundant()) continue; 65 if (op->IsRedundant()) continue;
93 MoveOperands* to_eliminate = PrepareInsertAfter(left, op, code_zone()); 66 auto to_eliminate = left->PrepareInsertAfter(op);
94 if (to_eliminate != nullptr) eliminated->push_back(to_eliminate); 67 if (to_eliminate != nullptr) eliminated->push_back(to_eliminate);
95 } 68 }
96 // Eliminate dead moves. Must happen before insertion of new moves as the 69 // Eliminate dead moves. Must happen before insertion of new moves as the
97 // contents of eliminated are pointers into a list. 70 // contents of eliminated are pointers into a list.
98 for (auto to_eliminate : *eliminated) { 71 for (auto to_eliminate : *eliminated) {
99 to_eliminate->Eliminate(); 72 to_eliminate->Eliminate();
100 } 73 }
101 eliminated->clear(); 74 eliminated->clear();
102 } 75 }
103 // Add all possibly modified moves from right side. 76 // Add all possibly modified moves from right side.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 std::swap(*new_move, *it); 195 std::swap(*new_move, *it);
223 ++it; 196 ++it;
224 } 197 }
225 DCHECK_EQ(it, slot_1->move_operands()->end()); 198 DCHECK_EQ(it, slot_1->move_operands()->end());
226 new_moves.clear(); 199 new_moves.clear();
227 } 200 }
228 201
229 } // namespace compiler 202 } // namespace compiler
230 } // namespace internal 203 } // namespace internal
231 } // namespace v8 204 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.cc ('k') | src/compiler/register-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698