| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_H_ | 5 #ifndef V8_COMPILER_H_ |
| 6 #define V8_COMPILER_H_ | 6 #define V8_COMPILER_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| 11 #include "src/compilation-dependencies.h" | 11 #include "src/compilation-dependencies.h" |
| 12 #include "src/source-position.h" | 12 #include "src/source-position.h" |
| 13 #include "src/zone.h" | 13 #include "src/zone.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 // Forward declarations. | 18 // Forward declarations. |
| 19 class CompilationInfo; | 19 class CompilationInfo; |
| 20 class CompilationJob; |
| 20 class JavaScriptFrame; | 21 class JavaScriptFrame; |
| 21 class OptimizedCompileJob; | |
| 22 class ParseInfo; | 22 class ParseInfo; |
| 23 class ScriptData; | 23 class ScriptData; |
| 24 | 24 |
| 25 // The V8 compiler API. | 25 // The V8 compiler API. |
| 26 // | 26 // |
| 27 // This is the central hub for dispatching to the various compilers within V8. | 27 // This is the central hub for dispatching to the various compilers within V8. |
| 28 // Logic for which compiler to choose and how to wire compilation results into | 28 // Logic for which compiler to choose and how to wire compilation results into |
| 29 // the object heap should be kept inside this class. | 29 // the object heap should be kept inside this class. |
| 30 // | 30 // |
| 31 // General strategy: Scripts are translated into anonymous functions w/o | 31 // General strategy: Scripts are translated into anonymous functions w/o |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 // whereas successful compilation ensures the {is_compiled} predicate on the | 43 // whereas successful compilation ensures the {is_compiled} predicate on the |
| 44 // given function holds (except for live-edit, which compiles the world). | 44 // given function holds (except for live-edit, which compiles the world). |
| 45 | 45 |
| 46 static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag); | 46 static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag); |
| 47 static bool CompileBaseline(Handle<JSFunction> function); | 47 static bool CompileBaseline(Handle<JSFunction> function); |
| 48 static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode); | 48 static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode); |
| 49 static bool CompileDebugCode(Handle<JSFunction> function); | 49 static bool CompileDebugCode(Handle<JSFunction> function); |
| 50 static bool CompileDebugCode(Handle<SharedFunctionInfo> shared); | 50 static bool CompileDebugCode(Handle<SharedFunctionInfo> shared); |
| 51 static bool CompileForLiveEdit(Handle<Script> script); | 51 static bool CompileForLiveEdit(Handle<Script> script); |
| 52 | 52 |
| 53 // Generate and install code from previously queued optimization job. | 53 // Generate and install code from previously queued compilation job. |
| 54 static void FinalizeOptimizedCompileJob(OptimizedCompileJob* job); | 54 static void FinalizeCompilationJob(CompilationJob* job); |
| 55 | 55 |
| 56 // Give the compiler a chance to perform low-latency initialization tasks of | 56 // Give the compiler a chance to perform low-latency initialization tasks of |
| 57 // the given {function} on its instantiation. Note that only the runtime will | 57 // the given {function} on its instantiation. Note that only the runtime will |
| 58 // offer this chance, optimized closure instantiation will not call this. | 58 // offer this chance, optimized closure instantiation will not call this. |
| 59 static void PostInstantiation(Handle<JSFunction> function, PretenureFlag); | 59 static void PostInstantiation(Handle<JSFunction> function, PretenureFlag); |
| 60 | 60 |
| 61 // Parser::Parse, then Compiler::Analyze. | 61 // Parser::Parse, then Compiler::Analyze. |
| 62 static bool ParseAndAnalyze(ParseInfo* info); | 62 static bool ParseAndAnalyze(ParseInfo* info); |
| 63 // Rewrite, analyze scopes, and renumber. | 63 // Rewrite, analyze scopes, and renumber. |
| 64 static bool Analyze(ParseInfo* info); | 64 static bool Analyze(ParseInfo* info); |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 // thread. The job is split into three phases which are called in sequence on | 565 // thread. The job is split into three phases which are called in sequence on |
| 566 // different threads and with different limitations: | 566 // different threads and with different limitations: |
| 567 // 1) CreateGraph: Runs on main thread. No major limitations. | 567 // 1) CreateGraph: Runs on main thread. No major limitations. |
| 568 // 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs. | 568 // 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs. |
| 569 // 3) GenerateCode: Runs on main thread. No dependency changes. | 569 // 3) GenerateCode: Runs on main thread. No dependency changes. |
| 570 // | 570 // |
| 571 // Each of the three phases can either fail, bail-out to full code generator or | 571 // Each of the three phases can either fail, bail-out to full code generator or |
| 572 // succeed. Apart from their return value, the status of the phase last run can | 572 // succeed. Apart from their return value, the status of the phase last run can |
| 573 // be checked using {last_status()} as well. | 573 // be checked using {last_status()} as well. |
| 574 // TODO(mstarzinger): Make CompilationInfo base embedded. | 574 // TODO(mstarzinger): Make CompilationInfo base embedded. |
| 575 class OptimizedCompileJob { | 575 class CompilationJob { |
| 576 public: | 576 public: |
| 577 explicit OptimizedCompileJob(CompilationInfo* info, const char* compiler_name) | 577 explicit CompilationJob(CompilationInfo* info, const char* compiler_name) |
| 578 : info_(info), compiler_name_(compiler_name), last_status_(SUCCEEDED) {} | 578 : info_(info), compiler_name_(compiler_name), last_status_(SUCCEEDED) {} |
| 579 virtual ~OptimizedCompileJob() {} | 579 virtual ~CompilationJob() {} |
| 580 | 580 |
| 581 enum Status { | 581 enum Status { |
| 582 FAILED, BAILED_OUT, SUCCEEDED | 582 FAILED, BAILED_OUT, SUCCEEDED |
| 583 }; | 583 }; |
| 584 | 584 |
| 585 MUST_USE_RESULT Status CreateGraph(); | 585 MUST_USE_RESULT Status CreateGraph(); |
| 586 MUST_USE_RESULT Status OptimizeGraph(); | 586 MUST_USE_RESULT Status OptimizeGraph(); |
| 587 MUST_USE_RESULT Status GenerateCode(); | 587 MUST_USE_RESULT Status GenerateCode(); |
| 588 | 588 |
| 589 Status last_status() const { return last_status_; } | 589 Status last_status() const { return last_status_; } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 MUST_USE_RESULT Status SetLastStatus(Status status) { | 621 MUST_USE_RESULT Status SetLastStatus(Status status) { |
| 622 last_status_ = status; | 622 last_status_ = status; |
| 623 return last_status_; | 623 return last_status_; |
| 624 } | 624 } |
| 625 }; | 625 }; |
| 626 | 626 |
| 627 } // namespace internal | 627 } // namespace internal |
| 628 } // namespace v8 | 628 } // namespace v8 |
| 629 | 629 |
| 630 #endif // V8_COMPILER_H_ | 630 #endif // V8_COMPILER_H_ |
| OLD | NEW |