Chromium Code Reviews| Index: src/compiler.h |
| diff --git a/src/compiler.h b/src/compiler.h |
| index 02c3ddd45a7ced8172ef5e5edb541f08121d821f..af681412b3dd29a5367f0ab8806e761c0eb9d22a 100644 |
| --- a/src/compiler.h |
| +++ b/src/compiler.h |
| @@ -9,7 +9,6 @@ |
| #include "src/ast/ast.h" |
| #include "src/bailout-reason.h" |
| #include "src/compilation-dependencies.h" |
| -#include "src/signature.h" |
| #include "src/source-position.h" |
| #include "src/zone.h" |
| @@ -17,10 +16,104 @@ namespace v8 { |
| namespace internal { |
| // Forward declarations. |
| +class CompilationInfo; |
| class JavaScriptFrame; |
| +class OptimizedCompileJob; |
| class ParseInfo; |
| class ScriptData; |
| +// The V8 compiler API. |
| +// |
| +// This is the central hub for dispatching to the various compilers within V8. |
| +// Logic for which compiler to choose and how to wire compilation results into |
| +// the object heap should be kept inside this class. |
| +// |
| +// General strategy: Source code is translated into an anonymous function w/o |
|
Yang
2016/03/07 06:01:08
I'd prefer "script source code" to be clear that t
Michael Starzinger
2016/03/08 10:23:24
Done.
|
| +// parameters which then can be executed. If the source code contains other |
| +// functions, they might be compiled and allocated as part of the compilation |
| +// of the source code or deferred for lazy compilation at a later point. |
| +class Compiler : public AllStatic { |
| + public: |
| + enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION }; |
| + enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; |
| + |
| + // =========================================================================== |
| + // The following family of methods ensures a given function is compiled. The |
| + // general contract is that failures will be reported by returning {false}, |
| + // whereas successful compilation ensures the {is_compiled} predicate on the |
| + // given function holds. |
| + |
| + static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag); |
| + static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode); |
| + static bool CompileDebugCode(Handle<JSFunction> function); |
| + static bool CompileDebugCode(Handle<SharedFunctionInfo> shared); |
| + static void CompileForLiveEdit(Handle<Script> script); |
|
Yang
2016/03/07 06:01:08
Comment does not really apply to this one. Compile
Michael Starzinger
2016/03/08 10:23:24
Done. Added a remark as discussed offline.
|
| + |
| + // Parser::Parse, then Compiler::Analyze. |
| + static bool ParseAndAnalyze(ParseInfo* info); |
| + // Rewrite, analyze scopes, and renumber. |
| + static bool Analyze(ParseInfo* info); |
| + // Adds deoptimization support, requires ParseAndAnalyze. |
| + static bool EnsureDeoptimizationSupport(CompilationInfo* info); |
| + |
| + // =========================================================================== |
| + // The following family of methods instantiates new functions for scripts or |
| + // function literals. The decision whether those functions will be compiled, |
| + // is left to the discretion of the compiler. |
| + // |
| + // Please note this interface returns shared function infos. This means you |
| + // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a |
| + // real function with a context. |
| + |
| + // Create a (bound) function for a String source within a context for eval. |
| + MUST_USE_RESULT static MaybeHandle<JSFunction> GetFunctionFromEval( |
| + Handle<String> source, Handle<SharedFunctionInfo> outer_info, |
| + Handle<Context> context, LanguageMode language_mode, |
| + ParseRestriction restriction, int line_offset, int column_offset = 0, |
| + Handle<Object> script_name = Handle<Object>(), |
| + ScriptOriginOptions options = ScriptOriginOptions()); |
| + |
| + // Create a shared function info object for a String source within a context. |
| + static Handle<SharedFunctionInfo> GetSharedFunctionInfoForScript( |
| + Handle<String> source, Handle<Object> script_name, int line_offset, |
| + int column_offset, ScriptOriginOptions resource_options, |
| + Handle<Object> source_map_url, Handle<Context> context, |
| + v8::Extension* extension, ScriptData** cached_data, |
| + ScriptCompiler::CompileOptions compile_options, |
| + NativesFlag is_natives_code, bool is_module); |
| + |
| + // Create a shared function info object for a Script that has already been |
| + // parsed while the script was being loaded from a streamed source. |
| + static Handle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript( |
| + Handle<Script> script, ParseInfo* info, int source_length); |
| + |
| + // Create a shared function info object (the code may be lazily compiled). |
| + static Handle<SharedFunctionInfo> GetSharedFunctionInfo( |
| + FunctionLiteral* node, Handle<Script> script, CompilationInfo* outer); |
| + |
| + // Create a shared function info object for a native function literal. |
| + static Handle<SharedFunctionInfo> GetSharedFunctionInfoForNative( |
| + v8::Extension* extension, Handle<String> name); |
| + |
| + // =========================================================================== |
| + // The following family of methods provides support for OSR. Code generated |
| + // for entry via OSR might not be suitable for normal entry, hence will be |
| + // returned directly to the caller. |
| + // |
| + // Please note this interface is the only part dealing with {Code} objects |
| + // directly. Other methods are agnostic to {Code} and can use an interpreter |
| + // instead of generating JIT code for a function at all. |
| + |
| + // Generate and return optimized code for OSR, or empty handle on failure. |
| + MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCodeForOSR( |
| + Handle<JSFunction> function, ConcurrencyMode mode, BailoutId osr_ast_id, |
| + JavaScriptFrame* osr_frame); |
| + |
| + // Generate and return code from previously queued optimization job. |
| + // On failure, return the empty handle. |
| + MUST_USE_RESULT static MaybeHandle<Code> GetConcurrentlyOptimizedCode( |
| + OptimizedCompileJob* job); |
| +}; |
| struct InlinedFunctionInfo { |
| InlinedFunctionInfo(int parent_id, SourcePosition inline_position, |
| @@ -571,98 +664,6 @@ class OptimizedCompileJob: public ZoneObject { |
| }; |
| }; |
| -// The V8 compiler API. |
| -// |
| -// This is the central hub for dispatching to the various compilers within V8. |
| -// Logic for which compiler to choose and how to wire compilation results into |
| -// the object heap should be kept inside this class. |
| -// |
| -// General strategy: Source code is translated into an anonymous function w/o |
| -// parameters which then can be executed. If the source code contains other |
| -// functions, they might be compiled and allocated as part of the compilation |
| -// of the source code or deferred for lazy compilation at a later point. |
| -class Compiler : public AllStatic { |
| - public: |
| - enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION }; |
| - enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; |
| - |
| - // =========================================================================== |
| - // The following family of methods ensures a given function is compiled. The |
| - // general contract is that failures will be reported by returning {false}, |
| - // whereas successful compilation ensures the {is_compiled} predicate on the |
| - // given function holds. |
| - |
| - static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag); |
| - static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode); |
| - static bool CompileDebugCode(Handle<JSFunction> function); |
| - static bool CompileDebugCode(Handle<SharedFunctionInfo> shared); |
| - static void CompileForLiveEdit(Handle<Script> script); |
| - |
| - // Parser::Parse, then Compiler::Analyze. |
| - static bool ParseAndAnalyze(ParseInfo* info); |
| - // Rewrite, analyze scopes, and renumber. |
| - static bool Analyze(ParseInfo* info); |
| - // Adds deoptimization support, requires ParseAndAnalyze. |
| - static bool EnsureDeoptimizationSupport(CompilationInfo* info); |
| - |
| - // =========================================================================== |
| - // The following family of methods instantiates new functions for script or |
| - // function literals. The decision whether those functions have been compiled |
| - // is left to the discretion of the compiler. |
| - // |
| - // Please note this interface returns shared function infos. This means you |
| - // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a |
| - // real function with a context. |
| - |
| - // Compile a String source within a context for eval. |
| - MUST_USE_RESULT static MaybeHandle<JSFunction> GetFunctionFromEval( |
| - Handle<String> source, Handle<SharedFunctionInfo> outer_info, |
| - Handle<Context> context, LanguageMode language_mode, |
| - ParseRestriction restriction, int line_offset, int column_offset = 0, |
| - Handle<Object> script_name = Handle<Object>(), |
| - ScriptOriginOptions options = ScriptOriginOptions()); |
| - |
| - // Compile a String source within a context. |
| - static Handle<SharedFunctionInfo> CompileScript( |
| - Handle<String> source, Handle<Object> script_name, int line_offset, |
| - int column_offset, ScriptOriginOptions resource_options, |
| - Handle<Object> source_map_url, Handle<Context> context, |
| - v8::Extension* extension, ScriptData** cached_data, |
| - ScriptCompiler::CompileOptions compile_options, |
| - NativesFlag is_natives_code, bool is_module); |
| - |
| - static Handle<SharedFunctionInfo> CompileStreamedScript(Handle<Script> script, |
| - ParseInfo* info, |
| - int source_length); |
| - |
| - // Create a shared function info object (the code may be lazily compiled). |
| - static Handle<SharedFunctionInfo> GetSharedFunctionInfo( |
| - FunctionLiteral* node, Handle<Script> script, CompilationInfo* outer); |
| - |
| - // Create a shared function info object for a native function literal. |
| - static Handle<SharedFunctionInfo> GetSharedFunctionInfoForNative( |
| - v8::Extension* extension, Handle<String> name); |
| - |
| - // =========================================================================== |
| - // The following family of methods provides support for OSR. Code generated |
| - // for entry via OSR might not be suitable for normal entry, hence will be |
| - // returned directly to the caller. |
| - // |
| - // Please note this interface is the only part dealing with {Code} objects |
| - // directly. Other methods are agnostic to {Code} and can use an interpreter |
| - // instead of generating JIT code for a function at all. |
| - |
| - // Generate and return optimized code for OSR, or empty handle on failure. |
| - MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCodeForOSR( |
| - Handle<JSFunction> function, ConcurrencyMode mode, BailoutId osr_ast_id, |
| - JavaScriptFrame* osr_frame); |
| - |
| - // Generate and return code from previously queued optimization job. |
| - // On failure, return the empty handle. |
| - MUST_USE_RESULT static MaybeHandle<Code> GetConcurrentlyOptimizedCode( |
| - OptimizedCompileJob* job); |
| -}; |
| - |
| } // namespace internal |
| } // namespace v8 |