Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/objects/js-array-buffer.h')
-rw-r--r--deps/v8/src/objects/js-array-buffer.h119
1 files changed, 49 insertions, 70 deletions
diff --git a/deps/v8/src/objects/js-array-buffer.h b/deps/v8/src/objects/js-array-buffer.h
index 624b716713e..3d6b293e2df 100644
--- a/deps/v8/src/objects/js-array-buffer.h
+++ b/deps/v8/src/objects/js-array-buffer.h
@@ -17,7 +17,8 @@ namespace internal {
class ArrayBufferExtension;
-class JSArrayBuffer : public JSObject {
+class JSArrayBuffer
+ : public TorqueGeneratedJSArrayBuffer<JSArrayBuffer, JSObject> {
public:
// The maximum length for JSArrayBuffer's supported by V8.
// On 32-bit architectures we limit this to 2GiB, so that
@@ -33,7 +34,8 @@ class JSArrayBuffer : public JSObject {
DECL_PRIMITIVE_ACCESSORS(byte_length, size_t)
// [backing_store]: backing memory for this array
- DECL_PRIMITIVE_ACCESSORS(backing_store, void*)
+ DECL_GETTER(backing_store, void*)
+ inline void set_backing_store(Isolate* isolate, void* value);
// [extension]: extension object used for GC
DECL_PRIMITIVE_ACCESSORS(extension, ArrayBufferExtension*)
@@ -50,7 +52,7 @@ class JSArrayBuffer : public JSObject {
// is deterministic. Depending on the V8 build mode there could be no padding.
V8_INLINE void clear_padding();
-// Bit positions for [bit_field].
+ // Bit positions for [bit_field].
DEFINE_TORQUE_GENERATED_JS_ARRAY_BUFFER_FLAGS()
// [is_external]: true indicates that the embedder is in charge of freeing the
@@ -70,8 +72,6 @@ class JSArrayBuffer : public JSObject {
// [is_shared]: tells whether this is an ArrayBuffer or a SharedArrayBuffer.
DECL_BOOLEAN_ACCESSORS(is_shared)
- DECL_CAST(JSArrayBuffer)
-
// Initializes the fields of the ArrayBuffer. The provided backing_store can
// be nullptr. If it is not nullptr, then the function registers it with
// src/heap/array-buffer-tracker.h.
@@ -110,13 +110,21 @@ class JSArrayBuffer : public JSObject {
void YoungMarkExtension();
void YoungMarkExtensionPromoted();
+ //
+ // Serializer/deserializer support.
+ //
+
+ // Backing stores are serialized/deserialized separately. During serialization
+ // the backing store reference is stored in the backing store field and upon
+ // deserialization it is converted back to actual external (off-heap) pointer
+ // value.
+ inline uint32_t GetBackingStoreRefForDeserialization() const;
+ inline void SetBackingStoreRefForSerialization(uint32_t ref);
+
// Dispatched behavior.
DECL_PRINTER(JSArrayBuffer)
DECL_VERIFIER(JSArrayBuffer)
- // Layout description.
- DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
- TORQUE_GENERATED_JS_ARRAY_BUFFER_FIELDS)
static constexpr int kEndOfTaggedFieldsOffset = JSObject::kHeaderSize;
static const int kSizeWithEmbedderFields =
@@ -125,8 +133,6 @@ class JSArrayBuffer : public JSObject {
class BodyDescriptor;
- OBJECT_CONSTRUCTORS(JSArrayBuffer, JSObject);
-
private:
inline ArrayBufferExtension** extension_location() const;
@@ -136,6 +142,8 @@ class JSArrayBuffer : public JSObject {
inline uint32_t* extension_lo() const;
inline uint32_t* extension_hi() const;
#endif
+
+ TQ_OBJECT_CONSTRUCTORS(JSArrayBuffer)
};
// Each JSArrayBuffer (with a backing store) has a corresponding native-heap
@@ -209,44 +217,29 @@ class ArrayBufferExtension : public Malloced {
void set_next(ArrayBufferExtension* extension) { next_ = extension; }
};
-class JSArrayBufferView : public JSObject {
+class JSArrayBufferView
+ : public TorqueGeneratedJSArrayBufferView<JSArrayBufferView, JSObject> {
public:
- // [buffer]: ArrayBuffer that this typed array views.
- DECL_ACCESSORS(buffer, Object)
-
// [byte_offset]: offset of typed array in bytes.
DECL_PRIMITIVE_ACCESSORS(byte_offset, size_t)
// [byte_length]: length of typed array in bytes.
DECL_PRIMITIVE_ACCESSORS(byte_length, size_t)
- DECL_CAST(JSArrayBufferView)
-
DECL_VERIFIER(JSArrayBufferView)
inline bool WasDetached() const;
-// Layout description.
-#define JS_ARRAY_BUFFER_VIEW_FIELDS(V) \
- V(kBufferOffset, kTaggedSize) \
- V(kEndOfTaggedFieldsOffset, 0) \
- /* Raw data fields. */ \
- V(kByteOffsetOffset, kUIntptrSize) \
- V(kByteLengthOffset, kUIntptrSize) \
- /* Header size. */ \
- V(kHeaderSize, 0)
-
- DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
- JS_ARRAY_BUFFER_VIEW_FIELDS)
-#undef JS_ARRAY_BUFFER_VIEW_FIELDS
+ static constexpr int kEndOfTaggedFieldsOffset = kByteOffsetOffset;
STATIC_ASSERT(IsAligned(kByteOffsetOffset, kUIntptrSize));
STATIC_ASSERT(IsAligned(kByteLengthOffset, kUIntptrSize));
- OBJECT_CONSTRUCTORS(JSArrayBufferView, JSObject);
+ TQ_OBJECT_CONSTRUCTORS(JSArrayBufferView)
};
-class JSTypedArray : public JSArrayBufferView {
+class JSTypedArray
+ : public TorqueGeneratedJSTypedArray<JSTypedArray, JSArrayBufferView> {
public:
// TODO(v8:4153): This should be equal to JSArrayBuffer::kMaxByteLength
// eventually.
@@ -260,8 +253,6 @@ class JSTypedArray : public JSArrayBufferView {
Isolate* isolate, Handle<JSTypedArray> o, Handle<Object> key,
PropertyDescriptor* desc, Maybe<ShouldThrow> should_throw);
- DECL_CAST(JSTypedArray)
-
ExternalArrayType type();
V8_EXPORT_PRIVATE size_t element_size();
@@ -270,8 +261,9 @@ class JSTypedArray : public JSArrayBufferView {
// Use with care: returns raw pointer into heap.
inline void* DataPtr();
- inline void SetOffHeapDataPtr(void* base, Address offset);
- inline void SetOnHeapDataPtr(HeapObject base, Address offset);
+ inline void SetOffHeapDataPtr(Isolate* isolate, void* base, Address offset);
+ inline void SetOnHeapDataPtr(Isolate* isolate, HeapObject base,
+ Address offset);
// Whether the buffer's backing store is on-heap or off-heap.
inline bool is_on_heap() const;
@@ -288,8 +280,21 @@ class JSTypedArray : public JSArrayBufferView {
static inline Address ExternalPointerCompensationForOnHeapArray(
const Isolate* isolate);
+ //
+ // Serializer/deserializer support.
+ //
+
+ // External backing stores are serialized/deserialized separately.
+ // During serialization the backing store reference is stored in the typed
+ // array object and upon deserialization it is converted back to actual
+ // external (off-heap) pointer value.
+ // The backing store reference is stored in the external_pointer field.
+ inline uint32_t GetExternalBackingStoreRefForDeserialization() const;
+ inline void SetExternalBackingStoreRefForSerialization(uint32_t ref);
+
// Subtracts external pointer compensation from the external pointer value.
- inline void RemoveExternalPointerCompensationForSerialization();
+ inline void RemoveExternalPointerCompensationForSerialization(
+ Isolate* isolate);
static inline MaybeHandle<JSTypedArray> Validate(Isolate* isolate,
Handle<Object> receiver,
@@ -299,19 +304,6 @@ class JSTypedArray : public JSArrayBufferView {
DECL_PRINTER(JSTypedArray)
DECL_VERIFIER(JSTypedArray)
-// Layout description.
-#define JS_TYPED_ARRAY_FIELDS(V) \
- /* Raw data fields. */ \
- V(kLengthOffset, kUIntptrSize) \
- V(kExternalPointerOffset, kSystemPointerSize) \
- V(kBasePointerOffset, kTaggedSize) \
- /* Header size. */ \
- V(kHeaderSize, 0)
-
- DEFINE_FIELD_OFFSET_CONSTANTS(JSArrayBufferView::kHeaderSize,
- JS_TYPED_ARRAY_FIELDS)
-#undef JS_TYPED_ARRAY_FIELDS
-
STATIC_ASSERT(IsAligned(kLengthOffset, kUIntptrSize));
STATIC_ASSERT(IsAligned(kExternalPointerOffset, kSystemPointerSize));
@@ -330,37 +322,24 @@ class JSTypedArray : public JSArrayBufferView {
private:
friend class Deserializer;
- // [base_pointer]: TODO(v8:4153)
- DECL_ACCESSORS(base_pointer, Object)
-
// [external_pointer]: TODO(v8:4153)
- DECL_PRIMITIVE_ACCESSORS(external_pointer, Address)
+ DECL_GETTER(external_pointer, Address)
+ inline void set_external_pointer(Isolate* isolate, Address value);
- OBJECT_CONSTRUCTORS(JSTypedArray, JSArrayBufferView);
+ TQ_OBJECT_CONSTRUCTORS(JSTypedArray)
};
-class JSDataView : public JSArrayBufferView {
+class JSDataView
+ : public TorqueGeneratedJSDataView<JSDataView, JSArrayBufferView> {
public:
// [data_pointer]: pointer to the actual data.
- DECL_PRIMITIVE_ACCESSORS(data_pointer, void*)
-
- DECL_CAST(JSDataView)
+ DECL_GETTER(data_pointer, void*)
+ inline void set_data_pointer(Isolate* isolate, void* value);
// Dispatched behavior.
DECL_PRINTER(JSDataView)
DECL_VERIFIER(JSDataView)
- // Layout description.
-#define JS_DATA_VIEW_FIELDS(V) \
- /* Raw data fields. */ \
- V(kDataPointerOffset, kIntptrSize) \
- /* Header size. */ \
- V(kHeaderSize, 0)
-
- DEFINE_FIELD_OFFSET_CONSTANTS(JSArrayBufferView::kHeaderSize,
- JS_DATA_VIEW_FIELDS)
-#undef JS_DATA_VIEW_FIELDS
-
STATIC_ASSERT(IsAligned(kDataPointerOffset, kUIntptrSize));
static const int kSizeWithEmbedderFields =
@@ -369,7 +348,7 @@ class JSDataView : public JSArrayBufferView {
class BodyDescriptor;
- OBJECT_CONSTRUCTORS(JSDataView, JSArrayBufferView);
+ TQ_OBJECT_CONSTRUCTORS(JSDataView)
};
} // namespace internal