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

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

Issue 1119483003: Revert of [turbofan] add MachineType to AllocatedOperand (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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-selector-impl.h ('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 typedef std::pair<InstructionOperand, InstructionOperand> MoveKey; 13 typedef std::pair<InstructionOperand, InstructionOperand> MoveKey;
14 14 typedef ZoneMap<MoveKey, unsigned> MoveMap;
15 struct MoveKeyCompare { 15 typedef ZoneSet<InstructionOperand> OperandSet;
16 bool operator()(const MoveKey& a, const MoveKey& b) const {
17 if (a.first.EqualsModuloType(b.first)) {
18 return a.second.CompareModuloType(b.second);
19 }
20 return a.first.CompareModuloType(b.first);
21 }
22 };
23
24 typedef ZoneMap<MoveKey, unsigned, MoveKeyCompare> MoveMap;
25 typedef ZoneSet<InstructionOperand, CompareOperandModuloType> OperandSet;
26 16
27 17
28 bool GapsCanMoveOver(Instruction* instr) { return instr->IsNop(); } 18 bool GapsCanMoveOver(Instruction* instr) { return instr->IsNop(); }
29 19
30 20
31 int FindFirstNonEmptySlot(Instruction* instr) { 21 int FindFirstNonEmptySlot(Instruction* instr) {
32 int i = Instruction::FIRST_GAP_POSITION; 22 int i = Instruction::FIRST_GAP_POSITION;
33 for (; i <= Instruction::LAST_GAP_POSITION; i++) { 23 for (; i <= Instruction::LAST_GAP_POSITION; i++) {
34 auto moves = instr->parallel_moves()[i]; 24 auto moves = instr->parallel_moves()[i];
35 if (moves == nullptr) continue; 25 if (moves == nullptr) continue;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 217
228 218
229 namespace { 219 namespace {
230 220
231 bool IsSlot(const InstructionOperand& op) { 221 bool IsSlot(const InstructionOperand& op) {
232 return op.IsStackSlot() || op.IsDoubleStackSlot(); 222 return op.IsStackSlot() || op.IsDoubleStackSlot();
233 } 223 }
234 224
235 225
236 bool LoadCompare(const MoveOperands* a, const MoveOperands* b) { 226 bool LoadCompare(const MoveOperands* a, const MoveOperands* b) {
237 if (!a->source().EqualsModuloType(b->source())) { 227 if (a->source() != b->source()) return a->source() < b->source();
238 return a->source().CompareModuloType(b->source());
239 }
240 if (IsSlot(a->destination()) && !IsSlot(b->destination())) return false; 228 if (IsSlot(a->destination()) && !IsSlot(b->destination())) return false;
241 if (!IsSlot(a->destination()) && IsSlot(b->destination())) return true; 229 if (!IsSlot(a->destination()) && IsSlot(b->destination())) return true;
242 return a->destination().CompareModuloType(b->destination()); 230 return a->destination() < b->destination();
243 } 231 }
244 232
245 } // namespace 233 } // namespace
246 234
247 235
248 // Split multiple loads of the same constant or stack slot off into the second 236 // Split multiple loads of the same constant or stack slot off into the second
249 // slot and keep remaining moves in the first slot. 237 // slot and keep remaining moves in the first slot.
250 void MoveOptimizer::FinalizeMoves(Instruction* instr) { 238 void MoveOptimizer::FinalizeMoves(Instruction* instr) {
251 auto loads = temp_vector_0(); 239 auto loads = temp_vector_0();
252 DCHECK(loads.empty()); 240 DCHECK(loads.empty());
253 // Find all the loads. 241 // Find all the loads.
254 for (auto move : *instr->parallel_moves()[0]) { 242 for (auto move : *instr->parallel_moves()[0]) {
255 if (move->IsRedundant()) continue; 243 if (move->IsRedundant()) continue;
256 if (move->source().IsConstant() || IsSlot(move->source())) { 244 if (move->source().IsConstant() || IsSlot(move->source())) {
257 loads.push_back(move); 245 loads.push_back(move);
258 } 246 }
259 } 247 }
260 if (loads.empty()) return; 248 if (loads.empty()) return;
261 // Group the loads by source, moving the preferred destination to the 249 // Group the loads by source, moving the preferred destination to the
262 // beginning of the group. 250 // beginning of the group.
263 std::sort(loads.begin(), loads.end(), LoadCompare); 251 std::sort(loads.begin(), loads.end(), LoadCompare);
264 MoveOperands* group_begin = nullptr; 252 MoveOperands* group_begin = nullptr;
265 for (auto load : loads) { 253 for (auto load : loads) {
266 // New group. 254 // New group.
267 if (group_begin == nullptr || 255 if (group_begin == nullptr || load->source() != group_begin->source()) {
268 !load->source().EqualsModuloType(group_begin->source())) {
269 group_begin = load; 256 group_begin = load;
270 continue; 257 continue;
271 } 258 }
272 // Nothing to be gained from splitting here. 259 // Nothing to be gained from splitting here.
273 if (IsSlot(group_begin->destination())) continue; 260 if (IsSlot(group_begin->destination())) continue;
274 // Insert new move into slot 1. 261 // Insert new move into slot 1.
275 auto slot_1 = instr->GetOrCreateParallelMove( 262 auto slot_1 = instr->GetOrCreateParallelMove(
276 static_cast<Instruction::GapPosition>(1), code_zone()); 263 static_cast<Instruction::GapPosition>(1), code_zone());
277 slot_1->AddMove(group_begin->destination(), load->destination()); 264 slot_1->AddMove(group_begin->destination(), load->destination());
278 load->Eliminate(); 265 load->Eliminate();
279 } 266 }
280 loads.clear(); 267 loads.clear();
281 } 268 }
282 269
283 } // namespace compiler 270 } // namespace compiler
284 } // namespace internal 271 } // namespace internal
285 } // namespace v8 272 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector-impl.h ('k') | src/compiler/register-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698