v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::internal::MicrotaskQueue Class Referencefinal

#include <microtask-queue.h>

Inheritance diagram for v8::internal::MicrotaskQueue:
Collaboration diagram for v8::internal::MicrotaskQueue:

Public Member Functions

 ~MicrotaskQueue () override
 
void EnqueueMicrotask (v8::Isolate *isolate, v8::Local< Function > microtask) override
 
void EnqueueMicrotask (v8::Isolate *isolate, v8::MicrotaskCallback callback, void *data) override
 
void PerformCheckpoint (v8::Isolate *isolate) override
 
bool ShouldPerfomCheckpoint () const
 
void EnqueueMicrotask (Tagged< Microtask > microtask)
 
void AddMicrotasksCompletedCallback (MicrotasksCompletedCallbackWithData callback, void *data) override
 
void RemoveMicrotasksCompletedCallback (MicrotasksCompletedCallbackWithData callback, void *data) override
 
bool IsRunningMicrotasks () const override
 
int RunMicrotasks (Isolate *isolate)
 
void IterateMicrotasks (RootVisitor *visitor)
 
void IncrementMicrotasksScopeDepth ()
 
void DecrementMicrotasksScopeDepth ()
 
int GetMicrotasksScopeDepth () const override
 
void IncrementMicrotasksSuppressions ()
 
void DecrementMicrotasksSuppressions ()
 
bool HasMicrotasksSuppressions () const
 
void set_microtasks_policy (v8::MicrotasksPolicy microtasks_policy)
 
v8::MicrotasksPolicy microtasks_policy () const
 
intptr_t capacity () const
 
intptr_t size () const
 
intptr_t start () const
 
Tagged< Microtaskget (intptr_t index) const
 
MicrotaskQueuenext () const
 
MicrotaskQueueprev () const
 
- Public Member Functions inherited from v8::MicrotaskQueue
 MicrotaskQueue (const MicrotaskQueue &)=delete
 
MicrotaskQueueoperator= (const MicrotaskQueue &)=delete
 

Static Public Member Functions

static void SetUpDefaultMicrotaskQueue (Isolate *isolate)
 
static std::unique_ptr< MicrotaskQueueNew (Isolate *isolate)
 
static Address CallEnqueueMicrotask (Isolate *isolate, intptr_t microtask_queue_pointer, Address raw_microtask)
 
- Static Public Member Functions inherited from v8::MicrotaskQueue
static std::unique_ptr< MicrotaskQueueNew (Isolate *isolate, MicrotasksPolicy policy=MicrotasksPolicy::kAuto)
 

Static Public Attributes

static const size_t kRingBufferOffset
 
static const size_t kCapacityOffset
 
static const size_t kSizeOffset = OFFSET_OF(MicrotaskQueue, size_)
 
static const size_t kStartOffset = OFFSET_OF(MicrotaskQueue, start_)
 
static const size_t kFinishedMicrotaskCountOffset
 
static const intptr_t kMinimumCapacity = 8
 

Private Types

using CallbackWithData
 

Private Member Functions

void PerformCheckpointInternal (v8::Isolate *v8_isolate)
 
void OnCompleted (Isolate *isolate)
 
 MicrotaskQueue ()
 
void ResizeBuffer (intptr_t new_capacity)
 

Private Attributes

intptr_t size_ = 0
 
intptr_t capacity_ = 0
 
intptr_t start_ = 0
 
Addressring_buffer_ = nullptr
 
intptr_t finished_microtask_count_ = 0
 
MicrotaskQueuenext_ = nullptr
 
MicrotaskQueueprev_ = nullptr
 
int microtasks_depth_ = 0
 
int microtasks_suppressions_ = 0
 
v8::MicrotasksPolicy microtasks_policy_ = v8::MicrotasksPolicy::kAuto
 
bool is_running_microtasks_ = false
 
bool is_running_completed_callbacks_ = false
 
std::vector< CallbackWithDatamicrotasks_completed_callbacks_
 
std::optional< std::vector< CallbackWithData > > microtasks_completed_callbacks_cow_
 

Detailed Description

Definition at line 27 of file microtask-queue.h.

Member Typedef Documentation

◆ CallbackWithData

Initial value:
std::pair<MicrotasksCompletedCallbackWithData, void*>

Definition at line 152 of file microtask-queue.h.

Constructor & Destructor Documentation

◆ ~MicrotaskQueue()

v8::internal::MicrotaskQueue::~MicrotaskQueue ( )
overridevirtual

Reimplemented from v8::MicrotaskQueue.

Definition at line 62 of file microtask-queue.cc.

◆ MicrotaskQueue()

v8::internal::MicrotaskQueue::MicrotaskQueue ( )
privatedefault
Here is the caller graph for this function:

Member Function Documentation

◆ AddMicrotasksCompletedCallback()

void v8::internal::MicrotaskQueue::AddMicrotasksCompletedCallback ( MicrotasksCompletedCallbackWithData callback,
void * data )
overridevirtual

Adds a callback to notify the embedder after microtasks were run. The callback is triggered by explicit RunMicrotasks call or automatic microtasks execution (see Isolate::SetMicrotasksPolicy).

Callback will trigger even if microtasks were attempted to run, but the microtasks queue was empty and no single microtask was actually executed.

Executing scripts inside the callback will not re-trigger microtasks and the callback.

Implements v8::MicrotaskQueue.

Definition at line 244 of file microtask-queue.cc.

◆ CallEnqueueMicrotask()

Address v8::internal::MicrotaskQueue::CallEnqueueMicrotask ( Isolate * isolate,
intptr_t microtask_queue_pointer,
Address raw_microtask )
static

Definition at line 72 of file microtask-queue.cc.

Here is the call graph for this function:

◆ capacity()

intptr_t v8::internal::MicrotaskQueue::capacity ( ) const
inline

Definition at line 101 of file microtask-queue.h.

◆ DecrementMicrotasksScopeDepth()

void v8::internal::MicrotaskQueue::DecrementMicrotasksScopeDepth ( )
inline

Definition at line 75 of file microtask-queue.h.

Here is the caller graph for this function:

◆ DecrementMicrotasksSuppressions()

void v8::internal::MicrotaskQueue::DecrementMicrotasksSuppressions ( )
inline

Definition at line 81 of file microtask-queue.h.

◆ EnqueueMicrotask() [1/3]

void v8::internal::MicrotaskQueue::EnqueueMicrotask ( Tagged< Microtask > microtask)

Definition at line 103 of file microtask-queue.cc.

Here is the call graph for this function:

◆ EnqueueMicrotask() [2/3]

void v8::internal::MicrotaskQueue::EnqueueMicrotask ( v8::Isolate * isolate,
v8::Local< Function > microtask )
overridevirtual

Enqueues the callback to the queue.

Implements v8::MicrotaskQueue.

Definition at line 81 of file microtask-queue.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnqueueMicrotask() [3/3]

void v8::internal::MicrotaskQueue::EnqueueMicrotask ( v8::Isolate * isolate,
v8::MicrotaskCallback callback,
void * data )
overridevirtual

Enqueues the callback to the queue.

Implements v8::MicrotaskQueue.

Definition at line 90 of file microtask-queue.cc.

Here is the call graph for this function:

◆ get()

Tagged< Microtask > v8::internal::MicrotaskQueue::get ( intptr_t index) const

Definition at line 305 of file microtask-queue.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMicrotasksScopeDepth()

int v8::internal::MicrotaskQueue::GetMicrotasksScopeDepth ( ) const
inlineoverridevirtual

Returns the current depth of nested MicrotasksScope that has kRunMicrotasks.

Implements v8::MicrotaskQueue.

Definition at line 76 of file microtask-queue.h.

◆ HasMicrotasksSuppressions()

bool v8::internal::MicrotaskQueue::HasMicrotasksSuppressions ( ) const
inline

Definition at line 82 of file microtask-queue.h.

◆ IncrementMicrotasksScopeDepth()

void v8::internal::MicrotaskQueue::IncrementMicrotasksScopeDepth ( )
inline

Definition at line 74 of file microtask-queue.h.

Here is the caller graph for this function:

◆ IncrementMicrotasksSuppressions()

void v8::internal::MicrotaskQueue::IncrementMicrotasksSuppressions ( )
inline

Definition at line 80 of file microtask-queue.h.

Here is the caller graph for this function:

◆ IsRunningMicrotasks()

bool v8::internal::MicrotaskQueue::IsRunningMicrotasks ( ) const
inlineoverridevirtual

Returns true if a microtask is running on this MicrotaskQueue instance.

Implements v8::MicrotaskQueue.

Definition at line 61 of file microtask-queue.h.

◆ IterateMicrotasks()

void v8::internal::MicrotaskQueue::IterateMicrotasks ( RootVisitor * visitor)

Definition at line 217 of file microtask-queue.cc.

Here is the call graph for this function:

◆ microtasks_policy()

v8::MicrotasksPolicy v8::internal::MicrotaskQueue::microtasks_policy ( ) const
inline

Definition at line 99 of file microtask-queue.h.

Here is the caller graph for this function:

◆ New()

std::unique_ptr< MicrotaskQueue > v8::internal::MicrotaskQueue::New ( Isolate * isolate)
static

Definition at line 45 of file microtask-queue.cc.

Here is the call graph for this function:

◆ next()

MicrotaskQueue * v8::internal::MicrotaskQueue::next ( ) const
inline

Definition at line 107 of file microtask-queue.h.

◆ OnCompleted()

void v8::internal::MicrotaskQueue::OnCompleted ( Isolate * isolate)
private

Definition at line 292 of file microtask-queue.cc.

Here is the caller graph for this function:

◆ PerformCheckpoint()

void v8::internal::MicrotaskQueue::PerformCheckpoint ( v8::Isolate * isolate)
inlineoverridevirtual

Runs microtasks if no microtask is running on this MicrotaskQueue instance.

Implements v8::MicrotaskQueue.

Definition at line 46 of file microtask-queue.h.

Here is the caller graph for this function:

◆ PerformCheckpointInternal()

void v8::internal::MicrotaskQueue::PerformCheckpointInternal ( v8::Isolate * v8_isolate)
private

Definition at line 116 of file microtask-queue.cc.

Here is the call graph for this function:

◆ prev()

MicrotaskQueue * v8::internal::MicrotaskQueue::prev ( ) const
inline

Definition at line 108 of file microtask-queue.h.

◆ RemoveMicrotasksCompletedCallback()

void v8::internal::MicrotaskQueue::RemoveMicrotasksCompletedCallback ( MicrotasksCompletedCallbackWithData callback,
void * data )
overridevirtual

Removes callback that was installed by AddMicrotasksCompletedCallback.

Implements v8::MicrotaskQueue.

Definition at line 268 of file microtask-queue.cc.

◆ ResizeBuffer()

void v8::internal::MicrotaskQueue::ResizeBuffer ( intptr_t new_capacity)
private

Definition at line 311 of file microtask-queue.cc.

Here is the caller graph for this function:

◆ RunMicrotasks()

int v8::internal::MicrotaskQueue::RunMicrotasks ( Isolate * isolate)

Definition at line 153 of file microtask-queue.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_microtasks_policy()

void v8::internal::MicrotaskQueue::set_microtasks_policy ( v8::MicrotasksPolicy microtasks_policy)
inline

Definition at line 96 of file microtask-queue.h.

◆ SetUpDefaultMicrotaskQueue()

void v8::internal::MicrotaskQueue::SetUpDefaultMicrotaskQueue ( Isolate * isolate)
static

Definition at line 35 of file microtask-queue.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShouldPerfomCheckpoint()

bool v8::internal::MicrotaskQueue::ShouldPerfomCheckpoint ( ) const
inline

Definition at line 51 of file microtask-queue.h.

Here is the caller graph for this function:

◆ size()

intptr_t v8::internal::MicrotaskQueue::size ( ) const
inline

Definition at line 102 of file microtask-queue.h.

Here is the caller graph for this function:

◆ start()

intptr_t v8::internal::MicrotaskQueue::start ( ) const
inline

Definition at line 103 of file microtask-queue.h.

Member Data Documentation

◆ capacity_

intptr_t v8::internal::MicrotaskQueue::capacity_ = 0
private

Definition at line 130 of file microtask-queue.h.

◆ finished_microtask_count_

intptr_t v8::internal::MicrotaskQueue::finished_microtask_count_ = 0
private

Definition at line 135 of file microtask-queue.h.

◆ is_running_completed_callbacks_

bool v8::internal::MicrotaskQueue::is_running_completed_callbacks_ = false
private

Definition at line 151 of file microtask-queue.h.

◆ is_running_microtasks_

bool v8::internal::MicrotaskQueue::is_running_microtasks_ = false
private

Definition at line 150 of file microtask-queue.h.

◆ kCapacityOffset

const size_t v8::internal::MicrotaskQueue::kCapacityOffset
static
Initial value:

Definition at line 111 of file microtask-queue.h.

◆ kFinishedMicrotaskCountOffset

const size_t v8::internal::MicrotaskQueue::kFinishedMicrotaskCountOffset
static
Initial value:

Definition at line 114 of file microtask-queue.h.

◆ kMinimumCapacity

const intptr_t v8::internal::MicrotaskQueue::kMinimumCapacity = 8
static

Definition at line 116 of file microtask-queue.h.

◆ kRingBufferOffset

const size_t v8::internal::MicrotaskQueue::kRingBufferOffset
static
Initial value:

Definition at line 110 of file microtask-queue.h.

◆ kSizeOffset

const size_t v8::internal::MicrotaskQueue::kSizeOffset = OFFSET_OF(MicrotaskQueue, size_)
static

Definition at line 112 of file microtask-queue.h.

◆ kStartOffset

const size_t v8::internal::MicrotaskQueue::kStartOffset = OFFSET_OF(MicrotaskQueue, start_)
static

Definition at line 113 of file microtask-queue.h.

◆ microtasks_completed_callbacks_

std::vector<CallbackWithData> v8::internal::MicrotaskQueue::microtasks_completed_callbacks_
private

Definition at line 154 of file microtask-queue.h.

◆ microtasks_completed_callbacks_cow_

std::optional<std::vector<CallbackWithData> > v8::internal::MicrotaskQueue::microtasks_completed_callbacks_cow_
private

Definition at line 156 of file microtask-queue.h.

◆ microtasks_depth_

int v8::internal::MicrotaskQueue::microtasks_depth_ = 0
private

Definition at line 142 of file microtask-queue.h.

◆ microtasks_policy_

v8::MicrotasksPolicy v8::internal::MicrotaskQueue::microtasks_policy_ = v8::MicrotasksPolicy::kAuto
private

Definition at line 148 of file microtask-queue.h.

◆ microtasks_suppressions_

int v8::internal::MicrotaskQueue::microtasks_suppressions_ = 0
private

Definition at line 143 of file microtask-queue.h.

◆ next_

MicrotaskQueue* v8::internal::MicrotaskQueue::next_ = nullptr
private

Definition at line 139 of file microtask-queue.h.

◆ prev_

MicrotaskQueue* v8::internal::MicrotaskQueue::prev_ = nullptr
private

Definition at line 140 of file microtask-queue.h.

◆ ring_buffer_

Address* v8::internal::MicrotaskQueue::ring_buffer_ = nullptr
private

Definition at line 132 of file microtask-queue.h.

◆ size_

intptr_t v8::internal::MicrotaskQueue::size_ = 0
private

Definition at line 129 of file microtask-queue.h.

◆ start_

intptr_t v8::internal::MicrotaskQueue::start_ = 0
private

Definition at line 131 of file microtask-queue.h.


The documentation for this class was generated from the following files: