5#ifndef V8_V8_PLATFORM_H_
6#define V8_V8_PLATFORM_H_
53 virtual void Run() = 0;
65 virtual void Run(
double deadline_in_seconds) = 0;
82 virtual void PostTask(std::unique_ptr<Task> task) {
115 double delay_in_seconds) {
139 double delay_in_seconds) {
188 double delay_in_seconds,
191 double delay_in_seconds,
377#if !defined(V8_USE_PERFETTO)
386 static uint8_t no = 0;
399 char phase,
const uint8_t* category_enabled_flag,
const char* name,
400 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
401 const char** arg_names,
const uint8_t* arg_types,
402 const uint64_t* arg_values,
403 std::unique_ptr<ConvertableToTraceFormat>* arg_convertables,
404 unsigned int flags) {
408 char phase,
const uint8_t* category_enabled_flag,
const char* name,
409 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
410 const char** arg_names,
const uint8_t* arg_types,
411 const uint64_t* arg_values,
412 std::unique_ptr<ConvertableToTraceFormat>* arg_convertables,
413 unsigned int flags, int64_t timestamp) {
422 const char* name, uint64_t handle) {}
506 virtual bool FreePages(
void* address,
size_t length) = 0;
512 size_t new_length) = 0;
570 virtual std::unique_ptr<SharedMemoryMapping>
RemapTo(
571 void* new_address)
const = 0;
599 size_t length,
const void* original_address) {
628 virtual void Free(
void*
object) = 0;
639 virtual int Pkey()
const {
return -1; }
667inline unsigned int MachMemoryEntryFromSharedMemoryHandle(
669 return static_cast<unsigned int>(handle);
677 return static_cast<uint32_t
>(handle);
686inline void* FileMappingFromSharedMemoryHandle(
688 return reinterpret_cast<void*
>(handle);
697 return static_cast<int>(handle);
768 size_t size()
const {
return size_; }
784 return (address >=
base()) && (address <
base() +
size());
1017 const size_t page_size_;
1018 const size_t allocation_granularity_;
1077 return &default_allocator;
1128 std::unique_ptr<Task> task,
1141 std::unique_ptr<Task> task,
1155 std::unique_ptr<Task> task,
1170 std::unique_ptr<Task> task,
double delay_in_seconds,
1173 std::move(task), delay_in_seconds,
1228 TaskPriority priority, std::unique_ptr<JobTask> job_task,
1230 auto handle =
CreateJob(priority, std::move(job_task), location);
1231 handle->NotifyConcurrencyIncrease();
1251 TaskPriority priority, std::unique_ptr<JobTask> job_task,
1253 return CreateJobImpl(priority, std::move(job_task), location);
1322 return &default_observer;
1337 TaskPriority priority, std::unique_ptr<JobTask> job_task,
1344 std::unique_ptr<Task> task,
virtual void LeaveSection()
virtual void EnterSection()
virtual ~IdleTask()=default
virtual void Run(double deadline_in_seconds)=0
virtual bool IsJoiningThread() const =0
virtual uint8_t GetTaskId()=0
virtual bool ShouldYield()=0
virtual void NotifyConcurrencyIncrease()=0
virtual void UpdatePriority(TaskPriority new_priority)
virtual bool UpdatePriorityEnabled() const
virtual void CancelAndDetach()=0
virtual bool IsActive()=0
virtual void NotifyConcurrencyIncrease()=0
virtual ~JobHandle()=default
virtual size_t GetMaxConcurrency(size_t worker_count) const =0
virtual void Run(JobDelegate *delegate)=0
virtual ~JobTask()=default
virtual std::unique_ptr< SharedMemoryMapping > RemapTo(void *new_address) const =0
virtual size_t GetSize() const =0
virtual void * GetMemory() const =0
virtual ~SharedMemory()=default
virtual ~SharedMemoryMapping()=default
virtual void * GetMemory() const =0
virtual std::unique_ptr< SharedMemory > AllocateSharedPages(size_t length, const void *original_address)
virtual bool SetPermissions(void *address, size_t length, Permission permissions)=0
virtual bool CanAllocateSharedPages()
virtual bool DecommitPages(void *address, size_t size)=0
virtual void * AllocatePages(void *address, size_t length, size_t alignment, Permission permissions)=0
virtual bool RecommitPages(void *address, size_t length, Permission permissions)
virtual void * GetRandomMmapAddr()=0
virtual size_t CommitPageSize()=0
virtual bool DiscardSystemPages(void *address, size_t size)
virtual bool ReserveForSharedMemoryMapping(void *address, size_t size)
virtual bool ReleasePages(void *address, size_t length, size_t new_length)=0
virtual void SetRandomMmapSeed(int64_t seed)=0
virtual ~PageAllocator()=default
virtual size_t AllocatePageSize()=0
virtual bool FreePages(void *address, size_t length)=0
virtual ~ScopedBlockingCall()=default
static constexpr SourceLocation Current()
virtual bool NonNestableTasksEnabled() const
virtual void PostIdleTaskImpl(std::unique_ptr< IdleTask > task, const SourceLocation &location)
virtual void PostNonNestableDelayedTaskImpl(std::unique_ptr< Task > task, double delay_in_seconds, const SourceLocation &location)
virtual void PostNonNestableDelayedTask(std::unique_ptr< Task > task, double delay_in_seconds)
virtual void PostNonNestableTaskImpl(std::unique_ptr< Task > task, const SourceLocation &location)
virtual void PostTaskImpl(std::unique_ptr< Task > task, const SourceLocation &location)
TaskRunner(const TaskRunner &)=delete
virtual void PostDelayedTask(std::unique_ptr< Task > task, double delay_in_seconds)
virtual bool NonNestableDelayedTasksEnabled() const
virtual void PostDelayedTaskImpl(std::unique_ptr< Task > task, double delay_in_seconds, const SourceLocation &location)
virtual void PostIdleTask(std::unique_ptr< IdleTask > task)
virtual bool IdleTasksEnabled()=0
virtual ~TaskRunner()=default
TaskRunner & operator=(const TaskRunner &)=delete
virtual void PostTask(std::unique_ptr< Task > task)
virtual void PostNonNestableTask(std::unique_ptr< Task > task)
virtual ~ThreadIsolatedAllocator()=default
virtual void Free(void *object)=0
static void SetDefaultPermissionsForSignalHandler()
virtual Type Type() const =0
virtual void * Allocate(size_t size)=0
virtual void OnTraceDisabled()=0
virtual ~TraceStateObserver()=default
virtual void OnTraceEnabled()=0
virtual const uint8_t * GetCategoryGroupEnabled(const char *name)
virtual void AddTraceStateObserver(TraceStateObserver *)
virtual ~TracingController()=default
virtual uint64_t AddTraceEventWithTimestamp(char phase, const uint8_t *category_enabled_flag, const char *name, const char *scope, uint64_t id, uint64_t bind_id, int32_t num_args, const char **arg_names, const uint8_t *arg_types, const uint64_t *arg_values, std::unique_ptr< ConvertableToTraceFormat > *arg_convertables, unsigned int flags, int64_t timestamp)
virtual void UpdateTraceEventDuration(const uint8_t *category_enabled_flag, const char *name, uint64_t handle)
virtual uint64_t AddTraceEvent(char phase, const uint8_t *category_enabled_flag, const char *name, const char *scope, uint64_t id, uint64_t bind_id, int32_t num_args, const char **arg_names, const uint8_t *arg_types, const uint64_t *arg_values, std::unique_ptr< ConvertableToTraceFormat > *arg_convertables, unsigned int flags)
virtual void RemoveTraceStateObserver(TraceStateObserver *)
bool Contains(Address address) const
virtual V8_WARN_UNUSED_RESULT bool DiscardSystemPages(Address address, size_t size)
static constexpr Address kNoHint
VirtualAddressSpace(size_t page_size, size_t allocation_granularity, Address base, size_t size, PagePermissions max_page_permissions)
virtual void SetRandomSeed(int64_t seed)=0
virtual V8_WARN_UNUSED_RESULT bool SetPagePermissions(Address address, size_t size, PagePermissions permissions)=0
size_t allocation_granularity() const
virtual V8_WARN_UNUSED_RESULT Address AllocateSharedPages(Address hint, size_t size, PagePermissions permissions, PlatformSharedMemoryHandle handle, uint64_t offset)=0
virtual void FreeGuardRegion(Address address, size_t size)=0
virtual V8_WARN_UNUSED_RESULT bool DecommitPages(Address address, size_t size)=0
virtual ~VirtualAddressSpace()=default
virtual std::unique_ptr< VirtualAddressSpace > AllocateSubspace(Address hint, size_t size, size_t alignment, PagePermissions max_page_permissions)=0
virtual V8_WARN_UNUSED_RESULT bool RecommitPages(Address address, size_t size, PagePermissions permissions)=0
virtual void FreeSharedPages(Address address, size_t size)=0
virtual V8_WARN_UNUSED_RESULT Address AllocatePages(Address hint, size_t size, size_t alignment, PagePermissions permissions)=0
virtual void FreePages(Address address, size_t size)=0
virtual bool CanAllocateSubspaces()=0
virtual Address RandomPageAddress()=0
PagePermissions max_page_permissions() const
virtual V8_WARN_UNUSED_RESULT bool AllocateGuardRegion(Address address, size_t size)=0
virtual MallocFn GetMallocFn() const
virtual FreeFn GetFreeFn() const
void *(*)(size_t) MallocFn
intptr_t PlatformSharedMemoryHandle
PlatformSharedMemoryHandle SharedMemoryHandleFromFileDescriptor(int fd)
int FileDescriptorFromSharedMemoryHandle(PlatformSharedMemoryHandle handle)
#define V8_WARN_UNUSED_RESULT