36 return size == 1 || size == 2 || size == 4 || size == 8;
45 return *isolate->factory()->ToBoolean(
52 bool only_int32_and_big_int64 =
false) {
53 if (IsJSTypedArray(*
object)) {
56 if (typed_array->IsDetachedOrOutOfBounds()) {
58 isolate, NewTypeError(MessageTemplate::kDetachedOperation,
59 isolate->factory()->NewStringFromAsciiChecked(
63 if (only_int32_and_big_int64) {
77 isolate, NewTypeError(only_int32_and_big_int64
78 ? MessageTemplate::kNotInt32OrBigInt64TypedArray
79 : MessageTemplate::kNotIntegerTypedArray,
90 isolate, access_index_obj,
92 MessageTemplate::kInvalidAtomicAccessIndex),
96 size_t typed_array_length = typed_array->GetLength();
98 access_index >= typed_array_length) {
99 isolate->Throw(*isolate->factory()->NewRangeError(
100 MessageTemplate::kInvalidAtomicAccessIndex));
108inline size_t GetAddress64(
size_t index,
size_t byte_offset) {
109 return (index << 3) + byte_offset;
112inline size_t GetAddress32(
size_t index,
size_t byte_offset) {
113 return (index << 2) + byte_offset;
144 if (IsUndefined(*
count, isolate)) {
150 if (count_double < 0) {
155 c =
static_cast<uint32_t
>(count_double);
170 wake_addr = GetAddress64(
i, sta->byte_offset());
173 wake_addr = GetAddress32(
i, sta->byte_offset());
191 isolate, NewTypeError(MessageTemplate::kNotSharedTypedArray, array));
204 BigInt::FromObject(isolate, value));
213 double timeout_number;
214 if (IsUndefined(*timeout, isolate)) {
221 if (std::isnan(timeout_number))
224 else if (timeout_number < 0)
232 !isolate->allow_atomics_wait()) {
234 isolate, NewTypeError(MessageTemplate::kAtomicsOperationNotAllowed,
235 isolate->factory()->NewStringFromAsciiChecked(
243 isolate, mode, array_buffer, GetAddress64(
i, sta->byte_offset()),
248 GetAddress32(
i, sta->byte_offset()),
280 Isolate* isolate, DirectHandle<Object> iteration_number) {
281 constexpr char method_name[] =
"Atomics.pause";
287 if (std::isfinite(iter) && nearbyint(iter) == iter) {
294 NewError(isolate->type_error_function(),
295 MessageTemplate::kArgumentIsNotUndefinedOrInteger,
296 isolate->factory()->NewStringFromAsciiChecked(method_name)),
308 if (
V8_UNLIKELY(!IsUndefined(*iteration_number, isolate) &&
309 !
IsSmi(*iteration_number))) {
311 isolate, CheckAtomicsPauseIterationNumber(isolate, iteration_number),
V8_INLINE T FromJust() const &
V8_INLINE bool IsNothing() const
static Tagged< Object > WaitJs64(Isolate *isolate, WaitMode mode, DirectHandle< JSArrayBuffer > array_buffer, size_t addr, int64_t value, double rel_timeout_ms)
static Tagged< Object > WaitJs32(Isolate *isolate, WaitMode mode, DirectHandle< JSArrayBuffer > array_buffer, size_t addr, int32_t value, double rel_timeout_ms)
static V8_EXPORT_PRIVATE int Wake(Tagged< JSArrayBuffer > array_buffer, size_t addr, uint32_t num_waiters_to_wake)
static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ToNumber(Isolate *isolate, HandleType< T > input)
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType ToIndex(Isolate *isolate, HandleType< T > input, MessageTemplate error_index)
static double NumberValue(Tagged< Number > obj)
static V8_WARN_UNUSED_RESULT Maybe< double > IntegerValue(Isolate *isolate, HandleType< T > input)
static V8_EXPORT_PRIVATE bool ToInt32(Tagged< Object > obj, int32_t *value)
static constexpr Tagged< Smi > FromInt(int value)
static constexpr Tagged< Smi > zero()
#define THROW_NEW_ERROR_RETURN_VALUE(isolate, call, value)
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
#define THROW_NEW_ERROR(isolate, call)
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call)
#define MAYBE_RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
#define MAYBE_ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
base::Vector< const DirectHandle< Object > > args
V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSTypedArray > ValidateIntegerTypedArray(Isolate *isolate, Handle< Object > object, const char *method_name, bool only_int32_and_big_int64=false)
bool IsNumber(Tagged< Object > obj)
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
bool AtomicIsLockFree(double size)
int32_t NumberToInt32(Tagged< Object > number)
V8_WARN_UNUSED_RESULT Maybe< size_t > ValidateAtomicAccess(Isolate *isolate, DirectHandle< JSTypedArray > typed_array, Handle< Object > request_index)
Tagged< Object > DoWait(Isolate *isolate, FutexEmulation::WaitMode mode, Handle< Object > array, Handle< Object > index, Handle< Object > value, Handle< Object > timeout)
@ kExternalUint8ClampedArray
bool TryNumberToSize(Tagged< Object > number, size_t *result)
constexpr uint32_t kMaxUInt32
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Maybe< T > Just(const T &t)
#define DCHECK(condition)
#define V8_WARN_UNUSED_RESULT
#define V8_UNLIKELY(condition)