|
@@ -1,83 +0,0 @@
|
|
|
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
-From: Shelley Vohr <[email protected]>
|
|
|
-Date: Thu, 20 Sep 2018 17:44:26 -0700
|
|
|
-Subject: add_realloc.patch
|
|
|
-
|
|
|
-Blink overrides ArrayBuffer's allocator with its own one, while Node simply
|
|
|
-uses malloc and free, so we need to use v8's allocator in Node. As part of the
|
|
|
-10.6.0 upgrade, we needed to make SerializerDelegate accept an allocator
|
|
|
-argument in its constructor, and override ReallocateBufferMemory and
|
|
|
-FreeBufferMemory to use the allocator. We cannot simply allocate and then memcpy
|
|
|
-when we override ReallocateBufferMemory, so we therefore need to implement
|
|
|
-Realloc on the v8 side and correspondingly in gin.
|
|
|
-
|
|
|
-diff --git a/gin/array_buffer.cc b/gin/array_buffer.cc
|
|
|
-index 210760801f1d027196111631d34bab3eb5a10792..cdfdf91841b5f2feb248b0c5890ddcfdb5a8f9ce 100644
|
|
|
---- a/gin/array_buffer.cc
|
|
|
-+++ b/gin/array_buffer.cc
|
|
|
-@@ -37,6 +37,10 @@ void* ArrayBufferAllocator::AllocateUninitialized(size_t length) {
|
|
|
- return malloc(length);
|
|
|
- }
|
|
|
-
|
|
|
-+void* ArrayBufferAllocator::Realloc(void* data, size_t length) {
|
|
|
-+ return realloc(data, length);
|
|
|
-+}
|
|
|
-+
|
|
|
- void ArrayBufferAllocator::Free(void* data, size_t length) {
|
|
|
- free(data);
|
|
|
- }
|
|
|
-diff --git a/gin/array_buffer.h b/gin/array_buffer.h
|
|
|
-index aef43319737398848dc40a3ab2d9e959ebb399f6..3c6dbc1ec10666b35d68e107a7a694c59c78a59f 100644
|
|
|
---- a/gin/array_buffer.h
|
|
|
-+++ b/gin/array_buffer.h
|
|
|
-@@ -20,6 +20,7 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
|
|
- public:
|
|
|
- void* Allocate(size_t length) override;
|
|
|
- void* AllocateUninitialized(size_t length) override;
|
|
|
-+ void* Realloc(void* data, size_t length) override;
|
|
|
- void Free(void* data, size_t length) override;
|
|
|
-
|
|
|
- GIN_EXPORT static ArrayBufferAllocator* SharedInstance();
|
|
|
-diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
|
|
|
-index c79fd01a887a54eed3868642b4e8d5a4b050ecca..d91c4344145f5ff2b081a5a9a3e931e9746a07af 100644
|
|
|
---- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
|
|
|
-+++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
|
|
|
-@@ -708,6 +708,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-+ void* Realloc(void* data, size_t size) override {
|
|
|
-+ return ArrayBufferContents::Realloc(data, size);
|
|
|
-+ }
|
|
|
-+
|
|
|
- void Free(void* data, size_t size) override {
|
|
|
- if (max_allocation_ != 0 && data)
|
|
|
- total_allocation_.fetch_sub(size, std::memory_order_relaxed);
|
|
|
-diff --git a/third_party/blink/renderer/core/typed_arrays/array_buffer/array_buffer_contents.cc b/third_party/blink/renderer/core/typed_arrays/array_buffer/array_buffer_contents.cc
|
|
|
-index dd90a1e579578e6bfc7419634d8c5fecb32cd167..1881ec0194ef0f33a011109ba7870d7993fe4c27 100644
|
|
|
---- a/third_party/blink/renderer/core/typed_arrays/array_buffer/array_buffer_contents.cc
|
|
|
-+++ b/third_party/blink/renderer/core/typed_arrays/array_buffer/array_buffer_contents.cc
|
|
|
-@@ -148,6 +148,11 @@ void* ArrayBufferContents::AllocateMemoryOrNull(size_t size,
|
|
|
- return AllocateMemoryWithFlags(size, policy, base::PartitionAllocReturnNull);
|
|
|
- }
|
|
|
-
|
|
|
-+void* ArrayBufferContents::Realloc(void* data, size_t size) {
|
|
|
-+ return WTF::Partitions::ArrayBufferPartition()->Realloc(data, size,
|
|
|
-+ WTF_HEAP_PROFILER_TYPE_NAME(ArrayBufferContents));
|
|
|
-+}
|
|
|
-+
|
|
|
- void ArrayBufferContents::FreeMemory(void* data) {
|
|
|
- InstanceCounters::DecrementCounter(
|
|
|
- InstanceCounters::kArrayBufferContentsCounter);
|
|
|
-diff --git a/third_party/blink/renderer/core/typed_arrays/array_buffer/array_buffer_contents.h b/third_party/blink/renderer/core/typed_arrays/array_buffer/array_buffer_contents.h
|
|
|
-index fcf19e6685686c1c4a40dea4869beccab9de9c03..8aeb0f8db579aa8100a01dedee66f778735e2a9c 100644
|
|
|
---- a/third_party/blink/renderer/core/typed_arrays/array_buffer/array_buffer_contents.h
|
|
|
-+++ b/third_party/blink/renderer/core/typed_arrays/array_buffer/array_buffer_contents.h
|
|
|
-@@ -107,6 +107,7 @@ class CORE_EXPORT ArrayBufferContents {
|
|
|
- void CopyTo(ArrayBufferContents& other);
|
|
|
-
|
|
|
- static void* AllocateMemoryOrNull(size_t, InitializationPolicy);
|
|
|
-+ static void* Realloc(void* data, size_t);
|
|
|
- static void FreeMemory(void*);
|
|
|
-
|
|
|
- private:
|