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.h" | 9 #include "src/ast.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
11 #include "src/compilation-dependencies.h" | 11 #include "src/compilation-dependencies.h" |
12 #include "src/zone.h" | 12 #include "src/zone.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
| 17 // Forward declarations. |
17 class AstValueFactory; | 18 class AstValueFactory; |
18 class HydrogenCodeStub; | 19 class HydrogenCodeStub; |
19 class ParseInfo; | 20 class ParseInfo; |
20 class ScriptData; | 21 class ScriptData; |
21 | 22 |
| 23 namespace compiler { |
| 24 |
| 25 // Forward declarations. |
| 26 class Pipeline; |
| 27 |
| 28 } // namespace compiler |
| 29 |
| 30 |
22 struct OffsetRange { | 31 struct OffsetRange { |
23 OffsetRange(int from, int to) : from(from), to(to) {} | 32 OffsetRange(int from, int to) : from(from), to(to) {} |
24 int from; | 33 int from; |
25 int to; | 34 int to; |
26 }; | 35 }; |
27 | 36 |
28 | 37 |
29 // This class encapsulates encoding and decoding of sources positions from | 38 // This class encapsulates encoding and decoding of sources positions from |
30 // which hydrogen values originated. | 39 // which hydrogen values originated. |
31 // When FLAG_track_hydrogen_positions is set this object encodes the | 40 // When FLAG_track_hydrogen_positions is set this object encodes the |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // A helper class that calls the three compilation phases in | 516 // A helper class that calls the three compilation phases in |
508 // Crankshaft and keeps track of its state. The three phases | 517 // Crankshaft and keeps track of its state. The three phases |
509 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either | 518 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either |
510 // fail, bail-out to the full code generator or succeed. Apart from | 519 // fail, bail-out to the full code generator or succeed. Apart from |
511 // their return value, the status of the phase last run can be checked | 520 // their return value, the status of the phase last run can be checked |
512 // using last_status(). | 521 // using last_status(). |
513 class OptimizedCompileJob: public ZoneObject { | 522 class OptimizedCompileJob: public ZoneObject { |
514 public: | 523 public: |
515 explicit OptimizedCompileJob(CompilationInfo* info) | 524 explicit OptimizedCompileJob(CompilationInfo* info) |
516 : info_(info), | 525 : info_(info), |
| 526 pipeline_(nullptr), |
517 graph_builder_(NULL), | 527 graph_builder_(NULL), |
518 graph_(NULL), | 528 graph_(NULL), |
519 chunk_(NULL), | 529 chunk_(NULL), |
520 last_status_(FAILED), | 530 last_status_(FAILED), |
521 awaiting_install_(false) { } | 531 awaiting_install_(false) {} |
| 532 ~OptimizedCompileJob(); |
522 | 533 |
523 enum Status { | 534 enum Status { |
524 FAILED, BAILED_OUT, SUCCEEDED | 535 FAILED, BAILED_OUT, SUCCEEDED |
525 }; | 536 }; |
526 | 537 |
527 MUST_USE_RESULT Status CreateGraph(); | 538 MUST_USE_RESULT Status CreateGraph(); |
528 MUST_USE_RESULT Status OptimizeGraph(); | 539 MUST_USE_RESULT Status OptimizeGraph(); |
529 MUST_USE_RESULT Status GenerateCode(); | 540 MUST_USE_RESULT Status GenerateCode(); |
530 | 541 |
531 Status last_status() const { return last_status_; } | 542 Status last_status() const { return last_status_; } |
532 CompilationInfo* info() const { return info_; } | 543 CompilationInfo* info() const { return info_; } |
| 544 compiler::Pipeline* pipeline() const { return pipeline_; } |
533 Isolate* isolate() const { return info()->isolate(); } | 545 Isolate* isolate() const { return info()->isolate(); } |
534 | 546 |
535 Status RetryOptimization(BailoutReason reason) { | 547 Status RetryOptimization(BailoutReason reason) { |
536 info_->RetryOptimization(reason); | 548 info_->RetryOptimization(reason); |
537 return SetLastStatus(BAILED_OUT); | 549 return SetLastStatus(BAILED_OUT); |
538 } | 550 } |
539 | 551 |
540 Status AbortOptimization(BailoutReason reason) { | 552 Status AbortOptimization(BailoutReason reason) { |
541 info_->AbortOptimization(reason); | 553 info_->AbortOptimization(reason); |
542 return SetLastStatus(BAILED_OUT); | 554 return SetLastStatus(BAILED_OUT); |
543 } | 555 } |
544 | 556 |
545 void WaitForInstall() { | 557 void WaitForInstall() { |
546 DCHECK(info_->is_osr()); | 558 DCHECK(info_->is_osr()); |
547 awaiting_install_ = true; | 559 awaiting_install_ = true; |
548 } | 560 } |
549 | 561 |
550 bool IsWaitingForInstall() { return awaiting_install_; } | 562 bool IsWaitingForInstall() { return awaiting_install_; } |
551 | 563 |
552 private: | 564 private: |
553 CompilationInfo* info_; | 565 CompilationInfo* const info_; |
| 566 compiler::Pipeline* pipeline_; |
554 HOptimizedGraphBuilder* graph_builder_; | 567 HOptimizedGraphBuilder* graph_builder_; |
555 HGraph* graph_; | 568 HGraph* graph_; |
556 LChunk* chunk_; | 569 LChunk* chunk_; |
557 base::TimeDelta time_taken_to_create_graph_; | 570 base::TimeDelta time_taken_to_create_graph_; |
558 base::TimeDelta time_taken_to_optimize_; | 571 base::TimeDelta time_taken_to_optimize_; |
559 base::TimeDelta time_taken_to_codegen_; | 572 base::TimeDelta time_taken_to_codegen_; |
560 Status last_status_; | 573 Status last_status_; |
561 bool awaiting_install_; | 574 bool awaiting_install_; |
562 | 575 |
563 MUST_USE_RESULT Status SetLastStatus(Status status) { | 576 MUST_USE_RESULT Status SetLastStatus(Status status) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 Zone zone_; | 695 Zone zone_; |
683 size_t info_zone_start_allocation_size_; | 696 size_t info_zone_start_allocation_size_; |
684 base::ElapsedTimer timer_; | 697 base::ElapsedTimer timer_; |
685 | 698 |
686 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 699 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
687 }; | 700 }; |
688 | 701 |
689 } } // namespace v8::internal | 702 } } // namespace v8::internal |
690 | 703 |
691 #endif // V8_COMPILER_H_ | 704 #endif // V8_COMPILER_H_ |
OLD | NEW |