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

Unified Diff: src/compiler.h

Issue 1766623004: [compiler] Unify naming of methods in compiler API. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-compiler-api-6
Patch Set: Rebased. Created 4 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/bootstrapper.cc ('k') | src/compiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index 3efbd6ebb6832657efdbdfb4bd380887378e9996..b1e96391788e8a031fdda22e3843b24648cb3021 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,107 @@ 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: Scripts are translated into anonymous functions 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 (except for live-edit, which compiles the world).
+
+ 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);
+
+ // Generate and install code from previously queued optimization job.
+ static void FinalizeOptimizedCompileJob(OptimizedCompileJob* job);
+
+ // Give the compiler a chance to perform low-latency initialization tasks of
+ // the given {function} on its instantiation. Note that only the runtime will
+ // offer this chance, optimized closure instantiation will not call this.
+ static void PostInstantiation(Handle<JSFunction> function, PretenureFlag);
+
+ // 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, BailoutId osr_ast_id,
+ JavaScriptFrame* osr_frame);
+};
struct InlinedFunctionInfo {
InlinedFunctionInfo(int parent_id, SourcePosition inline_position,
@@ -561,101 +657,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);
-
- // Generate and install code from previously queued optimization job.
- static void FinalizeOptimizedCompileJob(OptimizedCompileJob* job);
-
- // Give the compiler a chance to perform low-latency initialization tasks of
- // the given {function} on its instantiation. Note that only the runtime will
- // offer this chance, optimized closure instantiation will not call this.
- static void PostInstantiation(Handle<JSFunction> function, PretenureFlag);
-
- // 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, BailoutId osr_ast_id,
- JavaScriptFrame* osr_frame);
-};
-
} // namespace internal
} // namespace v8
« no previous file with comments | « src/bootstrapper.cc ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698