5#ifndef V8_OBJECTS_JS_ARRAY_BUFFER_H_
6#define V8_OBJECTS_JS_ARRAY_BUFFER_H_
13#include "torque-generated/bit-fields.h"
21class ArrayBufferExtension;
23#include "torque-generated/src/objects/js-array-buffer-tq.inc"
26 :
public TorqueGeneratedJSArrayBuffer<JSArrayBuffer,
27 JSAPIObjectWithEmbedderSlots> {
34 static constexpr size_t kMaxByteLength = kMaxSafeBufferSizeForSandbox;
35#elif V8_HOST_ARCH_32_BIT
65 DEFINE_TORQUE_GENERATED_JS_ARRAY_BUFFER_FLAGS()
126 Isolate* isolate,
size_t byte_length,
size_t max_byte_length,
127 ShouldThrow should_throw,
size_t* page_size,
size_t* initial_pages,
130 static std::optional<MessageTemplate>
132 Isolate* isolate,
size_t byte_length,
size_t max_byte_length,
133 size_t* page_size,
size_t* initial_pages,
size_t* max_pages);
138 Isolate* isolate, std::shared_ptr<BackingStore> backing_store);
174#if V8_COMPRESS_POINTERS
194#ifdef V8_COMPRESS_POINTERS
195 :
public ExternalPointerTable::ManagedResource {
218 AgeField::encode(static_cast<uint8_t>(age))) {}
248 std::memory_order_relaxed)};
252 std::memory_order_relaxed)};
258 std::memory_order_relaxed)};
275 std::memory_order_relaxed)};
300 :
public TorqueGeneratedJSArrayBufferView<JSArrayBufferView,
301 JSAPIObjectWithEmbedderSlots> {
314 DEFINE_TORQUE_GENERATED_JS_ARRAY_BUFFER_VIEW_FLAGS()
316 inline bool WasDetached()
const;
320 inline bool IsVariableLength()
const;
329 :
public TorqueGeneratedJSTypedArray<JSTypedArray, JSArrayBufferView> {
331 static constexpr size_t kMaxByteLength = JSArrayBuffer::kMaxByteLength;
352 static constexpr bool kOffHeapDataPtrEqualsExternalPointer =
true;
355 inline void* DataPtr();
360 inline bool is_on_heap()
const;
364 size_t GetVariableByteLengthOrOutOfBounds(
bool& out_of_bounds)
const;
365 size_t GetVariableLengthOrOutOfBounds(
bool& out_of_bounds)
const;
367 inline size_t GetLengthOrOutOfBounds(
bool& out_of_bounds)
const;
369 inline size_t GetByteLength()
const;
370 inline bool IsOutOfBounds()
const;
371 inline bool IsDetachedOrOutOfBounds()
const;
374 size_t* element_size,
377 static size_t LengthTrackingGsabBackedTypedArrayLength(
Isolate* isolate,
389 static inline Address ExternalPointerCompensationForOnHeapArray(
401 inline uint32_t GetExternalBackingStoreRefForDeserialization()
const;
402 inline void SetExternalBackingStoreRefForSerialization(uint32_t ref);
405 inline void RemoveExternalPointerCompensationForSerialization(
408 inline void AddExternalPointerCompensationForDeserialization(
422 static constexpr
int kSizeWithEmbedderFields =
425 static constexpr
bool kContainsEmbedderFields =
430#ifdef V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP
431 static constexpr size_t kMaxSizeInHeap = V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP;
433 static constexpr size_t kMaxSizeInHeap = 64;
437 template <
typename IsolateT>
444 inline size_t LengthUnchecked()
const;
451 inline void set_external_pointer(
Isolate* isolate, Address value);
457 :
public TorqueGeneratedJSDataViewOrRabGsabDataView<
458 JSDataViewOrRabGsabDataView, JSArrayBufferView> {
462 inline void set_data_pointer(
Isolate* isolate,
void* value);
467 static constexpr int kSizeWithEmbedderFields =
470 static constexpr bool kContainsEmbedderFields =
479 :
public TorqueGeneratedJSDataView<JSDataView,
480 JSDataViewOrRabGsabDataView> {
490 :
public TorqueGeneratedJSRabGsabDataView<JSRabGsabDataView,
491 JSDataViewOrRabGsabDataView> {
497 inline size_t GetByteLength()
const;
498 inline bool IsOutOfBounds()
const;
static const int kEmbedderFieldCount
static constexpr size_t kMaxByteLength
static constexpr T decode(U value)
static constexpr U encode(T value)
GcState young_gc_state() const
size_t accounting_length() const
AccountingState SetYoung()
bool IsYoungMarked() const
std::atomic< uint64_t > accounting_state_
ArrayBufferExtension * next() const
void set_next(ArrayBufferExtension *extension)
std::shared_ptr< BackingStore > RemoveBackingStore()
void set_young_gc_state(GcState value)
AccountingState ClearAccountingLength()
std::shared_ptr< BackingStore > backing_store_
std::atomic< bool > marked_
std::atomic< GcState > young_gc_state_
ArrayBufferExtension(std::shared_ptr< BackingStore > backing_store, ArrayBufferExtension::Age age)
AccountingState UpdateAccountingLength(int64_t delta)
std::shared_ptr< BackingStore > backing_store()
bool IsYoungPromoted() const
void set_backing_store(std::shared_ptr< BackingStore > backing_store)
ArrayBufferExtension * next_
size_t byte_length_unchecked() const
std::shared_ptr< BackingStore > RemoveExtension()
V8_EXPORT_PRIVATE ArrayBufferExtension * CreateExtension(Isolate *isolate, std::shared_ptr< BackingStore > backing_store)
void SetBackingStoreRefForSerialization(uint32_t ref)
uint32_t GetBackingStoreRefForDeserialization() const
V8_EXPORT_PRIVATE void Setup(SharedFlag shared, ResizableFlag resizable, std::shared_ptr< BackingStore > backing_store, Isolate *isolate)
void DetachInternal(bool force_for_wasm_memory, Isolate *isolate)
static constexpr int kSizeWithEmbedderFields
static size_t GsabByteLength(Isolate *isolate, Address raw_array_buffer)
V8_INLINE void clear_padding()
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > Detach(DirectHandle< JSArrayBuffer > buffer, bool force_for_wasm_memory=false, DirectHandle< Object > key={})
size_t GetByteLength() const
static constexpr size_t kMaxByteLength
void YoungMarkExtension()
static Maybe< bool > GetResizableBackingStorePageConfiguration(Isolate *isolate, size_t byte_length, size_t max_byte_length, ShouldThrow should_throw, size_t *page_size, size_t *initial_pages, size_t *max_pages)
static constexpr bool kContainsEmbedderFields
void set_backing_store(Isolate *isolate, void *value)
static std::optional< MessageTemplate > GetResizableBackingStorePageConfigurationImpl(Isolate *isolate, size_t byte_length, size_t max_byte_length, size_t *page_size, size_t *initial_pages, size_t *max_pages)
ArrayBufferExtension ** extension_location() const
std::shared_ptr< BackingStore > GetBackingStore() const
void YoungMarkExtensionPromoted()
constexpr double kMaxSafeInteger
constexpr int kEmbedderDataSlotSize
constexpr int kUIntptrSize
uint32_t ExternalPointerHandle
JSArrayBuffer::IsDetachableBit is_shared
uint32_t GetLength(Tagged< JSArray > array)
#define DECL_ACCESSORS(name,...)
#define DECL_GETTER(name,...)
#define DECL_ACQUIRE_GETTER(name,...)
#define DECL_VERIFIER(Name)
#define DECL_BOOLEAN_ACCESSORS(name)
#define DECL_RELEASE_SETTER(name,...)
#define DECL_PRIMITIVE_GETTER(name, type)
#define DECL_PRIMITIVE_ACCESSORS(name, type)
#define DECL_PRIMITIVE_SETTER(name, type)
#define DECL_PRINTER(Name)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define DECL_SETTER(name,...)
#define V8_EXPORT_PRIVATE
constexpr bool IsAligned(T value, U alignment)
size_t accounting_length() const
#define V8_WARN_UNUSED_RESULT
std::unique_ptr< ValueMirror > key