Chromium Code Reviews| 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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 837 static const char* phase_name() { return "allocate double registers"; } | 837 static const char* phase_name() { return "allocate double registers"; } |
| 838 | 838 |
| 839 void Run(PipelineData* data, Zone* temp_zone) { | 839 void Run(PipelineData* data, Zone* temp_zone) { |
| 840 RegAllocator allocator(data->register_allocation_data(), DOUBLE_REGISTERS, | 840 RegAllocator allocator(data->register_allocation_data(), DOUBLE_REGISTERS, |
| 841 temp_zone); | 841 temp_zone); |
| 842 allocator.AllocateRegisters(); | 842 allocator.AllocateRegisters(); |
| 843 } | 843 } |
| 844 }; | 844 }; |
| 845 | 845 |
| 846 | 846 |
| 847 struct MarkSpilledOnlyInDeferredPhase { | |
|
Jarin
2015/11/25 10:33:08
I think there is no need to introduce a new phase
Mircea Trofin
2015/11/25 16:21:36
It can be done, but it seemed cleaner to have it s
| |
| 848 static const char* phase_name() { | |
| 849 return "mark ranges spilled in deferred blocks"; | |
| 850 } | |
| 851 | |
| 852 void Run(PipelineData* pipeline_data, Zone* temp_zone) { | |
| 853 RegisterAllocationData* data = pipeline_data->register_allocation_data(); | |
| 854 for (TopLevelLiveRange* top : data->live_ranges()) { | |
|
Jarin
2015/11/25 10:33:08
The pipeline should not know about implementation
Mircea Trofin
2015/11/25 16:21:36
done as a side-effect of addressing the above.
| |
| 855 if (top == nullptr || top->IsEmpty() || top->splinter() == nullptr) { | |
| 856 continue; | |
| 857 } | |
| 858 | |
| 859 LiveRange* child = top; | |
| 860 for (; child != nullptr; child = child->next()) { | |
| 861 if (child->spilled() || | |
| 862 child->NextSlotPosition(child->Start()) != nullptr) { | |
| 863 break; | |
| 864 } | |
| 865 } | |
| 866 if (child == nullptr) top->MarkSpilledInDeferredBlock(); | |
| 867 } | |
| 868 } | |
| 869 }; | |
| 870 | |
| 871 | |
| 847 struct MergeSplintersPhase { | 872 struct MergeSplintersPhase { |
| 848 static const char* phase_name() { return "merge splintered ranges"; } | 873 static const char* phase_name() { return "merge splintered ranges"; } |
| 849 void Run(PipelineData* pipeline_data, Zone* temp_zone) { | 874 void Run(PipelineData* pipeline_data, Zone* temp_zone) { |
| 850 RegisterAllocationData* data = pipeline_data->register_allocation_data(); | 875 RegisterAllocationData* data = pipeline_data->register_allocation_data(); |
| 851 LiveRangeMerger live_range_merger(data, temp_zone); | 876 LiveRangeMerger live_range_merger(data, temp_zone); |
| 852 live_range_merger.Merge(); | 877 live_range_merger.Merge(); |
| 853 } | 878 } |
| 854 }; | 879 }; |
| 855 | 880 |
| 856 | 881 |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1369 Run<ResolvePhisPhase>(); | 1394 Run<ResolvePhisPhase>(); |
| 1370 Run<BuildLiveRangesPhase>(); | 1395 Run<BuildLiveRangesPhase>(); |
| 1371 if (FLAG_trace_turbo_graph) { | 1396 if (FLAG_trace_turbo_graph) { |
| 1372 OFStream os(stdout); | 1397 OFStream os(stdout); |
| 1373 PrintableInstructionSequence printable = {config, data->sequence()}; | 1398 PrintableInstructionSequence printable = {config, data->sequence()}; |
| 1374 os << "----- Instruction sequence before register allocation -----\n" | 1399 os << "----- Instruction sequence before register allocation -----\n" |
| 1375 << printable; | 1400 << printable; |
| 1376 } | 1401 } |
| 1377 if (verifier != nullptr) { | 1402 if (verifier != nullptr) { |
| 1378 CHECK(!data->register_allocation_data()->ExistsUseWithoutDefinition()); | 1403 CHECK(!data->register_allocation_data()->ExistsUseWithoutDefinition()); |
| 1404 CHECK(data->register_allocation_data() | |
| 1405 ->RangesDefinedInDeferredStaysInDeferred()); | |
| 1379 } | 1406 } |
| 1380 | 1407 |
| 1381 if (FLAG_turbo_preprocess_ranges) { | 1408 if (FLAG_turbo_preprocess_ranges) { |
| 1382 Run<SplinterLiveRangesPhase>(); | 1409 Run<SplinterLiveRangesPhase>(); |
| 1383 } | 1410 } |
| 1384 | 1411 |
| 1385 if (FLAG_turbo_greedy_regalloc) { | 1412 if (FLAG_turbo_greedy_regalloc) { |
| 1386 Run<AllocateGeneralRegistersPhase<GreedyAllocator>>(); | 1413 Run<AllocateGeneralRegistersPhase<GreedyAllocator>>(); |
| 1387 Run<AllocateDoubleRegistersPhase<GreedyAllocator>>(); | 1414 Run<AllocateDoubleRegistersPhase<GreedyAllocator>>(); |
| 1388 } else { | 1415 } else { |
| 1389 Run<AllocateGeneralRegistersPhase<LinearScanAllocator>>(); | 1416 Run<AllocateGeneralRegistersPhase<LinearScanAllocator>>(); |
| 1390 Run<AllocateDoubleRegistersPhase<LinearScanAllocator>>(); | 1417 Run<AllocateDoubleRegistersPhase<LinearScanAllocator>>(); |
| 1391 } | 1418 } |
| 1392 | 1419 |
| 1393 if (FLAG_turbo_preprocess_ranges) { | 1420 if (FLAG_turbo_preprocess_ranges) { |
| 1421 Run<MarkSpilledOnlyInDeferredPhase>(); | |
| 1394 Run<MergeSplintersPhase>(); | 1422 Run<MergeSplintersPhase>(); |
| 1395 } | 1423 } |
| 1396 | 1424 |
| 1397 if (FLAG_turbo_frame_elision) { | 1425 if (FLAG_turbo_frame_elision) { |
| 1398 Run<LocateSpillSlotsPhase>(); | 1426 Run<LocateSpillSlotsPhase>(); |
| 1399 Run<FrameElisionPhase>(); | 1427 Run<FrameElisionPhase>(); |
| 1400 } | 1428 } |
| 1401 | 1429 |
| 1402 Run<AssignSpillSlotsPhase>(); | 1430 Run<AssignSpillSlotsPhase>(); |
| 1403 | 1431 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1426 tcf << AsC1VRegisterAllocationData("CodeGen", | 1454 tcf << AsC1VRegisterAllocationData("CodeGen", |
| 1427 data->register_allocation_data()); | 1455 data->register_allocation_data()); |
| 1428 } | 1456 } |
| 1429 | 1457 |
| 1430 data->DeleteRegisterAllocationZone(); | 1458 data->DeleteRegisterAllocationZone(); |
| 1431 } | 1459 } |
| 1432 | 1460 |
| 1433 } // namespace compiler | 1461 } // namespace compiler |
| 1434 } // namespace internal | 1462 } // namespace internal |
| 1435 } // namespace v8 | 1463 } // namespace v8 |
| OLD | NEW |