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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 // 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 |
495 // 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 |
496 // using last_status(). | 496 // using last_status(). |
497 class OptimizingCompiler: public ZoneObject { | 497 class OptimizingCompiler: public ZoneObject { |
498 public: | 498 public: |
499 explicit OptimizingCompiler(CompilationInfo* info) | 499 explicit OptimizingCompiler(CompilationInfo* info) |
500 : info_(info), | 500 : info_(info), |
501 graph_builder_(NULL), | 501 graph_builder_(NULL), |
502 graph_(NULL), | 502 graph_(NULL), |
503 chunk_(NULL), | 503 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) { } | 504 last_status_(FAILED) { } |
508 | 505 |
509 enum Status { | 506 enum Status { |
510 FAILED, BAILED_OUT, SUCCEEDED | 507 FAILED, BAILED_OUT, SUCCEEDED |
511 }; | 508 }; |
512 | 509 |
513 MUST_USE_RESULT Status CreateGraph(); | 510 MUST_USE_RESULT Status CreateGraph(); |
514 MUST_USE_RESULT Status OptimizeGraph(); | 511 MUST_USE_RESULT Status OptimizeGraph(); |
515 MUST_USE_RESULT Status GenerateAndInstallCode(); | 512 MUST_USE_RESULT Status GenerateAndInstallCode(); |
516 | 513 |
517 Status last_status() const { return last_status_; } | 514 Status last_status() const { return last_status_; } |
518 CompilationInfo* info() const { return info_; } | 515 CompilationInfo* info() const { return info_; } |
519 Isolate* isolate() const { return info()->isolate(); } | 516 Isolate* isolate() const { return info()->isolate(); } |
520 | 517 |
521 MUST_USE_RESULT Status AbortOptimization() { | 518 MUST_USE_RESULT Status AbortOptimization() { |
522 info_->AbortOptimization(); | 519 info_->AbortOptimization(); |
523 info_->shared_info()->DisableOptimization(info_->bailout_reason()); | 520 info_->shared_info()->DisableOptimization(info_->bailout_reason()); |
524 return SetLastStatus(BAILED_OUT); | 521 return SetLastStatus(BAILED_OUT); |
525 } | 522 } |
526 | 523 |
527 private: | 524 private: |
528 CompilationInfo* info_; | 525 CompilationInfo* info_; |
529 HOptimizedGraphBuilder* graph_builder_; | 526 HOptimizedGraphBuilder* graph_builder_; |
530 HGraph* graph_; | 527 HGraph* graph_; |
531 LChunk* chunk_; | 528 LChunk* chunk_; |
532 int64_t time_taken_to_create_graph_; | 529 TimeDelta time_taken_to_create_graph_; |
533 int64_t time_taken_to_optimize_; | 530 TimeDelta time_taken_to_optimize_; |
534 int64_t time_taken_to_codegen_; | 531 TimeDelta time_taken_to_codegen_; |
535 Status last_status_; | 532 Status last_status_; |
536 | 533 |
537 MUST_USE_RESULT Status SetLastStatus(Status status) { | 534 MUST_USE_RESULT Status SetLastStatus(Status status) { |
538 last_status_ = status; | 535 last_status_ = status; |
539 return last_status_; | 536 return last_status_; |
540 } | 537 } |
541 void RecordOptimizationStats(); | 538 void RecordOptimizationStats(); |
542 | 539 |
543 struct Timer { | 540 struct Timer { |
544 Timer(OptimizingCompiler* compiler, int64_t* location) | 541 Timer(OptimizingCompiler* compiler, TimeDelta* location) |
545 : compiler_(compiler), | 542 : compiler_(compiler), |
546 start_(OS::Ticks()), | 543 location_(location) { |
547 location_(location) { } | 544 ASSERT(location_ != NULL); |
| 545 timer_.Start(); |
| 546 } |
548 | 547 |
549 ~Timer() { | 548 ~Timer() { |
550 *location_ += (OS::Ticks() - start_); | 549 *location_ += timer_.Elapsed(); |
551 } | 550 } |
552 | 551 |
553 OptimizingCompiler* compiler_; | 552 OptimizingCompiler* compiler_; |
554 int64_t start_; | 553 ElapsedTimer timer_; |
555 int64_t* location_; | 554 TimeDelta* location_; |
556 }; | 555 }; |
557 }; | 556 }; |
558 | 557 |
559 | 558 |
560 // The V8 compiler | 559 // The V8 compiler |
561 // | 560 // |
562 // General strategy: Source code is translated into an anonymous function w/o | 561 // 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 | 562 // 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 | 563 // functions, they will be compiled and allocated as part of the compilation |
565 // of the source code. | 564 // of the source code. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 const char* name() const { return name_; } | 636 const char* name() const { return name_; } |
638 CompilationInfo* info() const { return info_; } | 637 CompilationInfo* info() const { return info_; } |
639 Isolate* isolate() const { return info()->isolate(); } | 638 Isolate* isolate() const { return info()->isolate(); } |
640 Zone* zone() { return &zone_; } | 639 Zone* zone() { return &zone_; } |
641 | 640 |
642 private: | 641 private: |
643 const char* name_; | 642 const char* name_; |
644 CompilationInfo* info_; | 643 CompilationInfo* info_; |
645 Zone zone_; | 644 Zone zone_; |
646 unsigned info_zone_start_allocation_size_; | 645 unsigned info_zone_start_allocation_size_; |
647 int64_t start_ticks_; | 646 ElapsedTimer timer_; |
648 | 647 |
649 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 648 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
650 }; | 649 }; |
651 | 650 |
652 | 651 |
653 } } // namespace v8::internal | 652 } } // namespace v8::internal |
654 | 653 |
655 #endif // V8_COMPILER_H_ | 654 #endif // V8_COMPILER_H_ |
OLD | NEW |