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" |
33 #include "zone.h" | 34 #include "zone.h" |
34 | 35 |
35 namespace v8 { | 36 namespace v8 { |
36 namespace internal { | 37 namespace internal { |
37 | 38 |
38 static const int kPrologueOffsetNotSet = -1; | 39 static const int kPrologueOffsetNotSet = -1; |
39 | 40 |
40 class ScriptDataImpl; | 41 class ScriptDataImpl; |
41 class HydrogenCodeStub; | 42 class HydrogenCodeStub; |
42 | 43 |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 // fail, bail-out to the full code generator or succeed. Apart from | 495 // fail, bail-out to the full code generator or succeed. Apart from |
495 // their return value, the status of the phase last run can be checked | 496 // their return value, the status of the phase last run can be checked |
496 // using last_status(). | 497 // using last_status(). |
497 class OptimizingCompiler: public ZoneObject { | 498 class OptimizingCompiler: public ZoneObject { |
498 public: | 499 public: |
499 explicit OptimizingCompiler(CompilationInfo* info) | 500 explicit OptimizingCompiler(CompilationInfo* info) |
500 : info_(info), | 501 : info_(info), |
501 graph_builder_(NULL), | 502 graph_builder_(NULL), |
502 graph_(NULL), | 503 graph_(NULL), |
503 chunk_(NULL), | 504 chunk_(NULL), |
504 time_taken_to_create_graph_(0), | |
505 time_taken_to_optimize_(0), | |
506 time_taken_to_codegen_(0), | |
507 last_status_(FAILED) { } | 505 last_status_(FAILED) { } |
508 | 506 |
509 enum Status { | 507 enum Status { |
510 FAILED, BAILED_OUT, SUCCEEDED | 508 FAILED, BAILED_OUT, SUCCEEDED |
511 }; | 509 }; |
512 | 510 |
513 MUST_USE_RESULT Status CreateGraph(); | 511 MUST_USE_RESULT Status CreateGraph(); |
514 MUST_USE_RESULT Status OptimizeGraph(); | 512 MUST_USE_RESULT Status OptimizeGraph(); |
515 MUST_USE_RESULT Status GenerateAndInstallCode(); | 513 MUST_USE_RESULT Status GenerateAndInstallCode(); |
516 | 514 |
517 Status last_status() const { return last_status_; } | 515 Status last_status() const { return last_status_; } |
518 CompilationInfo* info() const { return info_; } | 516 CompilationInfo* info() const { return info_; } |
519 Isolate* isolate() const { return info()->isolate(); } | 517 Isolate* isolate() const { return info()->isolate(); } |
520 | 518 |
521 MUST_USE_RESULT Status AbortOptimization() { | 519 MUST_USE_RESULT Status AbortOptimization() { |
522 info_->AbortOptimization(); | 520 info_->AbortOptimization(); |
523 info_->shared_info()->DisableOptimization(info_->bailout_reason()); | 521 info_->shared_info()->DisableOptimization(info_->bailout_reason()); |
524 return SetLastStatus(BAILED_OUT); | 522 return SetLastStatus(BAILED_OUT); |
525 } | 523 } |
526 | 524 |
527 private: | 525 private: |
528 CompilationInfo* info_; | 526 CompilationInfo* info_; |
529 HOptimizedGraphBuilder* graph_builder_; | 527 HOptimizedGraphBuilder* graph_builder_; |
530 HGraph* graph_; | 528 HGraph* graph_; |
531 LChunk* chunk_; | 529 LChunk* chunk_; |
532 int64_t time_taken_to_create_graph_; | 530 TimeDelta time_taken_to_create_graph_; |
533 int64_t time_taken_to_optimize_; | 531 TimeDelta time_taken_to_optimize_; |
534 int64_t time_taken_to_codegen_; | 532 TimeDelta time_taken_to_codegen_; |
535 Status last_status_; | 533 Status last_status_; |
536 | 534 |
537 MUST_USE_RESULT Status SetLastStatus(Status status) { | 535 MUST_USE_RESULT Status SetLastStatus(Status status) { |
538 last_status_ = status; | 536 last_status_ = status; |
539 return last_status_; | 537 return last_status_; |
540 } | 538 } |
541 void RecordOptimizationStats(); | 539 void RecordOptimizationStats(); |
542 | 540 |
543 struct Timer { | 541 struct Timer { |
544 Timer(OptimizingCompiler* compiler, int64_t* location) | 542 Timer(OptimizingCompiler* compiler, TimeDelta* location) |
545 : compiler_(compiler), | 543 : compiler_(compiler), |
546 start_(OS::Ticks()), | 544 location_(location) { |
547 location_(location) { } | 545 ASSERT(location_ != NULL); |
| 546 timer_.Start(); |
| 547 } |
548 | 548 |
549 ~Timer() { | 549 ~Timer() { |
550 *location_ += (OS::Ticks() - start_); | 550 *location_ += timer_.Elapsed(); |
551 } | 551 } |
552 | 552 |
553 OptimizingCompiler* compiler_; | 553 OptimizingCompiler* compiler_; |
554 int64_t start_; | 554 ElapsedTimer timer_; |
555 int64_t* location_; | 555 TimeDelta* 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 int64_t start_ticks_; | 647 ElapsedTimer timer_; |
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 |