#include "src/execution/futex-emulation.h"
#include <limits>
#include "src/api/api-inl.h"
#include "src/base/lazy-instance.h"
#include "src/base/logging.h"
#include "src/base/macros.h"
#include "src/base/small-map.h"
#include "src/execution/isolate.h"
#include "src/execution/vm-state-inl.h"
#include "src/handles/handles-inl.h"
#include "src/numbers/conversions.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-promise-inl.h"
#include "src/objects/objects-inl.h"
#include "src/tasks/cancelable-task.h"
namespace v8::internal {
AtomicsWaitEvent;
class FutexWaitList { … };
namespace {
DEFINE_LAZY_LEAKY_OBJECT_GETTER(…)
}
bool FutexWaitListNode::CancelTimeoutTask() { … }
void FutexWaitListNode::NotifyWake() { … }
class ResolveAsyncWaiterPromisesTask : public CancelableTask { … };
class AsyncWaiterTimeoutTask : public CancelableTask { … };
void FutexEmulation::NotifyAsyncWaiter(FutexWaitListNode* node) { … }
void FutexWaitList::AddNode(FutexWaitListNode* node) { … }
void FutexWaitList::RemoveNode(FutexWaitListNode* node) { … }
void AtomicsWaitWakeHandle::Wake() { … }
enum WaitReturnValue : int { … };
namespace {
Tagged<Object> WaitJsTranslateReturn(Isolate* isolate, Tagged<Object> res) { … }
}
Tagged<Object> FutexEmulation::WaitJs32(Isolate* isolate, WaitMode mode,
Handle<JSArrayBuffer> array_buffer,
size_t addr, int32_t value,
double rel_timeout_ms) { … }
Tagged<Object> FutexEmulation::WaitJs64(Isolate* isolate, WaitMode mode,
Handle<JSArrayBuffer> array_buffer,
size_t addr, int64_t value,
double rel_timeout_ms) { … }
Tagged<Object> FutexEmulation::WaitWasm32(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer,
size_t addr, int32_t value,
int64_t rel_timeout_ns) { … }
Tagged<Object> FutexEmulation::WaitWasm64(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer,
size_t addr, int64_t value,
int64_t rel_timeout_ns) { … }
template <typename T>
Tagged<Object> FutexEmulation::Wait(Isolate* isolate, WaitMode mode,
Handle<JSArrayBuffer> array_buffer,
size_t addr, T value,
double rel_timeout_ms) { … }
namespace {
double WaitTimeoutInMs(double timeout_ns) { … }
}
template <typename T>
Tagged<Object> FutexEmulation::Wait(Isolate* isolate, WaitMode mode,
Handle<JSArrayBuffer> array_buffer,
size_t addr, T value, bool use_timeout,
int64_t rel_timeout_ns,
CallType call_type) { … }
template <typename T>
Tagged<Object> FutexEmulation::WaitSync(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer,
size_t addr, T value, bool use_timeout,
int64_t rel_timeout_ns,
CallType call_type) { … }
namespace {
template <typename T>
Global<T> GetWeakGlobal(Isolate* isolate, Local<T> object) { … }
}
FutexWaitListNode::FutexWaitListNode(std::weak_ptr<BackingStore> backing_store,
void* wait_location,
Handle<JSObject> promise, Isolate* isolate)
: … { … }
template <typename T>
Tagged<Object> FutexEmulation::WaitAsync(
Isolate* isolate, DirectHandle<JSArrayBuffer> array_buffer, size_t addr,
T value, bool use_timeout, int64_t rel_timeout_ns, CallType call_type) { … }
int FutexEmulation::Wake(Tagged<JSArrayBuffer> array_buffer, size_t addr,
uint32_t num_waiters_to_wake) { … }
int FutexEmulation::Wake(void* wait_location, uint32_t num_waiters_to_wake) { … }
void FutexEmulation::CleanupAsyncWaiterPromise(FutexWaitListNode* node) { … }
void FutexEmulation::ResolveAsyncWaiterPromise(FutexWaitListNode* node) { … }
void FutexEmulation::ResolveAsyncWaiterPromises(Isolate* isolate) { … }
void FutexEmulation::HandleAsyncWaiterTimeout(FutexWaitListNode* node) { … }
void FutexEmulation::IsolateDeinit(Isolate* isolate) { … }
int FutexEmulation::NumWaitersForTesting(Tagged<JSArrayBuffer> array_buffer,
size_t addr) { … }
int FutexEmulation::NumUnresolvedAsyncPromisesForTesting(
Tagged<JSArrayBuffer> array_buffer, size_t addr) { … }
void FutexWaitList::Verify() const { … }
bool FutexWaitList::NodeIsOnList(FutexWaitListNode* node,
FutexWaitListNode* head) { … }
}