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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 phase_name), | 469 phase_name), |
470 zone_scope_(data->zone_pool()) {} | 470 zone_scope_(data->zone_pool()) {} |
471 | 471 |
472 Zone* zone() { return zone_scope_.zone(); } | 472 Zone* zone() { return zone_scope_.zone(); } |
473 | 473 |
474 private: | 474 private: |
475 PhaseScope phase_scope_; | 475 PhaseScope phase_scope_; |
476 ZonePool::Scope zone_scope_; | 476 ZonePool::Scope zone_scope_; |
477 }; | 477 }; |
478 | 478 |
| 479 class PipelineCompilationJob : public OptimizedCompileJob { |
| 480 public: |
| 481 explicit PipelineCompilationJob(CompilationInfo* info) |
| 482 : OptimizedCompileJob(info) {} |
| 483 |
| 484 protected: |
| 485 virtual Status CreateGraphImpl(); |
| 486 virtual Status OptimizeGraphImpl(); |
| 487 virtual Status GenerateCodeImpl(); |
| 488 }; |
| 489 |
| 490 PipelineCompilationJob::Status PipelineCompilationJob::CreateGraphImpl() { |
| 491 if (FLAG_trace_opt) { |
| 492 OFStream os(stdout); |
| 493 os << "[compiling method " << Brief(*info()->closure()) |
| 494 << " using TurboFan"; |
| 495 if (info()->is_osr()) os << " OSR"; |
| 496 os << "]" << std::endl; |
| 497 } |
| 498 |
| 499 if (info()->shared_info()->asm_function()) { |
| 500 if (info()->osr_frame()) info()->MarkAsFrameSpecializing(); |
| 501 info()->MarkAsFunctionContextSpecializing(); |
| 502 } else { |
| 503 if (!FLAG_always_opt) { |
| 504 info()->MarkAsBailoutOnUninitialized(); |
| 505 } |
| 506 if (FLAG_native_context_specialization) { |
| 507 info()->MarkAsNativeContextSpecializing(); |
| 508 info()->MarkAsTypingEnabled(); |
| 509 } |
| 510 } |
| 511 if (!info()->shared_info()->asm_function() || FLAG_turbo_asm_deoptimization) { |
| 512 info()->MarkAsDeoptimizationEnabled(); |
| 513 } |
| 514 |
| 515 Pipeline pipeline(info()); |
| 516 pipeline.GenerateCode(); |
| 517 if (info()->code().is_null()) return BAILED_OUT; |
| 518 |
| 519 return SUCCEEDED; |
| 520 } |
| 521 |
| 522 PipelineCompilationJob::Status PipelineCompilationJob::OptimizeGraphImpl() { |
| 523 // TODO(turbofan): Currently everything is done in the first phase. |
| 524 DCHECK(!info()->code().is_null()); |
| 525 return SUCCEEDED; |
| 526 } |
| 527 |
| 528 PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() { |
| 529 // TODO(turbofan): Currently everything is done in the first phase. |
| 530 DCHECK(!info()->code().is_null()); |
| 531 info()->dependencies()->Commit(info()->code()); |
| 532 if (info()->is_deoptimization_enabled()) { |
| 533 info()->context()->native_context()->AddOptimizedCode(*info()->code()); |
| 534 RegisterWeakObjectsInOptimizedCode(info()->code()); |
| 535 } |
| 536 return SUCCEEDED; |
| 537 } |
| 538 |
479 } // namespace | 539 } // namespace |
480 | 540 |
481 | 541 |
482 template <typename Phase> | 542 template <typename Phase> |
483 void Pipeline::Run() { | 543 void Pipeline::Run() { |
484 PipelineRunScope scope(this->data_, Phase::phase_name()); | 544 PipelineRunScope scope(this->data_, Phase::phase_name()); |
485 Phase phase; | 545 Phase phase; |
486 phase.Run(this->data_, scope.zone()); | 546 phase.Run(this->data_, scope.zone()); |
487 } | 547 } |
488 | 548 |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 Pipeline pipeline(info); | 1366 Pipeline pipeline(info); |
1307 pipeline.data_ = &data; | 1367 pipeline.data_ = &data; |
1308 if (data.schedule() == nullptr) { | 1368 if (data.schedule() == nullptr) { |
1309 // TODO(rossberg): Should this really be untyped? | 1369 // TODO(rossberg): Should this really be untyped? |
1310 pipeline.RunPrintAndVerify("Machine", true); | 1370 pipeline.RunPrintAndVerify("Machine", true); |
1311 } | 1371 } |
1312 | 1372 |
1313 return pipeline.ScheduleAndGenerateCode(call_descriptor); | 1373 return pipeline.ScheduleAndGenerateCode(call_descriptor); |
1314 } | 1374 } |
1315 | 1375 |
| 1376 OptimizedCompileJob* Pipeline::NewCompilationJob(CompilationInfo* info) { |
| 1377 return new (info->zone()) PipelineCompilationJob(info); |
| 1378 } |
1316 | 1379 |
1317 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, | 1380 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, |
1318 InstructionSequence* sequence, | 1381 InstructionSequence* sequence, |
1319 bool run_verifier) { | 1382 bool run_verifier) { |
1320 CompilationInfo info("testing", sequence->isolate(), sequence->zone()); | 1383 CompilationInfo info("testing", sequence->isolate(), sequence->zone()); |
1321 ZonePool zone_pool(sequence->isolate()->allocator()); | 1384 ZonePool zone_pool(sequence->isolate()->allocator()); |
1322 PipelineData data(&zone_pool, &info, sequence); | 1385 PipelineData data(&zone_pool, &info, sequence); |
1323 Pipeline pipeline(&info); | 1386 Pipeline pipeline(&info); |
1324 pipeline.data_ = &data; | 1387 pipeline.data_ = &data; |
1325 pipeline.data_->InitializeFrameData(nullptr); | 1388 pipeline.data_->InitializeFrameData(nullptr); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 } | 1584 } |
1522 | 1585 |
1523 data->DeleteRegisterAllocationZone(); | 1586 data->DeleteRegisterAllocationZone(); |
1524 } | 1587 } |
1525 | 1588 |
1526 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1589 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
1527 | 1590 |
1528 } // namespace compiler | 1591 } // namespace compiler |
1529 } // namespace internal | 1592 } // namespace internal |
1530 } // namespace v8 | 1593 } // namespace v8 |
OLD | NEW |