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 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 void Run(PipelineData* data, Zone* temp_zone) { | 995 void Run(PipelineData* data, Zone* temp_zone) { |
996 MoveOptimizer move_optimizer(temp_zone, data->sequence()); | 996 MoveOptimizer move_optimizer(temp_zone, data->sequence()); |
997 move_optimizer.Run(); | 997 move_optimizer.Run(); |
998 } | 998 } |
999 }; | 999 }; |
1000 | 1000 |
1001 | 1001 |
1002 struct FrameElisionPhase { | 1002 struct FrameElisionPhase { |
1003 static const char* phase_name() { return "frame elision"; } | 1003 static const char* phase_name() { return "frame elision"; } |
1004 | 1004 |
1005 void Run(PipelineData* data, Zone* temp_zone) { | 1005 void Run(PipelineData* data, Zone* temp_zone, |
1006 FrameElider(data->sequence()).Run(); | 1006 const CallDescriptor* descriptor) { |
| 1007 FrameElider(data->sequence()).Run(descriptor); |
1007 } | 1008 } |
1008 }; | 1009 }; |
1009 | 1010 |
1010 | 1011 |
1011 struct JumpThreadingPhase { | 1012 struct JumpThreadingPhase { |
1012 static const char* phase_name() { return "jump threading"; } | 1013 static const char* phase_name() { return "jump threading"; } |
1013 | 1014 |
1014 void Run(PipelineData* data, Zone* temp_zone, bool frame_at_start) { | 1015 void Run(PipelineData* data, Zone* temp_zone, bool frame_at_start) { |
1015 ZoneVector<RpoNumber> result(temp_zone); | 1016 ZoneVector<RpoNumber> result(temp_zone); |
1016 if (JumpThreading::ComputeForwarding(temp_zone, result, data->sequence(), | 1017 if (JumpThreading::ComputeForwarding(temp_zone, result, data->sequence(), |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), | 1367 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), |
1367 call_descriptor, run_verifier); | 1368 call_descriptor, run_verifier); |
1368 if (data->compilation_failed()) { | 1369 if (data->compilation_failed()) { |
1369 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | 1370 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
1370 return Handle<Code>(); | 1371 return Handle<Code>(); |
1371 } | 1372 } |
1372 | 1373 |
1373 BeginPhaseKind("code generation"); | 1374 BeginPhaseKind("code generation"); |
1374 // TODO(mtrofin): move this off to the register allocator. | 1375 // TODO(mtrofin): move this off to the register allocator. |
1375 bool generate_frame_at_start = | 1376 bool generate_frame_at_start = |
1376 !FLAG_turbo_frame_elision || !data_->info()->IsStub() || | 1377 data_->sequence()->instruction_blocks().front()->must_construct_frame(); |
1377 !data_->frame()->needs_frame() || | |
1378 data_->sequence()->instruction_blocks().front()->needs_frame() || | |
1379 linkage.GetIncomingDescriptor()->CalleeSavedFPRegisters() != 0 || | |
1380 linkage.GetIncomingDescriptor()->CalleeSavedRegisters() != 0; | |
1381 // Optimimize jumps. | 1378 // Optimimize jumps. |
1382 if (FLAG_turbo_jt) { | 1379 if (FLAG_turbo_jt) { |
1383 Run<JumpThreadingPhase>(generate_frame_at_start); | 1380 Run<JumpThreadingPhase>(generate_frame_at_start); |
1384 } | 1381 } |
1385 | 1382 |
1386 // Generate final machine code. | 1383 // Generate final machine code. |
1387 Run<GenerateCodePhase>(&linkage); | 1384 Run<GenerateCodePhase>(&linkage); |
1388 | 1385 |
1389 Handle<Code> code = data->code(); | 1386 Handle<Code> code = data->code(); |
1390 if (profiler_data != nullptr) { | 1387 if (profiler_data != nullptr) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 Run<AllocateDoubleRegistersPhase<GreedyAllocator>>(); | 1475 Run<AllocateDoubleRegistersPhase<GreedyAllocator>>(); |
1479 } else { | 1476 } else { |
1480 Run<AllocateGeneralRegistersPhase<LinearScanAllocator>>(); | 1477 Run<AllocateGeneralRegistersPhase<LinearScanAllocator>>(); |
1481 Run<AllocateDoubleRegistersPhase<LinearScanAllocator>>(); | 1478 Run<AllocateDoubleRegistersPhase<LinearScanAllocator>>(); |
1482 } | 1479 } |
1483 | 1480 |
1484 if (FLAG_turbo_preprocess_ranges) { | 1481 if (FLAG_turbo_preprocess_ranges) { |
1485 Run<MergeSplintersPhase>(); | 1482 Run<MergeSplintersPhase>(); |
1486 } | 1483 } |
1487 | 1484 |
1488 // We plan to enable frame elision only for stubs and bytecode handlers. | |
1489 if (FLAG_turbo_frame_elision && info()->IsStub()) { | |
1490 Run<LocateSpillSlotsPhase>(); | |
1491 Run<FrameElisionPhase>(); | |
1492 } | |
1493 | |
1494 Run<AssignSpillSlotsPhase>(); | 1485 Run<AssignSpillSlotsPhase>(); |
1495 | 1486 |
1496 Run<CommitAssignmentPhase>(); | 1487 Run<CommitAssignmentPhase>(); |
1497 Run<PopulateReferenceMapsPhase>(); | 1488 Run<PopulateReferenceMapsPhase>(); |
1498 Run<ConnectRangesPhase>(); | 1489 Run<ConnectRangesPhase>(); |
1499 Run<ResolveControlFlowPhase>(); | 1490 Run<ResolveControlFlowPhase>(); |
1500 if (FLAG_turbo_move_optimization) { | 1491 if (FLAG_turbo_move_optimization) { |
1501 Run<OptimizeMovesPhase>(); | 1492 Run<OptimizeMovesPhase>(); |
1502 } | 1493 } |
1503 | 1494 |
| 1495 if (descriptor != nullptr && descriptor->RequiresFrameAsIncoming()) { |
| 1496 data_->sequence()->instruction_blocks()[0]->mark_needs_frame(); |
| 1497 } |
| 1498 |
| 1499 Run<LocateSpillSlotsPhase>(); |
| 1500 Run<FrameElisionPhase>(descriptor); |
| 1501 |
1504 if (FLAG_trace_turbo_graph) { | 1502 if (FLAG_trace_turbo_graph) { |
1505 OFStream os(stdout); | 1503 OFStream os(stdout); |
1506 PrintableInstructionSequence printable = {config, data->sequence()}; | 1504 PrintableInstructionSequence printable = {config, data->sequence()}; |
1507 os << "----- Instruction sequence after register allocation -----\n" | 1505 os << "----- Instruction sequence after register allocation -----\n" |
1508 << printable; | 1506 << printable; |
1509 } | 1507 } |
1510 | 1508 |
1511 if (verifier != nullptr) { | 1509 if (verifier != nullptr) { |
1512 verifier->VerifyAssignment(); | 1510 verifier->VerifyAssignment(); |
1513 verifier->VerifyGapMoves(); | 1511 verifier->VerifyGapMoves(); |
1514 } | 1512 } |
1515 | 1513 |
1516 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { | 1514 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { |
1517 TurboCfgFile tcf(data->isolate()); | 1515 TurboCfgFile tcf(data->isolate()); |
1518 tcf << AsC1VRegisterAllocationData("CodeGen", | 1516 tcf << AsC1VRegisterAllocationData("CodeGen", |
1519 data->register_allocation_data()); | 1517 data->register_allocation_data()); |
1520 } | 1518 } |
1521 | 1519 |
1522 data->DeleteRegisterAllocationZone(); | 1520 data->DeleteRegisterAllocationZone(); |
1523 } | 1521 } |
1524 | 1522 |
1525 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1523 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
1526 | 1524 |
1527 } // namespace compiler | 1525 } // namespace compiler |
1528 } // namespace internal | 1526 } // namespace internal |
1529 } // namespace v8 | 1527 } // namespace v8 |
OLD | NEW |