| 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 class HGraph; | 499 class HGraph; |
| 500 class HOptimizedGraphBuilder; | 500 class HOptimizedGraphBuilder; |
| 501 class LChunk; | 501 class LChunk; |
| 502 | 502 |
| 503 // A helper class that calls the three compilation phases in | 503 // A helper class that calls the three compilation phases in |
| 504 // Crankshaft and keeps track of its state. The three phases | 504 // Crankshaft and keeps track of its state. The three phases |
| 505 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either | 505 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either |
| 506 // fail, bail-out to the full code generator or succeed. Apart from | 506 // fail, bail-out to the full code generator or succeed. Apart from |
| 507 // their return value, the status of the phase last run can be checked | 507 // their return value, the status of the phase last run can be checked |
| 508 // using last_status(). | 508 // using last_status(). |
| 509 class OptimizingCompiler: public ZoneObject { | 509 class RecompileJob: public ZoneObject { |
| 510 public: | 510 public: |
| 511 explicit OptimizingCompiler(CompilationInfo* info) | 511 explicit RecompileJob(CompilationInfo* info) |
| 512 : info_(info), | 512 : info_(info), |
| 513 graph_builder_(NULL), | 513 graph_builder_(NULL), |
| 514 graph_(NULL), | 514 graph_(NULL), |
| 515 chunk_(NULL), | 515 chunk_(NULL), |
| 516 last_status_(FAILED) { } | 516 last_status_(FAILED) { } |
| 517 | 517 |
| 518 enum Status { | 518 enum Status { |
| 519 FAILED, BAILED_OUT, SUCCEEDED | 519 FAILED, BAILED_OUT, SUCCEEDED |
| 520 }; | 520 }; |
| 521 | 521 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 551 Status last_status_; | 551 Status last_status_; |
| 552 bool awaiting_install_; | 552 bool awaiting_install_; |
| 553 | 553 |
| 554 MUST_USE_RESULT Status SetLastStatus(Status status) { | 554 MUST_USE_RESULT Status SetLastStatus(Status status) { |
| 555 last_status_ = status; | 555 last_status_ = status; |
| 556 return last_status_; | 556 return last_status_; |
| 557 } | 557 } |
| 558 void RecordOptimizationStats(); | 558 void RecordOptimizationStats(); |
| 559 | 559 |
| 560 struct Timer { | 560 struct Timer { |
| 561 Timer(OptimizingCompiler* compiler, TimeDelta* location) | 561 Timer(RecompileJob* job, TimeDelta* location) |
| 562 : compiler_(compiler), | 562 : job_(job), location_(location) { |
| 563 location_(location) { | |
| 564 ASSERT(location_ != NULL); | 563 ASSERT(location_ != NULL); |
| 565 timer_.Start(); | 564 timer_.Start(); |
| 566 } | 565 } |
| 567 | 566 |
| 568 ~Timer() { | 567 ~Timer() { |
| 569 *location_ += timer_.Elapsed(); | 568 *location_ += timer_.Elapsed(); |
| 570 } | 569 } |
| 571 | 570 |
| 572 OptimizingCompiler* compiler_; | 571 RecompileJob* job_; |
| 573 ElapsedTimer timer_; | 572 ElapsedTimer timer_; |
| 574 TimeDelta* location_; | 573 TimeDelta* location_; |
| 575 }; | 574 }; |
| 576 }; | 575 }; |
| 577 | 576 |
| 578 | 577 |
| 579 // The V8 compiler | 578 // The V8 compiler |
| 580 // | 579 // |
| 581 // General strategy: Source code is translated into an anonymous function w/o | 580 // General strategy: Source code is translated into an anonymous function w/o |
| 582 // parameters which then can be executed. If the source code contains other | 581 // parameters which then can be executed. If the source code contains other |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 // compiled). | 626 // compiled). |
| 628 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 627 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
| 629 Handle<Script> script); | 628 Handle<Script> script); |
| 630 | 629 |
| 631 // Set the function info for a newly compiled function. | 630 // Set the function info for a newly compiled function. |
| 632 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, | 631 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
| 633 FunctionLiteral* lit, | 632 FunctionLiteral* lit, |
| 634 bool is_toplevel, | 633 bool is_toplevel, |
| 635 Handle<Script> script); | 634 Handle<Script> script); |
| 636 | 635 |
| 637 static Handle<Code> InstallOptimizedCode(OptimizingCompiler* info); | 636 static Handle<Code> InstallOptimizedCode(RecompileJob* job); |
| 638 | 637 |
| 639 #ifdef ENABLE_DEBUGGER_SUPPORT | 638 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 640 static bool MakeCodeForLiveEdit(CompilationInfo* info); | 639 static bool MakeCodeForLiveEdit(CompilationInfo* info); |
| 641 #endif | 640 #endif |
| 642 | 641 |
| 643 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 642 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| 644 CompilationInfo* info, | 643 CompilationInfo* info, |
| 645 Handle<SharedFunctionInfo> shared); | 644 Handle<SharedFunctionInfo> shared); |
| 646 }; | 645 }; |
| 647 | 646 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 666 unsigned info_zone_start_allocation_size_; | 665 unsigned info_zone_start_allocation_size_; |
| 667 ElapsedTimer timer_; | 666 ElapsedTimer timer_; |
| 668 | 667 |
| 669 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 668 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
| 670 }; | 669 }; |
| 671 | 670 |
| 672 | 671 |
| 673 } } // namespace v8::internal | 672 } } // namespace v8::internal |
| 674 | 673 |
| 675 #endif // V8_COMPILER_H_ | 674 #endif // V8_COMPILER_H_ |
| OLD | NEW |