| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_COMPILER_H_ | 28 #ifndef V8_COMPILER_H_ |
| 29 #define V8_COMPILER_H_ | 29 #define V8_COMPILER_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "ast.h" | 32 #include "ast.h" |
| 33 #include "time/elapsed-timer.h" | |
| 34 #include "zone.h" | 33 #include "zone.h" |
| 35 | 34 |
| 36 namespace v8 { | 35 namespace v8 { |
| 37 namespace internal { | 36 namespace internal { |
| 38 | 37 |
| 39 static const int kPrologueOffsetNotSet = -1; | 38 static const int kPrologueOffsetNotSet = -1; |
| 40 | 39 |
| 41 class ScriptDataImpl; | 40 class ScriptDataImpl; |
| 42 class HydrogenCodeStub; | 41 class HydrogenCodeStub; |
| 43 | 42 |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // fail, bail-out to the full code generator or succeed. Apart from | 494 // fail, bail-out to the full code generator or succeed. Apart from |
| 496 // their return value, the status of the phase last run can be checked | 495 // their return value, the status of the phase last run can be checked |
| 497 // using last_status(). | 496 // using last_status(). |
| 498 class OptimizingCompiler: public ZoneObject { | 497 class OptimizingCompiler: public ZoneObject { |
| 499 public: | 498 public: |
| 500 explicit OptimizingCompiler(CompilationInfo* info) | 499 explicit OptimizingCompiler(CompilationInfo* info) |
| 501 : info_(info), | 500 : info_(info), |
| 502 graph_builder_(NULL), | 501 graph_builder_(NULL), |
| 503 graph_(NULL), | 502 graph_(NULL), |
| 504 chunk_(NULL), | 503 chunk_(NULL), |
| 504 time_taken_to_create_graph_(0), |
| 505 time_taken_to_optimize_(0), |
| 506 time_taken_to_codegen_(0), |
| 505 last_status_(FAILED) { } | 507 last_status_(FAILED) { } |
| 506 | 508 |
| 507 enum Status { | 509 enum Status { |
| 508 FAILED, BAILED_OUT, SUCCEEDED | 510 FAILED, BAILED_OUT, SUCCEEDED |
| 509 }; | 511 }; |
| 510 | 512 |
| 511 MUST_USE_RESULT Status CreateGraph(); | 513 MUST_USE_RESULT Status CreateGraph(); |
| 512 MUST_USE_RESULT Status OptimizeGraph(); | 514 MUST_USE_RESULT Status OptimizeGraph(); |
| 513 MUST_USE_RESULT Status GenerateAndInstallCode(); | 515 MUST_USE_RESULT Status GenerateAndInstallCode(); |
| 514 | 516 |
| 515 Status last_status() const { return last_status_; } | 517 Status last_status() const { return last_status_; } |
| 516 CompilationInfo* info() const { return info_; } | 518 CompilationInfo* info() const { return info_; } |
| 517 Isolate* isolate() const { return info()->isolate(); } | 519 Isolate* isolate() const { return info()->isolate(); } |
| 518 | 520 |
| 519 MUST_USE_RESULT Status AbortOptimization() { | 521 MUST_USE_RESULT Status AbortOptimization() { |
| 520 info_->AbortOptimization(); | 522 info_->AbortOptimization(); |
| 521 info_->shared_info()->DisableOptimization(info_->bailout_reason()); | 523 info_->shared_info()->DisableOptimization(info_->bailout_reason()); |
| 522 return SetLastStatus(BAILED_OUT); | 524 return SetLastStatus(BAILED_OUT); |
| 523 } | 525 } |
| 524 | 526 |
| 525 private: | 527 private: |
| 526 CompilationInfo* info_; | 528 CompilationInfo* info_; |
| 527 HOptimizedGraphBuilder* graph_builder_; | 529 HOptimizedGraphBuilder* graph_builder_; |
| 528 HGraph* graph_; | 530 HGraph* graph_; |
| 529 LChunk* chunk_; | 531 LChunk* chunk_; |
| 530 TimeDelta time_taken_to_create_graph_; | 532 int64_t time_taken_to_create_graph_; |
| 531 TimeDelta time_taken_to_optimize_; | 533 int64_t time_taken_to_optimize_; |
| 532 TimeDelta time_taken_to_codegen_; | 534 int64_t time_taken_to_codegen_; |
| 533 Status last_status_; | 535 Status last_status_; |
| 534 | 536 |
| 535 MUST_USE_RESULT Status SetLastStatus(Status status) { | 537 MUST_USE_RESULT Status SetLastStatus(Status status) { |
| 536 last_status_ = status; | 538 last_status_ = status; |
| 537 return last_status_; | 539 return last_status_; |
| 538 } | 540 } |
| 539 void RecordOptimizationStats(); | 541 void RecordOptimizationStats(); |
| 540 | 542 |
| 541 struct Timer { | 543 struct Timer { |
| 542 Timer(OptimizingCompiler* compiler, TimeDelta* location) | 544 Timer(OptimizingCompiler* compiler, int64_t* location) |
| 543 : compiler_(compiler), | 545 : compiler_(compiler), |
| 544 location_(location) { | 546 start_(OS::Ticks()), |
| 545 ASSERT(location_ != NULL); | 547 location_(location) { } |
| 546 timer_.Start(); | |
| 547 } | |
| 548 | 548 |
| 549 ~Timer() { | 549 ~Timer() { |
| 550 *location_ += timer_.Elapsed(); | 550 *location_ += (OS::Ticks() - start_); |
| 551 } | 551 } |
| 552 | 552 |
| 553 OptimizingCompiler* compiler_; | 553 OptimizingCompiler* compiler_; |
| 554 ElapsedTimer timer_; | 554 int64_t start_; |
| 555 TimeDelta* location_; | 555 int64_t* location_; |
| 556 }; | 556 }; |
| 557 }; | 557 }; |
| 558 | 558 |
| 559 | 559 |
| 560 // The V8 compiler | 560 // The V8 compiler |
| 561 // | 561 // |
| 562 // General strategy: Source code is translated into an anonymous function w/o | 562 // General strategy: Source code is translated into an anonymous function w/o |
| 563 // parameters which then can be executed. If the source code contains other | 563 // parameters which then can be executed. If the source code contains other |
| 564 // functions, they will be compiled and allocated as part of the compilation | 564 // functions, they will be compiled and allocated as part of the compilation |
| 565 // of the source code. | 565 // of the source code. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 const char* name() const { return name_; } | 637 const char* name() const { return name_; } |
| 638 CompilationInfo* info() const { return info_; } | 638 CompilationInfo* info() const { return info_; } |
| 639 Isolate* isolate() const { return info()->isolate(); } | 639 Isolate* isolate() const { return info()->isolate(); } |
| 640 Zone* zone() { return &zone_; } | 640 Zone* zone() { return &zone_; } |
| 641 | 641 |
| 642 private: | 642 private: |
| 643 const char* name_; | 643 const char* name_; |
| 644 CompilationInfo* info_; | 644 CompilationInfo* info_; |
| 645 Zone zone_; | 645 Zone zone_; |
| 646 unsigned info_zone_start_allocation_size_; | 646 unsigned info_zone_start_allocation_size_; |
| 647 ElapsedTimer timer_; | 647 int64_t start_ticks_; |
| 648 | 648 |
| 649 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 649 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
| 650 }; | 650 }; |
| 651 | 651 |
| 652 | 652 |
| 653 } } // namespace v8::internal | 653 } } // namespace v8::internal |
| 654 | 654 |
| 655 #endif // V8_COMPILER_H_ | 655 #endif // V8_COMPILER_H_ |
| OLD | NEW |