#include "gin/public/v8_platform.h"
#include <algorithm>
#include "base/bit_cast.h"
#include "base/check_op.h"
#include "base/debug/stack_trace.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/stack_allocated.h"
#include "base/no_destructor.h"
#include "base/system/sys_info.h"
#include "base/task/post_job.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/scoped_blocking_call_internal.h"
#include "base/trace_event/trace_event.h"
#include "base/tracing_buildflags.h"
#include "build/build_config.h"
#include "gin/converter.h"
#include "gin/per_isolate_data.h"
#include "gin/thread_isolation.h"
#include "gin/v8_platform_thread_isolated_allocator.h"
#include "partition_alloc/buildflags.h"
#include "v8_platform_page_allocator.h"
namespace gin {
namespace {
base::LazyInstance<V8Platform>::Leaky g_v8_platform = …;
void PrintStackTrace() { … }
class ConvertableToTraceFormatWrapper final
: public base::trace_event::ConvertableToTraceFormat { … };
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
base::LazyInstance<gin::PageAllocator>::Leaky g_page_allocator = …;
#endif
base::TaskPriority ToBaseTaskPriority(v8::TaskPriority priority) { … }
class JobDelegateImpl : public v8::JobDelegate { … };
class JobHandleImpl : public v8::JobHandle { … };
class ScopedBlockingCallImpl : public v8::ScopedBlockingCall { … };
}
}
template <>
struct base::trace_event::TraceValue::Helper<
std::unique_ptr<v8::ConvertableToTraceFormat>> { … };
namespace gin {
class V8Platform::TracingControllerImpl : public v8::TracingController { … };
V8Platform* V8Platform::Get() { … }
V8Platform::V8Platform() : … { … }
V8Platform::~V8Platform() = default;
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
PageAllocator* V8Platform::GetPageAllocator() { … }
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
ThreadIsolatedAllocator* V8Platform::GetThreadIsolatedAllocator() { … }
#endif
void V8Platform::OnCriticalMemoryPressure() { … }
#endif
std::shared_ptr<v8::TaskRunner> V8Platform::GetForegroundTaskRunner(
v8::Isolate* isolate,
v8::TaskPriority priority) { … }
int V8Platform::NumberOfWorkerThreads() { … }
void V8Platform::PostTaskOnWorkerThreadImpl(
v8::TaskPriority priority,
std::unique_ptr<v8::Task> task,
const v8::SourceLocation& location) { … }
void V8Platform::PostDelayedTaskOnWorkerThreadImpl(
v8::TaskPriority priority,
std::unique_ptr<v8::Task> task,
double delay_in_seconds,
const v8::SourceLocation& location) { … }
std::unique_ptr<v8::JobHandle> V8Platform::CreateJobImpl(
v8::TaskPriority priority,
std::unique_ptr<v8::JobTask> job_task,
const v8::SourceLocation& location) { … }
std::unique_ptr<v8::ScopedBlockingCall> V8Platform::CreateBlockingScope(
v8::BlockingType blocking_type) { … }
bool V8Platform::IdleTasksEnabled(v8::Isolate* isolate) { … }
double V8Platform::MonotonicallyIncreasingTime() { … }
double V8Platform::CurrentClockTimeMillis() { … }
int64_t V8Platform::CurrentClockTimeMilliseconds() { … }
double V8Platform::CurrentClockTimeMillisecondsHighResolution() { … }
v8::TracingController* V8Platform::GetTracingController() { … }
v8::Platform::StackTracePrinter V8Platform::GetStackTracePrinter() { … }
}