5#ifndef INCLUDE_V8_ARRAY_BUFFER_H_
6#define INCLUDE_V8_ARRAY_BUFFER_H_
20class SharedArrayBuffer;
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
97 void operator delete(
void* ptr) { ::operator
delete(ptr); }
116 static void EmptyDeleter(
void* data,
size_t length,
void* deleter_data);
126#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
173 virtual void Free(
void* data,
size_t length) = 0;
200#if defined(V8_COMPRESS_POINTERS) && \
201 !defined(V8_COMPRESS_POINTERS_IN_SHARED_CAGE)
247 Isolate* isolate,
size_t byte_length,
249 BackingStoreInitializationMode::kZeroInitialized);
258 Isolate* isolate,
size_t byte_length,
260 BackingStoreInitializationMode::kZeroInitialized);
275 std::shared_ptr<BackingStore> backing_store);
293 Isolate* isolate,
size_t byte_length,
295 BackingStoreInitializationMode::kZeroInitialized,
297 BackingStoreOnFailureMode::kOutOfMemory);
324 size_t byte_length,
size_t max_byte_length);
350 size_t target_start)
const;
359 "Use the version which takes a key parameter (passing a null handle is "
393 bool IsResizableByUserJavaScript() const;
402#ifdef V8_ENABLE_CHECKS
408 static constexpr int kInternalFieldCount =
410 static constexpr int kEmbedderFieldCount = kInternalFieldCount;
413 static constexpr size_t kMaxByteLength =
414 internal::kMaxSafeBufferSizeForSandbox;
415#elif V8_HOST_ARCH_32_BIT
416 static constexpr size_t kMaxByteLength = std::numeric_limits<int>::max();
419 static constexpr size_t kMaxByteLength =
420 static_cast<size_t>((uint64_t{1} << 53) - 1);
425 static void CheckCast(
Value* obj);
429#ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
431#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
481#ifdef V8_ENABLE_CHECKS
487 static constexpr int kInternalFieldCount =
489 static const int kEmbedderFieldCount = kInternalFieldCount;
493 static void CheckCast(
Value* obj);
502 size_t byte_offset,
size_t length);
504 size_t byte_offset,
size_t length);
506#ifdef V8_ENABLE_CHECKS
509 return static_cast<DataView*
>(value);
514 static void CheckCast(
Value* obj);
539 Isolate* isolate,
size_t byte_length,
541 BackingStoreInitializationMode::kZeroInitialized);
551 Isolate* isolate,
size_t byte_length,
553 BackingStoreInitializationMode::kZeroInitialized);
568 Isolate* isolate, std::shared_ptr<BackingStore> backing_store);
587 Isolate* isolate,
size_t byte_length,
589 BackingStoreInitializationMode::kZeroInitialized,
591 BackingStoreOnFailureMode::kOutOfMemory);
627 size_t target_start)
const;
630#ifdef V8_ENABLE_CHECKS
636 static constexpr int kInternalFieldCount =
641 static void CheckCast(
Value* obj);
Definition: v8-array-buffer.h:438
static ArrayBufferView * Cast(Value *value)
Definition: v8-array-buffer.h:480
Local< ArrayBuffer > Buffer()
std::span< uint8_t > GetContents(std::span< uint8_t > storage)
size_t CopyContents(void *dest, size_t byte_length)
Definition: v8-array-buffer.h:153
virtual ~Allocator()=default
virtual void Free(void *data, size_t length)=0
static Allocator * NewDefaultAllocator()
virtual void * AllocateUninitialized(size_t length)=0
virtual size_t MaxAllocationSize() const
Definition: v8-array-buffer.h:182
virtual PageAllocator * GetPageAllocator()
Definition: v8-array-buffer.h:198
AllocationMode
Definition: v8-array-buffer.h:189
virtual void * Allocate(size_t length)=0
Definition: v8-array-buffer.h:136
static std::unique_ptr< BackingStore > NewBackingStore(void *data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, void *deleter_data)
size_t MaxByteLength() const
static std::unique_ptr< BackingStore > NewResizableBackingStore(size_t byte_length, size_t max_byte_length)
static Local< ArrayBuffer > New(Isolate *isolate, std::shared_ptr< BackingStore > backing_store)
size_t CopyArrayBufferBytes(size_t source_start, size_t bytes_to_copy, Local< ArrayBuffer > target, size_t target_start) const
bool IsDetachable() const
static Local< ArrayBuffer > New(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)
size_t ByteLength() const
static MaybeLocal< ArrayBuffer > MaybeNew(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized)
Definition: v8-array-buffer.h:49
size_t MaxByteLength() const
size_t ByteLength() const
void(*)(void *data, size_t length, void *deleter_data) DeleterCallback
Definition: v8-array-buffer.h:105
static void EmptyDeleter(void *data, size_t length, void *deleter_data)
bool IsResizableByUserJavaScript() const
Definition: v8-array-buffer.h:499
static Local< DataView > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static DataView * Cast(Value *value)
Definition: v8-array-buffer.h:505
static Local< DataView > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
Definition: v8-isolate.h:225
Definition: v8-isolate.h:292
Definition: v8-local-handle.h:366
Definition: v8-local-handle.h:734
Definition: v8-maybe.h:39
Definition: v8-object.h:266
Definition: v8-platform.h:548
Definition: v8-array-buffer.h:520
size_t CopyArrayBufferBytes(size_t source_start, size_t bytes_to_copy, Local< SharedArrayBuffer > target, size_t target_start) const
static Local< SharedArrayBuffer > New(Isolate *isolate, std::shared_ptr< BackingStore > backing_store)
static MaybeLocal< SharedArrayBuffer > MaybeNew(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized)
std::shared_ptr< BackingStore > GetBackingStore()
static std::unique_ptr< BackingStore > NewBackingStore(void *data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, void *deleter_data)
static std::unique_ptr< BackingStore > NewBackingStore(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized, BackingStoreOnFailureMode on_failure=BackingStoreOnFailureMode::kOutOfMemory)
size_t ByteLength() const
size_t MaxByteLength() const
static Local< SharedArrayBuffer > New(Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized)
static SharedArrayBuffer * Cast(Value *value)
Definition: v8-array-buffer.h:629
Definition: v8-typed-array.h:20
Definition: v8-value.h:32
Definition: v8-internal.h:1562
Definition: libplatform.h:15
void(*)(void *data, size_t length, void *deleter_data) BackingStoreDeleterCallback
Definition: v8-array-buffer.h:129
BackingStoreInitializationMode
Definition: v8-array-buffer.h:33
ArrayBufferCreationMode
Definition: v8-array-buffer.h:32
BackingStoreOnFailureMode
Definition: v8-array-buffer.h:34
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
Definition: v8-array-buffer.h:29
#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
Definition: v8-array-buffer.h:431
#define V8_EXPORT
Definition: v8config.h:867
#define V8_INLINE
Definition: v8config.h:511
#define V8_DEPRECATED(message)
Definition: v8config.h:616
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:681