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" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 // the object heap should be kept inside this class. | 30 // the object heap should be kept inside this class. |
31 // | 31 // |
32 // General strategy: Scripts are translated into anonymous functions w/o | 32 // General strategy: Scripts are translated into anonymous functions w/o |
33 // parameters which then can be executed. If the source code contains other | 33 // parameters which then can be executed. If the source code contains other |
34 // functions, they might be compiled and allocated as part of the compilation | 34 // functions, they might be compiled and allocated as part of the compilation |
35 // of the source code or deferred for lazy compilation at a later point. | 35 // of the source code or deferred for lazy compilation at a later point. |
36 class Compiler : public AllStatic { | 36 class Compiler : public AllStatic { |
37 public: | 37 public: |
38 enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION }; | 38 enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION }; |
39 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; | 39 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; |
40 enum CompilationTier { INTERPRETED, BASELINE, OPTIMIZED }; | |
40 | 41 |
41 // =========================================================================== | 42 // =========================================================================== |
42 // The following family of methods ensures a given function is compiled. The | 43 // The following family of methods ensures a given function is compiled. The |
43 // general contract is that failures will be reported by returning {false}, | 44 // general contract is that failures will be reported by returning {false}, |
44 // whereas successful compilation ensures the {is_compiled} predicate on the | 45 // whereas successful compilation ensures the {is_compiled} predicate on the |
45 // given function holds (except for live-edit, which compiles the world). | 46 // given function holds (except for live-edit, which compiles the world). |
46 | 47 |
47 static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag); | 48 static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag); |
48 static bool CompileBaseline(Handle<JSFunction> function); | 49 static bool CompileBaseline(Handle<JSFunction> function); |
49 static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode); | 50 static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode); |
50 static bool CompileDebugCode(Handle<JSFunction> function); | 51 static bool CompileDebugCode(Handle<JSFunction> function); |
51 static bool CompileDebugCode(Handle<SharedFunctionInfo> shared); | 52 static bool CompileDebugCode(Handle<SharedFunctionInfo> shared); |
52 static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script); | 53 static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script); |
53 | 54 |
54 // Generate and install code from previously queued compilation job. | 55 // Generate and install code from previously queued compilation job. |
55 static void FinalizeCompilationJob(CompilationJob* job); | 56 static void FinalizeCompilationJob(CompilationJob* job); |
56 | 57 |
57 // Give the compiler a chance to perform low-latency initialization tasks of | 58 // Give the compiler a chance to perform low-latency initialization tasks of |
58 // the given {function} on its instantiation. Note that only the runtime will | 59 // the given {function} on its instantiation. Note that only the runtime will |
59 // offer this chance, optimized closure instantiation will not call this. | 60 // offer this chance, optimized closure instantiation will not call this. |
60 static void PostInstantiation(Handle<JSFunction> function, PretenureFlag); | 61 static void PostInstantiation(Handle<JSFunction> function, PretenureFlag); |
61 | 62 |
62 // Parser::Parse, then Compiler::Analyze. | 63 // Parser::Parse, then Compiler::Analyze. |
63 static bool ParseAndAnalyze(ParseInfo* info); | 64 static bool ParseAndAnalyze(ParseInfo* info); |
64 // Rewrite, analyze scopes, and renumber. | 65 // Rewrite, analyze scopes, and renumber. |
65 static bool Analyze(ParseInfo* info); | 66 static bool Analyze(ParseInfo* info); |
66 // Adds deoptimization support, requires ParseAndAnalyze. | 67 // Adds deoptimization support, requires ParseAndAnalyze. |
67 static bool EnsureDeoptimizationSupport(CompilationInfo* info); | 68 static bool EnsureDeoptimizationSupport(CompilationInfo* info); |
69 // Ensures that bytecode is generated. | |
70 static bool EnsureBytecode(CompilationInfo* info); | |
71 | |
72 // The next compilation tier which the function should be compiled to for | |
73 // optimization. | |
74 static CompilationTier NextCompilationTier(JSFunction* function); | |
75 | |
76 // True if the given function compilation should use Ignition for unoptimized | |
77 // compilation. | |
78 static bool ShouldUseIgnition(CompilationInfo* info); | |
Michael Starzinger
2016/07/19 09:36:02
There seems to be only one use of this predicate o
rmcilroy
2016/07/19 13:13:50
Yeah I thought you might say this :). I've removed
| |
68 | 79 |
69 // =========================================================================== | 80 // =========================================================================== |
70 // The following family of methods instantiates new functions for scripts or | 81 // The following family of methods instantiates new functions for scripts or |
71 // function literals. The decision whether those functions will be compiled, | 82 // function literals. The decision whether those functions will be compiled, |
72 // is left to the discretion of the compiler. | 83 // is left to the discretion of the compiler. |
73 // | 84 // |
74 // Please note this interface returns shared function infos. This means you | 85 // Please note this interface returns shared function infos. This means you |
75 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a | 86 // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a |
76 // real function with a context. | 87 // real function with a context. |
77 | 88 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
572 MUST_USE_RESULT Status SetLastStatus(Status status) { | 583 MUST_USE_RESULT Status SetLastStatus(Status status) { |
573 last_status_ = status; | 584 last_status_ = status; |
574 return last_status_; | 585 return last_status_; |
575 } | 586 } |
576 }; | 587 }; |
577 | 588 |
578 } // namespace internal | 589 } // namespace internal |
579 } // namespace v8 | 590 } // namespace v8 |
580 | 591 |
581 #endif // V8_COMPILER_H_ | 592 #endif // V8_COMPILER_H_ |
OLD | NEW |