From 33035f96a29af6556dbe8a1dc036fe71d8af5334 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Mon, 17 May 2021 19:34:04 -0700 Subject: [PATCH] chore: remove add_realloc.patch (#29131) --- patches/chromium/.patches | 1 - patches/chromium/add_realloc.patch | 83 ------------------- ..._v8_initialization_isolate_callbacks.patch | 2 +- patches/v8/.patches | 1 - patches/v8/add_realloc.patch | 46 ---------- patches/v8/dcheck.patch | 4 +- shell/browser/javascript_environment.cc | 4 - 7 files changed, 3 insertions(+), 138 deletions(-) delete mode 100644 patches/chromium/add_realloc.patch delete mode 100644 patches/v8/add_realloc.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 8271c33bb04..91e0073d9b2 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -1,4 +1,3 @@ -add_realloc.patch build_gn.patch dcheck.patch accelerator.patch diff --git a/patches/chromium/add_realloc.patch b/patches/chromium/add_realloc.patch deleted file mode 100644 index 9ff226f6874..00000000000 --- a/patches/chromium/add_realloc.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shelley Vohr -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: diff --git a/patches/chromium/chore_expose_v8_initialization_isolate_callbacks.patch b/patches/chromium/chore_expose_v8_initialization_isolate_callbacks.patch index f0da1d0a070..52daab18ef7 100644 --- a/patches/chromium/chore_expose_v8_initialization_isolate_callbacks.patch +++ b/patches/chromium/chore_expose_v8_initialization_isolate_callbacks.patch @@ -9,7 +9,7 @@ we're running with contextIsolation enabled, we should be falling back to Blink's logic. This will be upstreamed in some form. 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 d91c4344145f5ff2b081a5a9a3e931e9746a07af..9bf3523e1a307a469129df6e48f04df051f5003f 100644 +index c79fd01a887a54eed3868642b4e8d5a4b050ecca..9c2d6db4b8801e30c6f03bd778bd46c1d1d92e60 100644 --- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc +++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc @@ -449,7 +449,7 @@ CodeGenerationCheckCallbackInMainThread(v8::Local context, diff --git a/patches/v8/.patches b/patches/v8/.patches index 61e50e1801d..a2c70b4ec4d 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -1,4 +1,3 @@ -add_realloc.patch build_gn.patch expose_mksnapshot.patch dcheck.patch diff --git a/patches/v8/add_realloc.patch b/patches/v8/add_realloc.patch deleted file mode 100644 index 93830dcf1d3..00000000000 --- a/patches/v8/add_realloc.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shelley Vohr -Date: Mon, 22 Oct 2018 10:47:11 -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. - -diff --git a/include/v8.h b/include/v8.h -index 81fbe7f97f1f0945b4712287f0c511cc6920379c..c5b2c17da660dbc9fe40e2d33cb09db2554c2507 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -5363,6 +5363,13 @@ class V8_EXPORT ArrayBuffer : public Object { - */ - virtual void* AllocateUninitialized(size_t length) = 0; - -+ /** -+ * Free the memory block of size |length|, pointed to by |data|. -+ * That memory must be previously allocated by |Allocate| and not yet freed -+ * with a call to |Free| or |Realloc| -+ */ -+ virtual void* Realloc(void* data, size_t length); -+ - /** - * Free the memory block of size |length|, pointed to by |data|. - * That memory is guaranteed to be previously allocated by |Allocate|. -diff --git a/src/api/api.cc b/src/api/api.cc -index 8f0cd7eaf0f1f2ecf81293e5a401c10139a06824..62b4be5bf0e64f04da22cbf32643ab86cb901bb6 100644 ---- a/src/api/api.cc -+++ b/src/api/api.cc -@@ -324,6 +324,10 @@ void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { - i::V8::SetSnapshotBlob(snapshot_blob); - } - -+void* v8::ArrayBuffer::Allocator::Realloc(void* data, size_t length) { -+ UNIMPLEMENTED(); -+} -+ - namespace { - - class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { diff --git a/patches/v8/dcheck.patch b/patches/v8/dcheck.patch index 5b53df2d01e..0918bc3938d 100644 --- a/patches/v8/dcheck.patch +++ b/patches/v8/dcheck.patch @@ -6,10 +6,10 @@ Subject: dcheck.patch https://github.com/auchenberg/volkswagen diff --git a/src/api/api.cc b/src/api/api.cc -index 62b4be5bf0e64f04da22cbf32643ab86cb901bb6..f7f0e7ee899746be121f6b840988cd8e46a1e194 100644 +index 8f0cd7eaf0f1f2ecf81293e5a401c10139a06824..f66ed281cc2d524797ec82638cfdbbad9e4a85b9 100644 --- a/src/api/api.cc +++ b/src/api/api.cc -@@ -8762,7 +8762,7 @@ void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { +@@ -8758,7 +8758,7 @@ void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { } void Isolate::PerformMicrotaskCheckpoint() { diff --git a/shell/browser/javascript_environment.cc b/shell/browser/javascript_environment.cc index d2a0b6a07f0..267214633ce 100644 --- a/shell/browser/javascript_environment.cc +++ b/shell/browser/javascript_environment.cc @@ -93,10 +93,6 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { return result; } - void* Realloc(void* data, size_t size) override { - return allocator_->root()->Realloc(data, size, "Electron"); - } - void Free(void* data, size_t size) override { allocator_->root()->Free(data); }