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

#include <js-atomics-synchronization.h>

Inheritance diagram for v8::internal::JSAtomicsMutex:
Collaboration diagram for v8::internal::JSAtomicsMutex:

Classes

class  LockGuard
 
class  LockGuardBase
 
class  TryLockGuard
 

Public Types

enum  { kMutexAsyncContextSlot = Context::MIN_CONTEXT_SLOTS , kUnlockedPromiseAsyncContextSlot , kAsyncLockedWaiterAsyncContextSlot , kAsyncContextLength }
 
using AsyncWaiterNodeType = LockAsyncWaiterQueueNode
 

Public Member Functions

V8_WARN_UNUSED_RESULT bool TryLock ()
 
void Unlock (Isolate *requester)
 
bool IsHeld ()
 
bool IsCurrentThreadOwner ()
 
void UnlockAsyncLockedMutex (Isolate *requester, DirectHandle< Foreign > async_locked_waiter_wrapper)
 

Static Public Member Functions

static DirectHandle< JSObjectCreateResultObject (Isolate *isolate, DirectHandle< Object > value, bool success)
 
static bool Lock (Isolate *requester, DirectHandle< JSAtomicsMutex > mutex, std::optional< base::TimeDelta > timeout=std::nullopt)
 
static bool LockAsync (Isolate *requester, DirectHandle< JSAtomicsMutex > mutex, Handle< JSPromise > internal_locked_promise, MaybeHandle< JSPromise > unlocked_promise, AsyncWaiterNodeType **waiter_node, std::optional< base::TimeDelta > timeout=std::nullopt)
 
static DirectHandle< JSPromiseLockAsyncWrapperForWait (Isolate *requester, DirectHandle< JSAtomicsMutex > mutex)
 
static MaybeDirectHandle< JSPromiseLockOrEnqueuePromise (Isolate *isolate, DirectHandle< JSAtomicsMutex > mutex, DirectHandle< Object > callback, std::optional< base::TimeDelta > timeout)
 
static bool LockOrEnqueueAsyncNode (Isolate *isolate, DirectHandle< JSAtomicsMutex > mutex, LockAsyncWaiterQueueNode *node)
 
static void HandleAsyncNotify (LockAsyncWaiterQueueNode *node)
 
static void HandleAsyncTimeout (LockAsyncWaiterQueueNode *node)
 
static void CleanupMatchingAsyncWaiters (Isolate *isolate, WaiterQueueNode *node, DequeueMatcher matcher)
 

Private Types

using IsLockedField = JSSynchronizationPrimitive::NextBitField<bool, 1>
 

Private Member Functions

void SetCurrentThreadAsOwner ()
 
void ClearOwnerThread ()
 
std::atomic< int32_t > * AtomicOwnerThreadIdPtr ()
 
V8_EXPORT_PRIVATE void UnlockSlowPath (Isolate *requester, std::atomic< StateT > *state)
 
bool LockJSMutexOrDequeueTimedOutWaiter (Isolate *requester, std::atomic< StateT > *state, WaiterQueueNode *timed_out_waiter)
 

Static Private Member Functions

static V8_EXPORT_PRIVATE bool LockSlowPath (Isolate *requester, DirectHandle< JSAtomicsMutex > mutex, std::atomic< StateT > *state, std::optional< base::TimeDelta > timeout)
 
static bool LockAsyncSlowPath (Isolate *isolate, DirectHandle< JSAtomicsMutex > mutex, std::atomic< StateT > *state, Handle< JSPromise > internal_locked_promise, MaybeHandle< JSPromise > unlocked_promise, AsyncWaiterNodeType **waiter_node, std::optional< base::TimeDelta > timeout)
 
static bool TryLockExplicit (std::atomic< StateT > *state, StateT &expected)
 
static std::optional< WaiterQueueLockGuardLockWaiterQueueOrJSMutex (std::atomic< StateT > *state, StateT &current_state)
 
static V8_EXPORT_PRIVATE bool MutexTryLock (Isolate *requester, DirectHandle< JSAtomicsMutex > mutex, std::atomic< StateT > *state)
 
static V8_INLINE bool BackoffTryLock (Isolate *requester, DirectHandle< JSAtomicsMutex > mutex, std::atomic< StateT > *state)
 
static bool DequeueTimedOutAsyncWaiter (Isolate *requester, DirectHandle< JSAtomicsMutex > mutex, std::atomic< StateT > *state, WaiterQueueNode *timed_out_waiter)
 
static V8_EXPORT_PRIVATE bool MaybeEnqueueNode (Isolate *requester, DirectHandle< JSAtomicsMutex > mutex, std::atomic< StateT > *state, WaiterQueueNode *this_waiter)
 
template<typename LockSlowPathWrapper , typename = std::enable_if<std::is_invocable_r_v< bool, LockSlowPathWrapper, std::atomic<StateT>*>>>
static bool LockImpl (Isolate *requester, DirectHandle< JSAtomicsMutex > mutex, std::optional< base::TimeDelta > timeout, LockSlowPathWrapper slow_path_wrapper)
 

Static Private Attributes

static constexpr StateT kUnlockedUncontended = kEmptyState
 
static constexpr StateT kLockedUncontended = IsLockedField::encode(true)
 

Friends

class Factory
 

Detailed Description

Definition at line 173 of file js-atomics-synchronization.h.

Member Typedef Documentation

◆ AsyncWaiterNodeType

◆ IsLockedField

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kMutexAsyncContextSlot 
kUnlockedPromiseAsyncContextSlot 
kAsyncLockedWaiterAsyncContextSlot 
kAsyncContextLength 

Definition at line 275 of file js-atomics-synchronization.h.

Member Function Documentation

◆ AtomicOwnerThreadIdPtr()

std::atomic< int32_t > * v8::internal::JSAtomicsMutex::AtomicOwnerThreadIdPtr ( )
inlineprivate

Definition at line 244 of file js-atomics-synchronization-inl.h.

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

◆ BackoffTryLock()

bool v8::internal::JSAtomicsMutex::BackoffTryLock ( Isolate * requester,
DirectHandle< JSAtomicsMutex > mutex,
std::atomic< StateT > * state )
staticprivate

Definition at line 598 of file js-atomics-synchronization.cc.

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

◆ CleanupMatchingAsyncWaiters()

void v8::internal::JSAtomicsMutex::CleanupMatchingAsyncWaiters ( Isolate * isolate,
WaiterQueueNode * node,
DequeueMatcher matcher )
static

Definition at line 529 of file js-atomics-synchronization.cc.

Here is the call graph for this function:

◆ ClearOwnerThread()

void v8::internal::JSAtomicsMutex::ClearOwnerThread ( )
inlineprivate

Definition at line 239 of file js-atomics-synchronization-inl.h.

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

◆ CreateResultObject()

DirectHandle< JSObject > v8::internal::JSAtomicsMutex::CreateResultObject ( Isolate * isolate,
DirectHandle< Object > value,
bool success )
static

Definition at line 516 of file js-atomics-synchronization.cc.

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

◆ DequeueTimedOutAsyncWaiter()

bool v8::internal::JSAtomicsMutex::DequeueTimedOutAsyncWaiter ( Isolate * requester,
DirectHandle< JSAtomicsMutex > mutex,
std::atomic< StateT > * state,
WaiterQueueNode * timed_out_waiter )
staticprivate

Definition at line 978 of file js-atomics-synchronization.cc.

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

◆ HandleAsyncNotify()

void v8::internal::JSAtomicsMutex::HandleAsyncNotify ( LockAsyncWaiterQueueNode * node)
static

Definition at line 1057 of file js-atomics-synchronization.cc.

Here is the call graph for this function:

◆ HandleAsyncTimeout()

void v8::internal::JSAtomicsMutex::HandleAsyncTimeout ( LockAsyncWaiterQueueNode * node)
static

Definition at line 1019 of file js-atomics-synchronization.cc.

Here is the call graph for this function:

◆ IsCurrentThreadOwner()

bool v8::internal::JSAtomicsMutex::IsCurrentThreadOwner ( )
inline

Definition at line 227 of file js-atomics-synchronization-inl.h.

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

◆ IsHeld()

bool v8::internal::JSAtomicsMutex::IsHeld ( )
inline

Definition at line 222 of file js-atomics-synchronization-inl.h.

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

◆ Lock()

bool v8::internal::JSAtomicsMutex::Lock ( Isolate * requester,
DirectHandle< JSAtomicsMutex > mutex,
std::optional< base::TimeDelta > timeout = std::nullopt )
inlinestatic

Definition at line 182 of file js-atomics-synchronization-inl.h.

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

◆ LockAsync()

bool v8::internal::JSAtomicsMutex::LockAsync ( Isolate * requester,
DirectHandle< JSAtomicsMutex > mutex,
Handle< JSPromise > internal_locked_promise,
MaybeHandle< JSPromise > unlocked_promise,
AsyncWaiterNodeType ** waiter_node,
std::optional< base::TimeDelta > timeout = std::nullopt )
static

Definition at line 862 of file js-atomics-synchronization.cc.

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

◆ LockAsyncSlowPath()

bool v8::internal::JSAtomicsMutex::LockAsyncSlowPath ( Isolate * isolate,
DirectHandle< JSAtomicsMutex > mutex,
std::atomic< StateT > * state,
Handle< JSPromise > internal_locked_promise,
MaybeHandle< JSPromise > unlocked_promise,
AsyncWaiterNodeType ** waiter_node,
std::optional< base::TimeDelta > timeout )
staticprivate

Definition at line 902 of file js-atomics-synchronization.cc.

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

◆ LockAsyncWrapperForWait()

DirectHandle< JSPromise > v8::internal::JSAtomicsMutex::LockAsyncWrapperForWait ( Isolate * requester,
DirectHandle< JSAtomicsMutex > mutex )
static

Definition at line 892 of file js-atomics-synchronization.cc.

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

◆ LockImpl()

template<typename LockSlowPathWrapper , typename >
bool v8::internal::JSAtomicsMutex::LockImpl ( Isolate * requester,
DirectHandle< JSAtomicsMutex > mutex,
std::optional< base::TimeDelta > timeout,
LockSlowPathWrapper slow_path_wrapper )
inlinestaticprivate

Definition at line 154 of file js-atomics-synchronization-inl.h.

Here is the caller graph for this function:

◆ LockJSMutexOrDequeueTimedOutWaiter()

bool v8::internal::JSAtomicsMutex::LockJSMutexOrDequeueTimedOutWaiter ( Isolate * requester,
std::atomic< StateT > * state,
WaiterQueueNode * timed_out_waiter )
private

Definition at line 669 of file js-atomics-synchronization.cc.

Here is the call graph for this function:

◆ LockOrEnqueueAsyncNode()

bool v8::internal::JSAtomicsMutex::LockOrEnqueueAsyncNode ( Isolate * isolate,
DirectHandle< JSAtomicsMutex > mutex,
LockAsyncWaiterQueueNode * node )
static

Definition at line 938 of file js-atomics-synchronization.cc.

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

◆ LockOrEnqueuePromise()

MaybeDirectHandle< JSPromise > v8::internal::JSAtomicsMutex::LockOrEnqueuePromise ( Isolate * isolate,
DirectHandle< JSAtomicsMutex > mutex,
DirectHandle< Object > callback,
std::optional< base::TimeDelta > timeout )
static

Definition at line 821 of file js-atomics-synchronization.cc.

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

◆ LockSlowPath()

bool v8::internal::JSAtomicsMutex::LockSlowPath ( Isolate * requester,
DirectHandle< JSAtomicsMutex > mutex,
std::atomic< StateT > * state,
std::optional< base::TimeDelta > timeout )
staticprivate

Definition at line 736 of file js-atomics-synchronization.cc.

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

◆ LockWaiterQueueOrJSMutex()

std::optional< WaiterQueueLockGuard > v8::internal::JSAtomicsMutex::LockWaiterQueueOrJSMutex ( std::atomic< StateT > * state,
StateT & current_state )
staticprivate

Definition at line 655 of file js-atomics-synchronization.cc.

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

◆ MaybeEnqueueNode()

bool v8::internal::JSAtomicsMutex::MaybeEnqueueNode ( Isolate * requester,
DirectHandle< JSAtomicsMutex > mutex,
std::atomic< StateT > * state,
WaiterQueueNode * this_waiter )
staticprivate

Definition at line 621 of file js-atomics-synchronization.cc.

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

◆ MutexTryLock()

static V8_EXPORT_PRIVATE bool v8::internal::JSAtomicsMutex::MutexTryLock ( Isolate * requester,
DirectHandle< JSAtomicsMutex > mutex,
std::atomic< StateT > * state )
staticprivate

◆ SetCurrentThreadAsOwner()

void v8::internal::JSAtomicsMutex::SetCurrentThreadAsOwner ( )
inlineprivate

Definition at line 234 of file js-atomics-synchronization-inl.h.

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

◆ TryLock()

bool v8::internal::JSAtomicsMutex::TryLock ( )
inline

Definition at line 190 of file js-atomics-synchronization-inl.h.

Here is the call graph for this function:

◆ TryLockExplicit()

bool v8::internal::JSAtomicsMutex::TryLockExplicit ( std::atomic< StateT > * state,
StateT & expected )
staticprivate

Definition at line 589 of file js-atomics-synchronization.cc.

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

◆ Unlock()

void v8::internal::JSAtomicsMutex::Unlock ( Isolate * requester)
inline

Definition at line 202 of file js-atomics-synchronization-inl.h.

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

◆ UnlockAsyncLockedMutex()

void v8::internal::JSAtomicsMutex::UnlockAsyncLockedMutex ( Isolate * requester,
DirectHandle< Foreign > async_locked_waiter_wrapper )

Definition at line 951 of file js-atomics-synchronization.cc.

Here is the call graph for this function:

◆ UnlockSlowPath()

void v8::internal::JSAtomicsMutex::UnlockSlowPath ( Isolate * requester,
std::atomic< StateT > * state )
private

Definition at line 780 of file js-atomics-synchronization.cc.

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

Friends And Related Symbol Documentation

◆ Factory

friend class Factory
friend

Definition at line 296 of file js-atomics-synchronization.h.

Member Data Documentation

◆ kLockedUncontended

StateT v8::internal::JSAtomicsMutex::kLockedUncontended = IsLockedField::encode(true)
staticconstexprprivate

Definition at line 304 of file js-atomics-synchronization.h.

◆ kUnlockedUncontended

StateT v8::internal::JSAtomicsMutex::kUnlockedUncontended = kEmptyState
staticconstexprprivate

Definition at line 303 of file js-atomics-synchronization.h.


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