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
102 void operator delete(
void* ptr) { ::operator
delete(ptr); }
121 static void EmptyDeleter(
void* data,
size_t length,
void* deleter_data);
131#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
178 virtual void Free(
void* data,
size_t length) = 0;
205#if defined(V8_COMPRESS_POINTERS) && \
206 !defined(V8_COMPRESS_POINTERS_IN_SHARED_CAGE)
252 Isolate* isolate,
size_t byte_length,
254 BackingStoreInitializationMode::kZeroInitialized);
263 Isolate* isolate,
size_t byte_length,
265 BackingStoreInitializationMode::kZeroInitialized);
280 std::shared_ptr<BackingStore> backing_store);
298 Isolate* isolate,
size_t byte_length,
300 BackingStoreInitializationMode::kZeroInitialized,
302 BackingStoreOnFailureMode::kOutOfMemory);
329 size_t byte_length,
size_t max_byte_length);
355 size_t target_start)
const;
364 "Use the version which takes a key parameter (passing a null handle is "
398 bool IsResizableByUserJavaScript() const;
407#ifdef V8_ENABLE_CHECKS
413 static constexpr int kInternalFieldCount =
415 static constexpr int kEmbedderFieldCount = kInternalFieldCount;
418 static constexpr size_t kMaxByteLength =
419 internal::kMaxSafeBufferSizeForSandbox;
420#elif V8_HOST_ARCH_32_BIT
421 static constexpr size_t kMaxByteLength = std::numeric_limits<int>::max();
424 static constexpr size_t kMaxByteLength =
425 static_cast<size_t>((uint64_t{1} << 53) - 1);
430 static void CheckCast(
Value* obj);
434#ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
436#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
486#ifdef V8_ENABLE_CHECKS
492 static constexpr int kInternalFieldCount =
494 static const int kEmbedderFieldCount = kInternalFieldCount;
498 static void CheckCast(
Value* obj);
507 size_t byte_offset,
size_t length);
509 size_t byte_offset,
size_t length);
511#ifdef V8_ENABLE_CHECKS
514 return static_cast<DataView*
>(value);
519 static void CheckCast(
Value* obj);
544 Isolate* isolate,
size_t byte_length,
546 BackingStoreInitializationMode::kZeroInitialized);
556 Isolate* isolate,
size_t byte_length,
558 BackingStoreInitializationMode::kZeroInitialized);
573 Isolate* isolate, std::shared_ptr<BackingStore> backing_store);
592 Isolate* isolate,
size_t byte_length,
594 BackingStoreInitializationMode::kZeroInitialized,
596 BackingStoreOnFailureMode::kOutOfMemory);
632 size_t target_start)
const;
635#ifdef V8_ENABLE_CHECKS
641 static constexpr int kInternalFieldCount =
646 static void CheckCast(
Value* obj);
Definition: v8-array-buffer.h:443
static ArrayBufferView * Cast(Value *value)
Definition: v8-array-buffer.h:485
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:158
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:187
virtual PageAllocator * GetPageAllocator()
Definition: v8-array-buffer.h:203
AllocationMode
Definition: v8-array-buffer.h:194
virtual void * Allocate(size_t length)=0
Definition: v8-array-buffer.h:141
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:110
static void EmptyDeleter(void *data, size_t length, void *deleter_data)
bool IsResizableByUserJavaScript() const
std::span< uint8_t > ByteSpan() const
Definition: v8-array-buffer.h:504
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:510
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:267
Definition: v8-platform.h:548
Definition: v8-array-buffer.h:525
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:634
Definition: v8-typed-array.h:20
Definition: v8-value.h:32
Definition: v8-internal.h:1568
Definition: libplatform.h:15
void(*)(void *data, size_t length, void *deleter_data) BackingStoreDeleterCallback
Definition: v8-array-buffer.h:134
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:436
#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