| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_COMPILER_H_ | 5 #ifndef V8_COMPILER_H_ |
| 6 #define V8_COMPILER_H_ | 6 #define V8_COMPILER_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 561 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
| 562 }; | 562 }; |
| 563 | 563 |
| 564 // A base class for compilation jobs intended to run concurrent to the main | 564 // A base class for compilation jobs intended to run concurrent to the main |
| 565 // thread. The job is split into three phases which are called in sequence on | 565 // thread. The job is split into three phases which are called in sequence on |
| 566 // different threads and with different limitations: | 566 // different threads and with different limitations: |
| 567 // 1) CreateGraph: Runs on main thread. No major limitations. | 567 // 1) CreateGraph: Runs on main thread. No major limitations. |
| 568 // 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs. | 568 // 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs. |
| 569 // 3) GenerateCode: Runs on main thread. No dependency changes. | 569 // 3) GenerateCode: Runs on main thread. No dependency changes. |
| 570 // | 570 // |
| 571 // Each of the three phases can either fail, bail-out to full code generator or | 571 // Each of the three phases can either fail or succeed. Apart from their return |
| 572 // succeed. Apart from their return value, the status of the phase last run can | 572 // value, the status of the phase last run can be checked using {last_status()} |
| 573 // be checked using {last_status()} as well. | 573 // as well. When failing we distinguish between the following levels: |
| 574 // a) AbortOptimization: Persistent failure, disable future optimization. |
| 575 // b) RetryOptimzation: Transient failure, try again next time. |
| 574 // TODO(mstarzinger): Make CompilationInfo base embedded. | 576 // TODO(mstarzinger): Make CompilationInfo base embedded. |
| 575 class CompilationJob { | 577 class CompilationJob { |
| 576 public: | 578 public: |
| 577 explicit CompilationJob(CompilationInfo* info, const char* compiler_name) | 579 explicit CompilationJob(CompilationInfo* info, const char* compiler_name) |
| 578 : info_(info), compiler_name_(compiler_name), last_status_(SUCCEEDED) {} | 580 : info_(info), compiler_name_(compiler_name), last_status_(SUCCEEDED) {} |
| 579 virtual ~CompilationJob() {} | 581 virtual ~CompilationJob() {} |
| 580 | 582 |
| 581 enum Status { | 583 enum Status { FAILED, SUCCEEDED }; |
| 582 FAILED, BAILED_OUT, SUCCEEDED | |
| 583 }; | |
| 584 | 584 |
| 585 MUST_USE_RESULT Status CreateGraph(); | 585 MUST_USE_RESULT Status CreateGraph(); |
| 586 MUST_USE_RESULT Status OptimizeGraph(); | 586 MUST_USE_RESULT Status OptimizeGraph(); |
| 587 MUST_USE_RESULT Status GenerateCode(); | 587 MUST_USE_RESULT Status GenerateCode(); |
| 588 | 588 |
| 589 Status last_status() const { return last_status_; } | 589 Status last_status() const { return last_status_; } |
| 590 CompilationInfo* info() const { return info_; } | 590 CompilationInfo* info() const { return info_; } |
| 591 Isolate* isolate() const { return info()->isolate(); } | 591 Isolate* isolate() const { return info()->isolate(); } |
| 592 | 592 |
| 593 Status RetryOptimization(BailoutReason reason) { | 593 Status RetryOptimization(BailoutReason reason) { |
| 594 info_->RetryOptimization(reason); | 594 info_->RetryOptimization(reason); |
| 595 return SetLastStatus(BAILED_OUT); | 595 return SetLastStatus(FAILED); |
| 596 } | 596 } |
| 597 | 597 |
| 598 Status AbortOptimization(BailoutReason reason) { | 598 Status AbortOptimization(BailoutReason reason) { |
| 599 info_->AbortOptimization(reason); | 599 info_->AbortOptimization(reason); |
| 600 return SetLastStatus(BAILED_OUT); | 600 return SetLastStatus(FAILED); |
| 601 } | 601 } |
| 602 | 602 |
| 603 void RecordOptimizationStats(); | 603 void RecordOptimizationStats(); |
| 604 | 604 |
| 605 protected: | 605 protected: |
| 606 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code); | 606 void RegisterWeakObjectsInOptimizedCode(Handle<Code> code); |
| 607 | 607 |
| 608 // Overridden by the actual implementation. | 608 // Overridden by the actual implementation. |
| 609 virtual Status CreateGraphImpl() = 0; | 609 virtual Status CreateGraphImpl() = 0; |
| 610 virtual Status OptimizeGraphImpl() = 0; | 610 virtual Status OptimizeGraphImpl() = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 621 MUST_USE_RESULT Status SetLastStatus(Status status) { | 621 MUST_USE_RESULT Status SetLastStatus(Status status) { |
| 622 last_status_ = status; | 622 last_status_ = status; |
| 623 return last_status_; | 623 return last_status_; |
| 624 } | 624 } |
| 625 }; | 625 }; |
| 626 | 626 |
| 627 } // namespace internal | 627 } // namespace internal |
| 628 } // namespace v8 | 628 } // namespace v8 |
| 629 | 629 |
| 630 #endif // V8_COMPILER_H_ | 630 #endif // V8_COMPILER_H_ |
| OLD | NEW |