#include "src/libplatform/default-platform.h"
#include <algorithm>
#include <queue>
#include "include/libplatform/libplatform.h"
#include "src/base/debug/stack_trace.h"
#include "src/base/logging.h"
#include "src/base/page-allocator.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/base/sys-info.h"
#include "src/libplatform/default-foreground-task-runner.h"
#include "src/libplatform/default-job.h"
#include "src/libplatform/default-worker-threads-task-runner.h"
namespace v8 {
namespace platform {
namespace {
void PrintStackTrace() { … }
constexpr int kMaxThreadPoolSize = …;
int GetActualThreadPoolSize(int thread_pool_size) { … }
}
std::unique_ptr<v8::Platform> NewDefaultPlatform(
int thread_pool_size, IdleTaskSupport idle_task_support,
InProcessStackDumping in_process_stack_dumping,
std::unique_ptr<v8::TracingController> tracing_controller,
PriorityMode priority_mode) { … }
std::unique_ptr<v8::Platform> NewSingleThreadedDefaultPlatform(
IdleTaskSupport idle_task_support,
InProcessStackDumping in_process_stack_dumping,
std::unique_ptr<v8::TracingController> tracing_controller) { … }
V8_PLATFORM_EXPORT std::unique_ptr<JobHandle> NewDefaultJobHandle(
Platform* platform, TaskPriority priority,
std::unique_ptr<JobTask> job_task, size_t num_worker_threads) { … }
bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate,
MessageLoopBehavior behavior) { … }
void RunIdleTasks(v8::Platform* platform, v8::Isolate* isolate,
double idle_time_in_seconds) { … }
void NotifyIsolateShutdown(v8::Platform* platform, Isolate* isolate) { … }
DefaultPlatform::DefaultPlatform(
int thread_pool_size, IdleTaskSupport idle_task_support,
std::unique_ptr<v8::TracingController> tracing_controller,
PriorityMode priority_mode)
: … { … }
DefaultPlatform::~DefaultPlatform() { … }
namespace {
double DefaultTimeFunction() { … }
}
void DefaultPlatform::EnsureBackgroundTaskRunnerInitialized() { … }
void DefaultPlatform::SetTimeFunctionForTesting(
DefaultPlatform::TimeFunction time_function) { … }
bool DefaultPlatform::PumpMessageLoop(v8::Isolate* isolate,
MessageLoopBehavior wait_for_work) { … }
void DefaultPlatform::RunIdleTasks(v8::Isolate* isolate,
double idle_time_in_seconds) { … }
std::shared_ptr<TaskRunner> DefaultPlatform::GetForegroundTaskRunner(
v8::Isolate* isolate, TaskPriority priority) { … }
void DefaultPlatform::PostTaskOnWorkerThreadImpl(
TaskPriority priority, std::unique_ptr<Task> task,
const SourceLocation& location) { … }
void DefaultPlatform::PostDelayedTaskOnWorkerThreadImpl(
TaskPriority priority, std::unique_ptr<Task> task, double delay_in_seconds,
const SourceLocation& location) { … }
bool DefaultPlatform::IdleTasksEnabled(Isolate* isolate) { … }
std::unique_ptr<JobHandle> DefaultPlatform::CreateJobImpl(
TaskPriority priority, std::unique_ptr<JobTask> job_task,
const SourceLocation& location) { … }
double DefaultPlatform::MonotonicallyIncreasingTime() { … }
double DefaultPlatform::CurrentClockTimeMillis() { … }
TracingController* DefaultPlatform::GetTracingController() { … }
void DefaultPlatform::SetTracingController(
std::unique_ptr<v8::TracingController> tracing_controller) { … }
int DefaultPlatform::NumberOfWorkerThreads() { … }
Platform::StackTracePrinter DefaultPlatform::GetStackTracePrinter() { … }
v8::PageAllocator* DefaultPlatform::GetPageAllocator() { … }
v8::ThreadIsolatedAllocator* DefaultPlatform::GetThreadIsolatedAllocator() { … }
void DefaultPlatform::NotifyIsolateShutdown(Isolate* isolate) { … }
}
}