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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 496 |
497 // A helper class that calls the three compilation phases in | 497 // A helper class that calls the three compilation phases in |
498 // Crankshaft and keeps track of its state. The three phases | 498 // Crankshaft and keeps track of its state. The three phases |
499 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either | 499 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either |
500 // fail, bail-out to the full code generator or succeed. Apart from | 500 // fail, bail-out to the full code generator or succeed. Apart from |
501 // their return value, the status of the phase last run can be checked | 501 // their return value, the status of the phase last run can be checked |
502 // using last_status(). | 502 // using last_status(). |
503 class OptimizedCompileJob: public ZoneObject { | 503 class OptimizedCompileJob: public ZoneObject { |
504 public: | 504 public: |
505 explicit OptimizedCompileJob(CompilationInfo* info) | 505 explicit OptimizedCompileJob(CompilationInfo* info) |
506 : info_(info), | 506 : info_(info), graph_(NULL), chunk_(NULL), last_status_(FAILED) {} |
507 graph_(NULL), | |
508 chunk_(NULL), | |
509 last_status_(FAILED), | |
510 awaiting_install_(false) { } | |
511 | 507 |
512 enum Status { | 508 enum Status { |
513 FAILED, BAILED_OUT, SUCCEEDED | 509 FAILED, BAILED_OUT, SUCCEEDED |
514 }; | 510 }; |
515 | 511 |
516 MUST_USE_RESULT Status CreateGraph(); | 512 MUST_USE_RESULT Status CreateGraph(); |
517 MUST_USE_RESULT Status OptimizeGraph(); | 513 MUST_USE_RESULT Status OptimizeGraph(); |
518 MUST_USE_RESULT Status GenerateCode(); | 514 MUST_USE_RESULT Status GenerateCode(); |
519 | 515 |
520 Status last_status() const { return last_status_; } | 516 Status last_status() const { return last_status_; } |
521 CompilationInfo* info() const { return info_; } | 517 CompilationInfo* info() const { return info_; } |
522 Isolate* isolate() const { return info()->isolate(); } | 518 Isolate* isolate() const { return info()->isolate(); } |
523 | 519 |
524 Status RetryOptimization(BailoutReason reason) { | 520 Status RetryOptimization(BailoutReason reason) { |
525 info_->RetryOptimization(reason); | 521 info_->RetryOptimization(reason); |
526 return SetLastStatus(BAILED_OUT); | 522 return SetLastStatus(BAILED_OUT); |
527 } | 523 } |
528 | 524 |
529 Status AbortOptimization(BailoutReason reason) { | 525 Status AbortOptimization(BailoutReason reason) { |
530 info_->AbortOptimization(reason); | 526 info_->AbortOptimization(reason); |
531 return SetLastStatus(BAILED_OUT); | 527 return SetLastStatus(BAILED_OUT); |
532 } | 528 } |
533 | 529 |
534 void WaitForInstall() { | |
535 DCHECK(info_->is_osr()); | |
536 awaiting_install_ = true; | |
537 } | |
538 | |
539 bool IsWaitingForInstall() { return awaiting_install_; } | |
540 | |
541 private: | 530 private: |
542 CompilationInfo* info_; | 531 CompilationInfo* info_; |
543 HGraph* graph_; | 532 HGraph* graph_; |
544 LChunk* chunk_; | 533 LChunk* chunk_; |
545 base::TimeDelta time_taken_to_create_graph_; | 534 base::TimeDelta time_taken_to_create_graph_; |
546 base::TimeDelta time_taken_to_optimize_; | 535 base::TimeDelta time_taken_to_optimize_; |
547 base::TimeDelta time_taken_to_codegen_; | 536 base::TimeDelta time_taken_to_codegen_; |
548 Status last_status_; | 537 Status last_status_; |
549 bool awaiting_install_; | |
550 | 538 |
551 MUST_USE_RESULT Status SetLastStatus(Status status) { | 539 MUST_USE_RESULT Status SetLastStatus(Status status) { |
552 last_status_ = status; | 540 last_status_ = status; |
553 return last_status_; | 541 return last_status_; |
554 } | 542 } |
555 void RecordOptimizationStats(); | 543 void RecordOptimizationStats(); |
556 | 544 |
557 struct Timer { | 545 struct Timer { |
558 Timer(OptimizedCompileJob* job, base::TimeDelta* location) | 546 Timer(OptimizedCompileJob* job, base::TimeDelta* location) |
559 : job_(job), location_(location) { | 547 : job_(job), location_(location) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 // The following family of methods provides support for OSR. Code generated | 635 // The following family of methods provides support for OSR. Code generated |
648 // for entry via OSR might not be suitable for normal entry, hence will be | 636 // for entry via OSR might not be suitable for normal entry, hence will be |
649 // returned directly to the caller. | 637 // returned directly to the caller. |
650 // | 638 // |
651 // Please note this interface is the only part dealing with {Code} objects | 639 // Please note this interface is the only part dealing with {Code} objects |
652 // directly. Other methods are agnostic to {Code} and can use an interpreter | 640 // directly. Other methods are agnostic to {Code} and can use an interpreter |
653 // instead of generating JIT code for a function at all. | 641 // instead of generating JIT code for a function at all. |
654 | 642 |
655 // Generate and return optimized code for OSR, or empty handle on failure. | 643 // Generate and return optimized code for OSR, or empty handle on failure. |
656 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCodeForOSR( | 644 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCodeForOSR( |
657 Handle<JSFunction> function, ConcurrencyMode mode, BailoutId osr_ast_id, | 645 Handle<JSFunction> function, BailoutId osr_ast_id, |
658 JavaScriptFrame* osr_frame); | 646 JavaScriptFrame* osr_frame); |
659 | 647 |
660 // Generate and return code from previously queued optimization job. | 648 // Generate and return code from previously queued optimization job. |
661 // On failure, return the empty handle. | 649 // On failure, return the empty handle. |
662 MUST_USE_RESULT static MaybeHandle<Code> GetConcurrentlyOptimizedCode( | 650 MUST_USE_RESULT static MaybeHandle<Code> GetConcurrentlyOptimizedCode( |
663 OptimizedCompileJob* job); | 651 OptimizedCompileJob* job); |
664 }; | 652 }; |
665 | 653 |
666 } // namespace internal | 654 } // namespace internal |
667 } // namespace v8 | 655 } // namespace v8 |
668 | 656 |
669 #endif // V8_COMPILER_H_ | 657 #endif // V8_COMPILER_H_ |
OLD | NEW |