| OLD | NEW |
| 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/pipeline.h" | 5 #include "src/compiler/pipeline.h" |
| 6 | 6 |
| 7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/base/adapters.h" | 10 #include "src/base/adapters.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 void InitializeInstructionSequence(const CallDescriptor* descriptor) { | 270 void InitializeInstructionSequence(const CallDescriptor* descriptor) { |
| 271 DCHECK(sequence_ == nullptr); | 271 DCHECK(sequence_ == nullptr); |
| 272 InstructionBlocks* instruction_blocks = | 272 InstructionBlocks* instruction_blocks = |
| 273 InstructionSequence::InstructionBlocksFor(instruction_zone(), | 273 InstructionSequence::InstructionBlocksFor(instruction_zone(), |
| 274 schedule()); | 274 schedule()); |
| 275 sequence_ = new (instruction_zone()) InstructionSequence( | 275 sequence_ = new (instruction_zone()) InstructionSequence( |
| 276 info()->isolate(), instruction_zone(), instruction_blocks); | 276 info()->isolate(), instruction_zone(), instruction_blocks); |
| 277 if (descriptor && descriptor->RequiresFrameAsIncoming()) { | 277 if (descriptor && descriptor->RequiresFrameAsIncoming()) { |
| 278 sequence_->instruction_blocks()[0]->mark_needs_frame(); | 278 sequence_->instruction_blocks()[0]->mark_needs_frame(); |
| 279 } else { |
| 280 DCHECK_EQ(0, descriptor->CalleeSavedFPRegisters()); |
| 281 DCHECK_EQ(0, descriptor->CalleeSavedRegisters()); |
| 279 } | 282 } |
| 280 } | 283 } |
| 281 | 284 |
| 282 void InitializeFrameData(CallDescriptor* descriptor) { | 285 void InitializeFrameData(CallDescriptor* descriptor) { |
| 283 DCHECK(frame_ == nullptr); | 286 DCHECK(frame_ == nullptr); |
| 284 int fixed_frame_size = 0; | 287 int fixed_frame_size = 0; |
| 285 if (descriptor != nullptr) { | 288 if (descriptor != nullptr) { |
| 286 fixed_frame_size = CalculateFixedFrameSize(descriptor); | 289 fixed_frame_size = CalculateFixedFrameSize(descriptor); |
| 287 } | 290 } |
| 288 frame_ = new (instruction_zone()) Frame(fixed_frame_size, descriptor); | 291 frame_ = new (instruction_zone()) Frame(fixed_frame_size, descriptor); |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 data->DeleteGraphZone(); | 1366 data->DeleteGraphZone(); |
| 1364 | 1367 |
| 1365 BeginPhaseKind("register allocation"); | 1368 BeginPhaseKind("register allocation"); |
| 1366 | 1369 |
| 1367 bool run_verifier = FLAG_turbo_verify_allocation; | 1370 bool run_verifier = FLAG_turbo_verify_allocation; |
| 1368 | 1371 |
| 1369 // Allocate registers. | 1372 // Allocate registers. |
| 1370 AllocateRegisters( | 1373 AllocateRegisters( |
| 1371 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), | 1374 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), |
| 1372 call_descriptor, run_verifier); | 1375 call_descriptor, run_verifier); |
| 1376 Run<FrameElisionPhase>(); |
| 1373 if (data->compilation_failed()) { | 1377 if (data->compilation_failed()) { |
| 1374 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | 1378 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
| 1375 return Handle<Code>(); | 1379 return Handle<Code>(); |
| 1376 } | 1380 } |
| 1377 | 1381 |
| 1378 BeginPhaseKind("code generation"); | 1382 BeginPhaseKind("code generation"); |
| 1379 // TODO(mtrofin): move this off to the register allocator. | 1383 // TODO(mtrofin): move this off to the register allocator. |
| 1380 bool generate_frame_at_start = | 1384 bool generate_frame_at_start = |
| 1381 !FLAG_turbo_frame_elision || !data_->info()->IsStub() || | 1385 data_->sequence()->instruction_blocks().front()->must_construct_frame(); |
| 1382 !data_->frame()->needs_frame() || | |
| 1383 data_->sequence()->instruction_blocks().front()->needs_frame() || | |
| 1384 linkage.GetIncomingDescriptor()->CalleeSavedFPRegisters() != 0 || | |
| 1385 linkage.GetIncomingDescriptor()->CalleeSavedRegisters() != 0; | |
| 1386 // Optimimize jumps. | 1386 // Optimimize jumps. |
| 1387 if (FLAG_turbo_jt) { | 1387 if (FLAG_turbo_jt) { |
| 1388 Run<JumpThreadingPhase>(generate_frame_at_start); | 1388 Run<JumpThreadingPhase>(generate_frame_at_start); |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 // Generate final machine code. | 1391 // Generate final machine code. |
| 1392 Run<GenerateCodePhase>(&linkage); | 1392 Run<GenerateCodePhase>(&linkage); |
| 1393 | 1393 |
| 1394 Handle<Code> code = data->code(); | 1394 Handle<Code> code = data->code(); |
| 1395 if (profiler_data != nullptr) { | 1395 if (profiler_data != nullptr) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 | 1495 |
| 1496 Run<CommitAssignmentPhase>(); | 1496 Run<CommitAssignmentPhase>(); |
| 1497 Run<PopulateReferenceMapsPhase>(); | 1497 Run<PopulateReferenceMapsPhase>(); |
| 1498 Run<ConnectRangesPhase>(); | 1498 Run<ConnectRangesPhase>(); |
| 1499 Run<ResolveControlFlowPhase>(); | 1499 Run<ResolveControlFlowPhase>(); |
| 1500 if (FLAG_turbo_move_optimization) { | 1500 if (FLAG_turbo_move_optimization) { |
| 1501 Run<OptimizeMovesPhase>(); | 1501 Run<OptimizeMovesPhase>(); |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 Run<LocateSpillSlotsPhase>(); | 1504 Run<LocateSpillSlotsPhase>(); |
| 1505 Run<FrameElisionPhase>(); | |
| 1506 | 1505 |
| 1507 if (FLAG_trace_turbo_graph) { | 1506 if (FLAG_trace_turbo_graph) { |
| 1508 OFStream os(stdout); | 1507 OFStream os(stdout); |
| 1509 PrintableInstructionSequence printable = {config, data->sequence()}; | 1508 PrintableInstructionSequence printable = {config, data->sequence()}; |
| 1510 os << "----- Instruction sequence after register allocation -----\n" | 1509 os << "----- Instruction sequence after register allocation -----\n" |
| 1511 << printable; | 1510 << printable; |
| 1512 } | 1511 } |
| 1513 | 1512 |
| 1514 if (verifier != nullptr) { | 1513 if (verifier != nullptr) { |
| 1515 verifier->VerifyAssignment(); | 1514 verifier->VerifyAssignment(); |
| 1516 verifier->VerifyGapMoves(); | 1515 verifier->VerifyGapMoves(); |
| 1517 } | 1516 } |
| 1518 | 1517 |
| 1519 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { | 1518 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { |
| 1520 TurboCfgFile tcf(data->isolate()); | 1519 TurboCfgFile tcf(data->isolate()); |
| 1521 tcf << AsC1VRegisterAllocationData("CodeGen", | 1520 tcf << AsC1VRegisterAllocationData("CodeGen", |
| 1522 data->register_allocation_data()); | 1521 data->register_allocation_data()); |
| 1523 } | 1522 } |
| 1524 | 1523 |
| 1525 data->DeleteRegisterAllocationZone(); | 1524 data->DeleteRegisterAllocationZone(); |
| 1526 } | 1525 } |
| 1527 | 1526 |
| 1528 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1527 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
| 1529 | 1528 |
| 1530 } // namespace compiler | 1529 } // namespace compiler |
| 1531 } // namespace internal | 1530 } // namespace internal |
| 1532 } // namespace v8 | 1531 } // namespace v8 |
| OLD | NEW |