// Copyright 2016 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_COMPILER_DISPATCHER_LAZY_COMPILE_DISPATCHER_H_ #define V8_COMPILER_DISPATCHER_LAZY_COMPILE_DISPATCHER_H_ #include <cstdint> #include <memory> #include <unordered_set> #include <utility> #include <vector> #include "src/base/atomic-utils.h" #include "src/base/macros.h" #include "src/base/platform/condition-variable.h" #include "src/base/platform/mutex.h" #include "src/base/platform/semaphore.h" #include "src/common/globals.h" #include "src/utils/identity-map.h" #include "testing/gtest/include/gtest/gtest_prod.h" // nogncheck namespace v8 { class JobDelegate; class JobHandle; class Platform; class TaskRunner; enum class MemoryPressureLevel; namespace internal { class AstRawString; class AstValueFactory; class BackgroundCompileTask; class CancelableTaskManager; class UnoptimizedCompileJob; class UnoptimizedCompileState; class FunctionLiteral; class ParseInfo; class ProducedPreparseData; class SharedFunctionInfo; class TimedHistogram; class Utf16CharacterStream; class WorkerThreadRuntimeCallStats; class Zone; // The LazyCompileDispatcher uses a combination of idle tasks and background // tasks to parse and compile lazily parsed functions. // // As both parsing and compilation currently requires a preparation and // finalization step that happens on the main thread, every task has to be // advanced during idle time first. Depending on the properties of the task, it // can then be parsed or compiled on either background threads, or during idle // time. Last, it has to be finalized during idle time again. // // LazyCompileDispatcher::jobs_ maintains the list of all // LazyCompilerDispatcherJobs the LazyCompileDispatcher knows about. // // LazyCompileDispatcher::pending_background_jobs_ contains the set of // LazyCompilerDispatcherJobs that can be processed on a background thread. // // LazyCompileDispatcher::running_background_jobs_ contains the set of // LazyCompilerDispatcherJobs that are currently being processed on a background // thread. // // LazyCompileDispatcher::DoIdleWork tries to advance as many jobs out of jobs_ // as possible during idle time. If a job can't be advanced, but is suitable for // background processing, it fires off background threads. // // LazyCompileDispatcher::DoBackgroundWork advances one of the pending jobs, // and then spins of another idle task to potentially do the final step on the // main thread. class V8_EXPORT_PRIVATE LazyCompileDispatcher { … }; } // namespace internal } // namespace v8 #endif // V8_COMPILER_DISPATCHER_LAZY_COMPILE_DISPATCHER_H_