From 12478684aab233942e0d5dc24f195930c8a5e59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 13 Jul 2020 10:39:42 +0200 Subject: deps: update V8 to 8.4.371.19 PR-URL: https://github.com/nodejs/node/pull/33579 Reviewed-By: Matteo Collina Reviewed-By: Jiawen Geng Reviewed-By: Michael Dawson Reviewed-By: Rich Trott Reviewed-By: Shelley Vohr --- deps/v8/src/objects/js-array-buffer-inl.h | 104 ++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 35 deletions(-) (limited to 'deps/v8/src/objects/js-array-buffer-inl.h') diff --git a/deps/v8/src/objects/js-array-buffer-inl.h b/deps/v8/src/objects/js-array-buffer-inl.h index b77f5580e2..6737cdc719 100644 --- a/deps/v8/src/objects/js-array-buffer-inl.h +++ b/deps/v8/src/objects/js-array-buffer-inl.h @@ -5,8 +5,10 @@ #ifndef V8_OBJECTS_JS_ARRAY_BUFFER_INL_H_ #define V8_OBJECTS_JS_ARRAY_BUFFER_INL_H_ +#include "src/common/external-pointer.h" #include "src/objects/js-array-buffer.h" +#include "src/common/external-pointer-inl.h" #include "src/heap/heap-write-barrier-inl.h" #include "src/objects/js-objects-inl.h" #include "src/objects/objects-inl.h" @@ -18,15 +20,10 @@ namespace v8 { namespace internal { -OBJECT_CONSTRUCTORS_IMPL(JSArrayBuffer, JSObject) -OBJECT_CONSTRUCTORS_IMPL(JSArrayBufferView, JSObject) -OBJECT_CONSTRUCTORS_IMPL(JSTypedArray, JSArrayBufferView) -OBJECT_CONSTRUCTORS_IMPL(JSDataView, JSArrayBufferView) - -CAST_ACCESSOR(JSArrayBuffer) -CAST_ACCESSOR(JSArrayBufferView) -CAST_ACCESSOR(JSTypedArray) -CAST_ACCESSOR(JSDataView) +TQ_OBJECT_CONSTRUCTORS_IMPL(JSArrayBuffer) +TQ_OBJECT_CONSTRUCTORS_IMPL(JSArrayBufferView) +TQ_OBJECT_CONSTRUCTORS_IMPL(JSTypedArray) +TQ_OBJECT_CONSTRUCTORS_IMPL(JSDataView) size_t JSArrayBuffer::byte_length() const { return ReadField(kByteLengthOffset); @@ -36,12 +33,27 @@ void JSArrayBuffer::set_byte_length(size_t value) { WriteField(kByteLengthOffset, value); } -void* JSArrayBuffer::backing_store() const { - return reinterpret_cast(ReadField
(kBackingStoreOffset)); +DEF_GETTER(JSArrayBuffer, backing_store, void*) { + ExternalPointer_t encoded_value = + ReadField(kBackingStoreOffset); + return reinterpret_cast(DecodeExternalPointer(isolate, encoded_value)); +} + +void JSArrayBuffer::set_backing_store(Isolate* isolate, void* value) { + ExternalPointer_t encoded_value = + EncodeExternalPointer(isolate, reinterpret_cast
(value)); + WriteField(kBackingStoreOffset, encoded_value); } -void JSArrayBuffer::set_backing_store(void* value) { - WriteField
(kBackingStoreOffset, reinterpret_cast
(value)); +uint32_t JSArrayBuffer::GetBackingStoreRefForDeserialization() const { + ExternalPointer_t encoded_value = + ReadField(kBackingStoreOffset); + return static_cast(encoded_value); +} + +void JSArrayBuffer::SetBackingStoreRefForSerialization(uint32_t ref) { + ExternalPointer_t encoded_value = ref; + WriteField(kBackingStoreOffset, encoded_value); } ArrayBufferExtension* JSArrayBuffer::extension() const { @@ -173,8 +185,6 @@ void JSArrayBufferView::set_byte_length(size_t value) { WriteField(kByteLengthOffset, value); } -ACCESSORS(JSArrayBufferView, buffer, Object, kBufferOffset) - bool JSArrayBufferView::WasDetached() const { return JSArrayBuffer::cast(buffer()).was_detached(); } @@ -185,12 +195,15 @@ void JSTypedArray::set_length(size_t value) { WriteField(kLengthOffset, value); } -Address JSTypedArray::external_pointer() const { - return ReadField
(kExternalPointerOffset); +DEF_GETTER(JSTypedArray, external_pointer, Address) { + ExternalPointer_t encoded_value = + ReadField(kExternalPointerOffset); + return DecodeExternalPointer(isolate, encoded_value); } -void JSTypedArray::set_external_pointer(Address value) { - WriteField
(kExternalPointerOffset, value); +void JSTypedArray::set_external_pointer(Isolate* isolate, Address value) { + ExternalPointer_t encoded_value = EncodeExternalPointer(isolate, value); + WriteField(kExternalPointerOffset, encoded_value); } Address JSTypedArray::ExternalPointerCompensationForOnHeapArray( @@ -202,14 +215,30 @@ Address JSTypedArray::ExternalPointerCompensationForOnHeapArray( #endif } -void JSTypedArray::RemoveExternalPointerCompensationForSerialization() { - DCHECK(is_on_heap()); - const Isolate* isolate = GetIsolateForPtrCompr(*this); - set_external_pointer(external_pointer() - - ExternalPointerCompensationForOnHeapArray(isolate)); +uint32_t JSTypedArray::GetExternalBackingStoreRefForDeserialization() const { + DCHECK(!is_on_heap()); + ExternalPointer_t encoded_value = + ReadField(kExternalPointerOffset); + return static_cast(encoded_value); +} + +void JSTypedArray::SetExternalBackingStoreRefForSerialization(uint32_t ref) { + DCHECK(!is_on_heap()); + ExternalPointer_t encoded_value = ref; + WriteField(kExternalPointerOffset, encoded_value); } -ACCESSORS(JSTypedArray, base_pointer, Object, kBasePointerOffset) +void JSTypedArray::RemoveExternalPointerCompensationForSerialization( + Isolate* isolate) { + DCHECK(is_on_heap()); + // TODO(v8:10391): once we have an external table, avoid the need for + // compensation by replacing external_pointer and base_pointer fields + // with one data_pointer field which can point to either external data + // backing store or into on-heap backing store. + set_external_pointer( + isolate, + external_pointer() - ExternalPointerCompensationForOnHeapArray(isolate)); +} void* JSTypedArray::DataPtr() { // Zero-extend Tagged_t to Address according to current compression scheme @@ -220,18 +249,19 @@ void* JSTypedArray::DataPtr() { static_cast(base_pointer().ptr())); } -void JSTypedArray::SetOffHeapDataPtr(void* base, Address offset) { +void JSTypedArray::SetOffHeapDataPtr(Isolate* isolate, void* base, + Address offset) { set_base_pointer(Smi::zero(), SKIP_WRITE_BARRIER); Address address = reinterpret_cast
(base) + offset; - set_external_pointer(address); + set_external_pointer(isolate, address); DCHECK_EQ(address, reinterpret_cast
(DataPtr())); } -void JSTypedArray::SetOnHeapDataPtr(HeapObject base, Address offset) { +void JSTypedArray::SetOnHeapDataPtr(Isolate* isolate, HeapObject base, + Address offset) { set_base_pointer(base); - const Isolate* isolate = GetIsolateForPtrCompr(*this); - set_external_pointer(offset + - ExternalPointerCompensationForOnHeapArray(isolate)); + set_external_pointer( + isolate, offset + ExternalPointerCompensationForOnHeapArray(isolate)); DCHECK_EQ(base.ptr() + offset, reinterpret_cast
(DataPtr())); } @@ -264,12 +294,16 @@ MaybeHandle JSTypedArray::Validate(Isolate* isolate, return array; } -void* JSDataView::data_pointer() const { - return reinterpret_cast(ReadField
(kDataPointerOffset)); +DEF_GETTER(JSDataView, data_pointer, void*) { + ExternalPointer_t encoded_value = + ReadField(kDataPointerOffset); + return reinterpret_cast(DecodeExternalPointer(isolate, encoded_value)); } -void JSDataView::set_data_pointer(void* value) { - WriteField
(kDataPointerOffset, reinterpret_cast
(value)); +void JSDataView::set_data_pointer(Isolate* isolate, void* value) { + WriteField( + kDataPointerOffset, + EncodeExternalPointer(isolate, reinterpret_cast
(value))); } } // namespace internal -- cgit v1.2.1