Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/compiler.h

Issue 2579973002: Don't compile inner functions when compiling via the dispatcher (Closed)
Patch Set: added comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
11 #include "src/bailout-reason.h" 11 #include "src/bailout-reason.h"
12 #include "src/contexts.h" 12 #include "src/contexts.h"
13 #include "src/isolate.h" 13 #include "src/isolate.h"
14 #include "src/zone/zone.h" 14 #include "src/zone/zone.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 18
19 // Forward declarations. 19 // Forward declarations.
20 class CompilationInfo; 20 class CompilationInfo;
21 class CompilationJob; 21 class CompilationJob;
22 class JavaScriptFrame; 22 class JavaScriptFrame;
23 class ParseInfo; 23 class ParseInfo;
24 class ScriptData; 24 class ScriptData;
25 25
26 enum class LazyCompilationMode { kAlways, kIfRequested };
rmcilroy 2016/12/16 12:51:17 I find the name confusing, I parse the kAlways as
27
26 // The V8 compiler API. 28 // The V8 compiler API.
27 // 29 //
28 // This is the central hub for dispatching to the various compilers within V8. 30 // This is the central hub for dispatching to the various compilers within V8.
29 // Logic for which compiler to choose and how to wire compilation results into 31 // Logic for which compiler to choose and how to wire compilation results into
30 // the object heap should be kept inside this class. 32 // the object heap should be kept inside this class.
31 // 33 //
32 // General strategy: Scripts are translated into anonymous functions w/o 34 // General strategy: Scripts are translated into anonymous functions w/o
33 // parameters which then can be executed. If the source code contains other 35 // 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 36 // 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. 37 // of the source code or deferred for lazy compilation at a later point.
36 class Compiler : public AllStatic { 38 class Compiler : public AllStatic {
37 public: 39 public:
38 enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION }; 40 enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION };
39 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; 41 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT };
40 enum CompilationTier { INTERPRETED, BASELINE, OPTIMIZED }; 42 enum CompilationTier { INTERPRETED, BASELINE, OPTIMIZED };
41 43
42 // =========================================================================== 44 // ===========================================================================
43 // The following family of methods ensures a given function is compiled. The 45 // The following family of methods ensures a given function is compiled. The
44 // general contract is that failures will be reported by returning {false}, 46 // general contract is that failures will be reported by returning {false},
45 // whereas successful compilation ensures the {is_compiled} predicate on the 47 // whereas successful compilation ensures the {is_compiled} predicate on the
46 // given function holds (except for live-edit, which compiles the world). 48 // given function holds (except for live-edit, which compiles the world).
47 49
48 static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag); 50 static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag);
49 static bool CompileBaseline(Handle<JSFunction> function); 51 static bool CompileBaseline(Handle<JSFunction> function);
50 static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode); 52 static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode);
51 static bool CompileDebugCode(Handle<SharedFunctionInfo> shared); 53 static bool CompileDebugCode(Handle<SharedFunctionInfo> shared);
52 static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script); 54 static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script);
53 55
54 // Prepare a compilation job for unoptimized code. Requires ParseAndAnalyse. 56 // Prepare a compilation job for unoptimized code. If |mode| is
57 // LazyCompilationMode::kAlways, the returned job will not compile any inner
58 // functions. Requires ParseAndAnalyse.
55 static CompilationJob* PrepareUnoptimizedCompilationJob( 59 static CompilationJob* PrepareUnoptimizedCompilationJob(
56 CompilationInfo* info); 60 CompilationInfo* info, LazyCompilationMode mode);
57 61
58 // Generate and install code from previously queued compilation job. 62 // Generate and install code from previously queued compilation job.
59 static bool FinalizeCompilationJob(CompilationJob* job); 63 static bool FinalizeCompilationJob(CompilationJob* job);
60 64
61 // Give the compiler a chance to perform low-latency initialization tasks of 65 // Give the compiler a chance to perform low-latency initialization tasks of
62 // the given {function} on its instantiation. Note that only the runtime will 66 // the given {function} on its instantiation. Note that only the runtime will
63 // offer this chance, optimized closure instantiation will not call this. 67 // offer this chance, optimized closure instantiation will not call this.
64 static void PostInstantiation(Handle<JSFunction> function, PretenureFlag); 68 static void PostInstantiation(Handle<JSFunction> function, PretenureFlag);
65 69
66 // Parser::Parse, then Compiler::Analyze. 70 // Parser::Parse, then Compiler::Analyze.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 ScriptCompiler::CompileOptions compile_options, 112 ScriptCompiler::CompileOptions compile_options,
109 NativesFlag is_natives_code, bool is_module); 113 NativesFlag is_natives_code, bool is_module);
110 114
111 // Create a shared function info object for a Script that has already been 115 // Create a shared function info object for a Script that has already been
112 // parsed while the script was being loaded from a streamed source. 116 // parsed while the script was being loaded from a streamed source.
113 static Handle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript( 117 static Handle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript(
114 Handle<Script> script, ParseInfo* info, int source_length); 118 Handle<Script> script, ParseInfo* info, int source_length);
115 119
116 // Create a shared function info object (the code may be lazily compiled). 120 // Create a shared function info object (the code may be lazily compiled).
117 static Handle<SharedFunctionInfo> GetSharedFunctionInfo( 121 static Handle<SharedFunctionInfo> GetSharedFunctionInfo(
118 FunctionLiteral* node, Handle<Script> script, CompilationInfo* outer); 122 FunctionLiteral* node, Handle<Script> script, CompilationInfo* outer,
123 LazyCompilationMode mode = LazyCompilationMode::kIfRequested);
119 124
120 // Create a shared function info object for a native function literal. 125 // Create a shared function info object for a native function literal.
121 static Handle<SharedFunctionInfo> GetSharedFunctionInfoForNative( 126 static Handle<SharedFunctionInfo> GetSharedFunctionInfoForNative(
122 v8::Extension* extension, Handle<String> name); 127 v8::Extension* extension, Handle<String> name);
123 128
124 // =========================================================================== 129 // ===========================================================================
125 // The following family of methods provides support for OSR. Code generated 130 // The following family of methods provides support for OSR. Code generated
126 // for entry via OSR might not be suitable for normal entry, hence will be 131 // for entry via OSR might not be suitable for normal entry, hence will be
127 // returned directly to the caller. 132 // returned directly to the caller.
128 // 133 //
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 state_ = State::kFailed; 226 state_ = State::kFailed;
222 } 227 }
223 return status; 228 return status;
224 } 229 }
225 }; 230 };
226 231
227 } // namespace internal 232 } // namespace internal
228 } // namespace v8 233 } // namespace v8
229 234
230 #endif // V8_COMPILER_H_ 235 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698