1 // Copyright 2016 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_DISPATCHER_UNOPTIMIZED_COMPILE_JOB_H_ 6 #define V8_COMPILER_DISPATCHER_UNOPTIMIZED_COMPILE_JOB_H_ 7 8 #include <memory> 9 10 #include "include/v8.h" 11 #include "src/base/macros.h" 12 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" 13 #include "src/globals.h" 14 15 namespace v8 { 16 namespace internal { 17 18 class AstValueFactory; 19 class AstStringConstants; 20 class CompilerDispatcherTracer; 21 class DeferredHandles; 22 class FunctionLiteral; 23 class Isolate; 24 class ParseInfo; 25 class Parser; 26 class SharedFunctionInfo; 27 class String; 28 class UnicodeCache; 29 class UnoptimizedCompilationJob; 30 class Utf16CharacterStream; 31 32 class V8_EXPORT_PRIVATE UnoptimizedCompileJob : public CompilerDispatcherJob { 33 public: 34 // Creates a UnoptimizedCompileJob in the initial state. 35 UnoptimizedCompileJob(Isolate* isolate, CompilerDispatcherTracer* tracer, 36 Handle<SharedFunctionInfo> shared, 37 size_t max_stack_size); 38 ~UnoptimizedCompileJob() override; 39 shared()40 Handle<SharedFunctionInfo> shared() const { return shared_; } 41 42 // Returns true if this UnoptimizedCompileJob was created for the given 43 // function. 44 bool IsAssociatedWith(Handle<SharedFunctionInfo> shared) const; 45 46 // CompilerDispatcherJob implementation. 47 void PrepareOnMainThread(Isolate* isolate) override; 48 void Compile(bool on_background_thread) override; 49 void FinalizeOnMainThread(Isolate* isolate) override; 50 void ReportErrorsOnMainThread(Isolate* isolate) override; 51 void ResetOnMainThread(Isolate* isolate) override; 52 double EstimateRuntimeOfNextStepInMs() const override; 53 void ShortPrintOnMainThread() override; 54 55 private: 56 friend class CompilerDispatcherTest; 57 friend class UnoptimizedCompileJobTest; 58 59 void ResetDataOnMainThread(Isolate* isolate); 60 context()61 Context* context() { return *context_; } 62 63 int main_thread_id_; 64 CompilerDispatcherTracer* tracer_; 65 AccountingAllocator* allocator_; 66 Handle<Context> context_; // Global handle. 67 Handle<SharedFunctionInfo> shared_; // Global handle. 68 Handle<String> source_; // Global handle. 69 Handle<String> wrapper_; // Global handle. 70 size_t max_stack_size_; 71 72 // Members required for parsing. 73 std::unique_ptr<UnicodeCache> unicode_cache_; 74 std::unique_ptr<ParseInfo> parse_info_; 75 std::unique_ptr<Parser> parser_; 76 77 // Members required for compiling. 78 std::unique_ptr<UnoptimizedCompilationJob> compilation_job_; 79 80 bool trace_compiler_dispatcher_jobs_; 81 82 DISALLOW_COPY_AND_ASSIGN(UnoptimizedCompileJob); 83 }; 84 85 } // namespace internal 86 } // namespace v8 87 88 #endif // V8_COMPILER_DISPATCHER_UNOPTIMIZED_COMPILE_JOB_H_ 89