5 #ifndef V8_OBJECTS_JS_ARRAY_BUFFER_H_ 6 #define V8_OBJECTS_JS_ARRAY_BUFFER_H_ 8 #include "src/objects/js-objects.h" 11 #include "src/objects/object-macros.h" 17 enum class SharedFlag :
uint32_t { kNotShared, kShared };
25 #if V8_HOST_ARCH_32_BIT 26 static constexpr
size_t kMaxByteLength = kMaxInt;
28 static constexpr
size_t kMaxByteLength = kMaxSafeInteger;
32 DECL_PRIMITIVE_ACCESSORS(byte_length,
size_t)
35 DECL_ACCESSORS(backing_store,
void)
39 inline size_t allocation_length()
const;
40 inline void* allocation_base()
const;
43 DECL_PRIMITIVE_ACCESSORS(bit_field,
uint32_t)
47 V8_INLINE
void clear_padding();
50 #define JS_ARRAY_BUFFER_BIT_FIELD_FIELDS(V, _) \ 51 V(IsExternalBit, bool, 1, _) \ 52 V(IsNeuterableBit, bool, 1, _) \ 53 V(WasNeuteredBit, bool, 1, _) \ 54 V(IsSharedBit, bool, 1, _) \ 55 V(IsGrowableBit, bool, 1, _) \ 56 V(IsWasmMemoryBit, bool, 1, _) 57 DEFINE_BIT_FIELDS(JS_ARRAY_BUFFER_BIT_FIELD_FIELDS)
58 #undef JS_ARRAY_BUFFER_BIT_FIELD_FIELDS 63 DECL_BOOLEAN_ACCESSORS(is_external)
66 DECL_BOOLEAN_ACCESSORS(is_neuterable)
69 DECL_BOOLEAN_ACCESSORS(was_neutered)
72 DECL_BOOLEAN_ACCESSORS(is_shared)
75 DECL_BOOLEAN_ACCESSORS(is_growable)
78 DECL_BOOLEAN_ACCESSORS(is_wasm_memory)
85 Allocation(
void* allocation_base,
size_t length,
void* backing_store,
87 : allocation_base(allocation_base),
89 backing_store(backing_store),
90 is_wasm_memory(is_wasm_memory) {}
92 void* allocation_base;
98 void FreeBackingStoreFromMainThread();
101 V8_EXPORT_PRIVATE
static void Setup(
103 void* data,
size_t allocated_length,
104 SharedFlag shared_flag = SharedFlag::kNotShared,
105 bool is_wasm_memory =
false);
114 static bool SetupAllocatingData(
116 size_t allocated_length,
bool initialize =
true,
117 SharedFlag shared_flag = SharedFlag::kNotShared) V8_WARN_UNUSED_RESULT;
124 #define JS_ARRAY_BUFFER_FIELDS(V) \ 125 V(kEndOfTaggedFieldsOffset, 0) \ 127 V(kByteLengthOffset, kUIntptrSize) \ 128 V(kBackingStoreOffset, kSystemPointerSize) \ 129 V(kBitFieldOffset, kInt32Size) \ 131 V(kOptionalPaddingOffset, OBJECT_POINTER_PADDING(kOptionalPaddingOffset)) \ 135 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_ARRAY_BUFFER_FIELDS)
136 #undef JS_ARRAY_BUFFER_FIELDS 138 static const int kSizeWithEmbedderFields =
140 v8::ArrayBuffer::kEmbedderFieldCount * kEmbedderDataSlotSize;
151 DECL_ACCESSORS(buffer,
Object)
154 DECL_PRIMITIVE_ACCESSORS(byte_offset,
size_t)
157 DECL_PRIMITIVE_ACCESSORS(byte_length,
size_t)
163 inline bool WasNeutered()
const;
166 #define JS_ARRAY_BUFFER_VIEW_FIELDS(V) \ 167 V(kBufferOffset, kTaggedSize) \ 168 V(kEndOfTaggedFieldsOffset, 0) \ 170 V(kByteOffsetOffset, kUIntptrSize) \ 171 V(kByteLengthOffset, kUIntptrSize) \ 175 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
176 JS_ARRAY_BUFFER_VIEW_FIELDS)
177 #undef JS_ARRAY_BUFFER_VIEW_FIELDS 188 DECL_ACCESSORS(length,
Object)
189 inline size_t length_value()
const;
192 V8_WARN_UNUSED_RESULT
static Maybe<bool> DefineOwnProperty(
198 ExternalArrayType
type();
199 V8_EXPORT_PRIVATE
size_t element_size();
204 inline bool is_on_heap()
const;
208 const char* method_name);
215 #define JS_TYPED_ARRAY_FIELDS(V) \ 217 V(kLengthOffset, kSystemPointerSize) \ 221 DEFINE_FIELD_OFFSET_CONSTANTS(JSArrayBufferView::kHeaderSize,
222 JS_TYPED_ARRAY_FIELDS)
223 #undef JS_TYPED_ARRAY_FIELDS 225 static const int kSizeWithEmbedderFields =
227 v8::ArrayBufferView::kEmbedderFieldCount * kEmbedderDataSlotSize;
233 DECL_ACCESSORS(raw_length,
Object)
248 static const int kSizeWithEmbedderFields =
250 v8::ArrayBufferView::kEmbedderFieldCount * kEmbedderDataSlotSize;
259 #include "src/objects/object-macros-undef.h" 261 #endif // V8_OBJECTS_JS_ARRAY_BUFFER_H_