| 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/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // TODO(turbofan): Make OSR work and remove this bailout. | 150 // TODO(turbofan): Make OSR work and remove this bailout. |
| 151 info()->is_osr()) { | 151 info()->is_osr()) { |
| 152 return Handle<Code>::null(); | 152 return Handle<Code>::null(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 ZonePool zone_pool(isolate()); | 155 ZonePool zone_pool(isolate()); |
| 156 | 156 |
| 157 SmartPointer<PipelineStatistics> pipeline_statistics; | 157 SmartPointer<PipelineStatistics> pipeline_statistics; |
| 158 if (FLAG_turbo_stats) { | 158 if (FLAG_turbo_stats) { |
| 159 pipeline_statistics.Reset(new PipelineStatistics(info(), &zone_pool)); | 159 pipeline_statistics.Reset(new PipelineStatistics(info(), &zone_pool)); |
| 160 pipeline_statistics->BeginPhaseKind("create graph"); | 160 pipeline_statistics->BeginPhaseKind("graph creation"); |
| 161 } | 161 } |
| 162 | 162 |
| 163 if (FLAG_trace_turbo) { | 163 if (FLAG_trace_turbo) { |
| 164 OFStream os(stdout); | 164 OFStream os(stdout); |
| 165 os << "---------------------------------------------------\n" | 165 os << "---------------------------------------------------\n" |
| 166 << "Begin compiling method " | 166 << "Begin compiling method " |
| 167 << info()->function()->debug_name()->ToCString().get() | 167 << info()->function()->debug_name()->ToCString().get() |
| 168 << " using Turbofan" << std::endl; | 168 << " using Turbofan" << std::endl; |
| 169 TurboCfgFile tcf(isolate()); | 169 TurboCfgFile tcf(isolate()); |
| 170 tcf << AsC1VCompilation(info()); | 170 tcf << AsC1VCompilation(info()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 JSGenericLowering lowering(info(), &jsgraph); | 319 JSGenericLowering lowering(info(), &jsgraph); |
| 320 GraphReducer graph_reducer(&graph); | 320 GraphReducer graph_reducer(&graph); |
| 321 graph_reducer.AddReducer(&lowering); | 321 graph_reducer.AddReducer(&lowering); |
| 322 graph_reducer.ReduceGraph(); | 322 graph_reducer.ReduceGraph(); |
| 323 | 323 |
| 324 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 324 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 325 VerifyAndPrintGraph(&graph, "Lowered generic", true); | 325 VerifyAndPrintGraph(&graph, "Lowered generic", true); |
| 326 } | 326 } |
| 327 | 327 |
| 328 if (!pipeline_statistics.is_empty()) { | 328 if (!pipeline_statistics.is_empty()) { |
| 329 pipeline_statistics->BeginPhaseKind("code generation"); | 329 pipeline_statistics->BeginPhaseKind("block building"); |
| 330 } | 330 } |
| 331 | 331 |
| 332 source_positions.RemoveDecorator(); | 332 source_positions.RemoveDecorator(); |
| 333 | 333 |
| 334 Schedule* schedule; | 334 Schedule* schedule; |
| 335 { | 335 { |
| 336 PhaseScope phase_scope(pipeline_statistics.get(), "scheduling"); | 336 PhaseScope phase_scope(pipeline_statistics.get(), "scheduling"); |
| 337 // Compute a schedule. | 337 // Compute a schedule. |
| 338 schedule = ComputeSchedule(&zone_pool, &graph); | 338 schedule = ComputeSchedule(&zone_pool, &graph); |
| 339 } | 339 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 423 } |
| 424 | 424 |
| 425 if (FLAG_trace_turbo) { | 425 if (FLAG_trace_turbo) { |
| 426 OFStream os(stdout); | 426 OFStream os(stdout); |
| 427 os << "----- Instruction sequence before register allocation -----\n" | 427 os << "----- Instruction sequence before register allocation -----\n" |
| 428 << sequence; | 428 << sequence; |
| 429 TurboCfgFile tcf(isolate()); | 429 TurboCfgFile tcf(isolate()); |
| 430 tcf << AsC1V("CodeGen", schedule, source_positions, &sequence); | 430 tcf << AsC1V("CodeGen", schedule, source_positions, &sequence); |
| 431 } | 431 } |
| 432 | 432 |
| 433 if (pipeline_statistics != NULL) { |
| 434 pipeline_statistics->BeginPhaseKind("register allocation"); |
| 435 } |
| 436 |
| 433 // Allocate registers. | 437 // Allocate registers. |
| 434 Frame frame; | 438 Frame frame; |
| 435 { | 439 { |
| 436 int node_count = graph->NodeCount(); | 440 int node_count = graph->NodeCount(); |
| 437 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { | 441 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { |
| 438 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); | 442 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); |
| 439 return Handle<Code>::null(); | 443 return Handle<Code>::null(); |
| 440 } | 444 } |
| 441 ZonePool::Scope zone_scope(zone_pool); | 445 ZonePool::Scope zone_scope(zone_pool); |
| 442 RegisterAllocator allocator(zone_scope.zone(), &frame, linkage->info(), | 446 RegisterAllocator allocator(zone_scope.zone(), &frame, linkage->info(), |
| 443 &sequence); | 447 &sequence); |
| 444 if (!allocator.Allocate(pipeline_statistics)) { | 448 if (!allocator.Allocate(pipeline_statistics)) { |
| 445 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | 449 linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
| 446 return Handle<Code>::null(); | 450 return Handle<Code>::null(); |
| 447 } | 451 } |
| 448 if (FLAG_trace_turbo) { | 452 if (FLAG_trace_turbo) { |
| 449 TurboCfgFile tcf(isolate()); | 453 TurboCfgFile tcf(isolate()); |
| 450 tcf << AsC1VAllocator("CodeGen", &allocator); | 454 tcf << AsC1VAllocator("CodeGen", &allocator); |
| 451 } | 455 } |
| 452 } | 456 } |
| 453 | 457 |
| 454 if (FLAG_trace_turbo) { | 458 if (FLAG_trace_turbo) { |
| 455 OFStream os(stdout); | 459 OFStream os(stdout); |
| 456 os << "----- Instruction sequence after register allocation -----\n" | 460 os << "----- Instruction sequence after register allocation -----\n" |
| 457 << sequence; | 461 << sequence; |
| 458 } | 462 } |
| 459 | 463 |
| 464 if (pipeline_statistics != NULL) { |
| 465 pipeline_statistics->BeginPhaseKind("code generation"); |
| 466 } |
| 467 |
| 460 // Generate native sequence. | 468 // Generate native sequence. |
| 461 Handle<Code> code; | 469 Handle<Code> code; |
| 462 { | 470 { |
| 463 PhaseScope phase_scope(pipeline_statistics, "generate code"); | 471 PhaseScope phase_scope(pipeline_statistics, "generate code"); |
| 464 CodeGenerator generator(&frame, linkage, &sequence); | 472 CodeGenerator generator(&frame, linkage, &sequence); |
| 465 code = generator.GenerateCode(); | 473 code = generator.GenerateCode(); |
| 466 } | 474 } |
| 467 if (profiler_data != NULL) { | 475 if (profiler_data != NULL) { |
| 468 #if ENABLE_DISASSEMBLER | 476 #if ENABLE_DISASSEMBLER |
| 469 std::ostringstream os; | 477 std::ostringstream os; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 480 } | 488 } |
| 481 | 489 |
| 482 | 490 |
| 483 void Pipeline::TearDown() { | 491 void Pipeline::TearDown() { |
| 484 InstructionOperand::TearDownCaches(); | 492 InstructionOperand::TearDownCaches(); |
| 485 } | 493 } |
| 486 | 494 |
| 487 } // namespace compiler | 495 } // namespace compiler |
| 488 } // namespace internal | 496 } // namespace internal |
| 489 } // namespace v8 | 497 } // namespace v8 |
| OLD | NEW |