5#ifndef INCLUDE_V8_ARRAY_BUFFER_H_
6#define INCLUDE_V8_ARRAY_BUFFER_H_
22#if defined(V8_COMPRESS_POINTERS) && \
23 !defined(V8_COMPRESS_POINTERS_IN_SHARED_CAGE)
27#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
29#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
92 void operator delete(
void* ptr) { ::operator
delete(ptr); }
111 static void EmptyDeleter(
void* data,
size_t length,
void* deleter_data);
121#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
168 virtual void Free(
void* data,
size_t length) = 0;
195#if defined(V8_COMPRESS_POINTERS) && \
196 !defined(V8_COMPRESS_POINTERS_IN_SHARED_CAGE)
242 Isolate* isolate,
size_t byte_length,
253 Isolate* isolate,
size_t byte_length,
270 std::shared_ptr<BackingStore> backing_store);
288 Isolate* isolate,
size_t byte_length,
319 size_t byte_length,
size_t max_byte_length);
338 "Use the version which takes a key parameter (passing a null handle is "
381#ifdef V8_ENABLE_CHECKS
384 return static_cast<ArrayBuffer*
>(value);
393 internal::kMaxSafeBufferSizeForSandbox;
394#elif V8_HOST_ARCH_32_BIT
395 static constexpr size_t kMaxByteLength = std::numeric_limits<int>::max();
399 static_cast<size_t>((uint64_t{1} << 53) - 1);
404 static void CheckCast(
Value* obj);
408#ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
410#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
460#ifdef V8_ENABLE_CHECKS
463 return static_cast<ArrayBufferView*
>(value);
472 static void CheckCast(
Value* obj);
481 size_t byte_offset,
size_t length);
483 size_t byte_offset,
size_t length);
485#ifdef V8_ENABLE_CHECKS
488 return static_cast<DataView*
>(value);
493 static void CheckCast(
Value* obj);
518 Isolate* isolate,
size_t byte_length,
530 Isolate* isolate,
size_t byte_length,
547 Isolate* isolate, std::shared_ptr<BackingStore> backing_store);
566 Isolate* isolate,
size_t byte_length,
599#ifdef V8_ENABLE_CHECKS
602 return static_cast<SharedArrayBuffer*
>(value);
610 static void CheckCast(
Value* obj);
static Allocator * NewDefaultAllocator()
virtual void * AllocateUninitialized(size_t length)=0
virtual size_t MaxAllocationSize() const
virtual ~Allocator()=default
virtual void Free(void *data, size_t length)=0
virtual void * Allocate(size_t length)=0
virtual PageAllocator * GetPageAllocator()
static constexpr int kEmbedderFieldCount
static Local< ArrayBuffer > New(Isolate *isolate, std::shared_ptr< BackingStore > backing_store)
static V8_INLINE ArrayBuffer * Cast(Value *value)
size_t MaxByteLength() const
static std::unique_ptr< BackingStore > NewBackingStore(void *data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, void *deleter_data)
static Local< ArrayBuffer > New(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized)
bool IsDetachable() const
static std::unique_ptr< BackingStore > NewBackingStore(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized, BackingStoreOnFailureMode on_failure=BackingStoreOnFailureMode::kOutOfMemory)
static constexpr size_t kMaxByteLength
static constexpr int kInternalFieldCount
std::shared_ptr< BackingStore > GetBackingStore()
size_t ByteLength() const
void SetDetachKey(v8::Local< v8::Value > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Detach(v8::Local< v8::Value > key)
bool IsResizableByUserJavaScript() const
V8_DEPRECATED("Use the version which takes a key parameter (passing a null handle is " "ok).") void Detach()
static std::unique_ptr< BackingStore > NewResizableBackingStore(size_t byte_length, size_t max_byte_length)
static MaybeLocal< ArrayBuffer > MaybeNew(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized)
v8::MemorySpan< uint8_t > GetContents(v8::MemorySpan< uint8_t > storage)
Local< ArrayBuffer > Buffer()
static const int kEmbedderFieldCount
size_t CopyContents(void *dest, size_t byte_length)
static constexpr int kInternalFieldCount
static V8_INLINE ArrayBufferView * Cast(Value *value)
void(*)(void *data, size_t length, void *deleter_data) DeleterCallback
size_t MaxByteLength() const
static void EmptyDeleter(void *data, size_t length, void *deleter_data)
size_t ByteLength() const
bool IsResizableByUserJavaScript() const
static Local< DataView > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static V8_INLINE DataView * Cast(Value *value)
static Local< DataView > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< SharedArrayBuffer > New(Isolate *isolate, std::shared_ptr< BackingStore > backing_store)
size_t MaxByteLength() const
static std::unique_ptr< BackingStore > NewBackingStore(void *data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, void *deleter_data)
static MaybeLocal< SharedArrayBuffer > MaybeNew(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized)
static std::unique_ptr< BackingStore > NewBackingStore(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized, BackingStoreOnFailureMode on_failure=BackingStoreOnFailureMode::kOutOfMemory)
static V8_INLINE SharedArrayBuffer * Cast(Value *value)
static constexpr int kInternalFieldCount
static Local< SharedArrayBuffer > New(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized)
std::shared_ptr< BackingStore > GetBackingStore()
size_t ByteLength() const
BackingStoreOnFailureMode
BackingStoreInitializationMode
void(*)(void *data, size_t length, void *deleter_data) BackingStoreDeleterCallback
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
#define V8_WARN_UNUSED_RESULT