| Index: src/compiler.h
|
| diff --git a/src/compiler.h b/src/compiler.h
|
| index bfeaa8e7c336f739514de2d8db7b39d7ad2fdff2..a80c7996a38d73be1c806cfd69e77fbef21c7cad 100644
|
| --- a/src/compiler.h
|
| +++ b/src/compiler.h
|
| @@ -6,6 +6,7 @@
|
| #define V8_COMPILER_H_
|
|
|
| #include <memory>
|
| +#include <vector>
|
|
|
| #include "src/allocation.h"
|
| #include "src/bailout-reason.h"
|
| @@ -23,6 +24,10 @@ class JavaScriptFrame;
|
| class ParseInfo;
|
| class ScriptData;
|
|
|
| +// Used by indicate whether Compiler::GetSharedFunctionInfo should trigger a
|
| +// compilation.
|
| +enum class ShouldCompile { kIfNecessary, kNever };
|
| +
|
| // The V8 compiler API.
|
| //
|
| // This is the central hub for dispatching to the various compilers within V8.
|
| @@ -52,9 +57,10 @@ class Compiler : public AllStatic {
|
| static bool CompileDebugCode(Handle<SharedFunctionInfo> shared);
|
| static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script);
|
|
|
| - // Prepare a compilation job for unoptimized code. Requires ParseAndAnalyse.
|
| - static CompilationJob* PrepareUnoptimizedCompilationJob(
|
| - CompilationInfo* info);
|
| + // Prepare a series of compilation jobs for unoptimized code. Requires
|
| + // ParseAndAnalyse.
|
| + static std::vector<std::unique_ptr<CompilationJob>>
|
| + PrepareUnoptimizedCompilationJobs(CompilationInfo* info);
|
|
|
| // Generate and install code from previously queued compilation job.
|
| static bool FinalizeCompilationJob(CompilationJob* job);
|
| @@ -114,9 +120,11 @@ class Compiler : public AllStatic {
|
| static Handle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript(
|
| Handle<Script> script, ParseInfo* info, int source_length);
|
|
|
| - // Create a shared function info object (the code may be lazily compiled).
|
| + // Create a shared function info object (the code may be lazily compiled if
|
| + // |should_compile| is kIfNecessary).
|
| static Handle<SharedFunctionInfo> GetSharedFunctionInfo(
|
| - FunctionLiteral* node, Handle<Script> script, CompilationInfo* outer);
|
| + FunctionLiteral* node, Handle<Script> script, CompilationInfo* outer,
|
| + ShouldCompile should_compile = ShouldCompile::kIfNecessary);
|
|
|
| // Create a shared function info object for a native function literal.
|
| static Handle<SharedFunctionInfo> GetSharedFunctionInfoForNative(
|
| @@ -159,12 +167,8 @@ class CompilationJob {
|
|
|
| CompilationJob(Isolate* isolate, CompilationInfo* info,
|
| const char* compiler_name,
|
| - State initial_state = State::kReadyToPrepare)
|
| - : info_(info),
|
| - compiler_name_(compiler_name),
|
| - state_(initial_state),
|
| - stack_limit_(isolate->stack_guard()->real_climit()) {}
|
| - virtual ~CompilationJob() {}
|
| + State initial_state = State::kReadyToPrepare);
|
| + virtual ~CompilationJob();
|
|
|
| // Prepare the compile job. Must be called on the main thread.
|
| MUST_USE_RESULT Status PrepareJob();
|
| @@ -196,6 +200,10 @@ class CompilationJob {
|
| CompilationInfo* info() const { return info_; }
|
| Isolate* isolate() const;
|
|
|
| + // Destroy the CompilationInfo, its ParseInfo, and its zone at the end of
|
| + // this CompilationJob's lifetime.
|
| + void TakeOwnershipOfCompilationInfo();
|
| +
|
| protected:
|
| // Overridden by the actual implementation.
|
| virtual Status PrepareJobImpl() = 0;
|
| @@ -207,6 +215,12 @@ class CompilationJob {
|
| void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
|
|
| private:
|
| + // The following unique_ptr are used only for lifetime management and might
|
| + // be empty.
|
| + std::unique_ptr<Zone> zone_;
|
| + std::unique_ptr<ParseInfo> parse_info_;
|
| + std::unique_ptr<CompilationInfo> compilation_info_;
|
| +
|
| CompilationInfo* info_;
|
| base::TimeDelta time_taken_to_prepare_;
|
| base::TimeDelta time_taken_to_execute_;
|
| @@ -223,6 +237,8 @@ class CompilationJob {
|
| }
|
| return status;
|
| }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CompilationJob);
|
| };
|
|
|
| } // namespace internal
|
|
|