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