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
63 size_t ByteLength()
const;
72 size_t MaxByteLength()
const;
78 bool IsShared()
const;
85 bool IsResizableByUserJavaScript()
const;
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)
227 size_t ByteLength()
const;
232 size_t MaxByteLength()
const;
242 Isolate* isolate,
size_t byte_length,
244 BackingStoreInitializationMode::kZeroInitialized);
253 Isolate* isolate,
size_t byte_length,
255 BackingStoreInitializationMode::kZeroInitialized);
270 std::shared_ptr<BackingStore> backing_store);
287 static std::unique_ptr<BackingStore> NewBackingStore(
288 Isolate* isolate,
size_t byte_length,
290 BackingStoreInitializationMode::kZeroInitialized,
292 BackingStoreOnFailureMode::kOutOfMemory);
302 static std::unique_ptr<BackingStore> NewBackingStore(
318 static std::unique_ptr<BackingStore> NewResizableBackingStore(
319 size_t byte_length,
size_t max_byte_length);
324 bool IsDetachable()
const;
329 bool WasDetached()
const;
338 "Use the version which takes a key parameter (passing a null handle is "
372 bool IsResizableByUserJavaScript() const;
381#ifdef V8_ENABLE_CHECKS
387 static constexpr int kInternalFieldCount =
388 V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
389 static constexpr int kEmbedderFieldCount = kInternalFieldCount;
392 static constexpr size_t kMaxByteLength =
393 internal::kMaxSafeBufferSizeForSandbox;
394#elif V8_HOST_ARCH_32_BIT
395 static constexpr size_t kMaxByteLength = std::numeric_limits<int>::max();
398 static constexpr size_t kMaxByteLength =
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
441 size_t CopyContents(
void* dest,
size_t byte_length);
457 bool HasBuffer()
const;
460#ifdef V8_ENABLE_CHECKS
466 static constexpr int kInternalFieldCount =
467 V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT;
468 static const int kEmbedderFieldCount = kInternalFieldCount;
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
493 static void CheckCast(
Value* obj);
504 size_t ByteLength()
const;
509 size_t MaxByteLength()
const;
518 Isolate* isolate,
size_t byte_length,
520 BackingStoreInitializationMode::kZeroInitialized);
530 Isolate* isolate,
size_t byte_length,
532 BackingStoreInitializationMode::kZeroInitialized);
547 Isolate* isolate, std::shared_ptr<BackingStore> backing_store);
565 static std::unique_ptr<BackingStore> NewBackingStore(
566 Isolate* isolate,
size_t byte_length,
568 BackingStoreInitializationMode::kZeroInitialized,
570 BackingStoreOnFailureMode::kOutOfMemory);
580 static std::unique_ptr<BackingStore> NewBackingStore(
590 std::shared_ptr<BackingStore> GetBackingStore();
599#ifdef V8_ENABLE_CHECKS
605 static constexpr int kInternalFieldCount =
606 V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
610 static void CheckCast(
Value* obj);
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
static V8_INLINE ArrayBufferView * Cast(Value *value)
virtual ~Allocator()=default
virtual void Free(void *data, size_t length)=0
virtual void * AllocateUninitialized(size_t length)=0
virtual size_t MaxAllocationSize() const
virtual PageAllocator * GetPageAllocator()
virtual void * Allocate(size_t length)=0
V8_DEPRECATED("Use the version which takes a key parameter (passing a null handle is " "ok).") void Detach()
void(*)(void *data, size_t length, void *deleter_data) DeleterCallback
static V8_INLINE DataView * Cast(Value *value)
static V8_INLINE SharedArrayBuffer * Cast(Value *value)
BackingStoreInitializationMode
BackingStoreOnFailureMode
void(*)(void *data, size_t length, void *deleter_data) BackingStoreDeleterCallback
#define V8_WARN_UNUSED_RESULT
std::unique_ptr< ValueMirror > value
std::unique_ptr< ValueMirror > key