File
Blob: patches/v8/0030-Expose-AdjustAmountOfExternalAllocatedMemoryImpl-as-.patch
| 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | From: Aditya Tewari <adityaatewari@gmail.com> |
| 3 | Date: Wed, 15 Jan 2025 12:00:00 +0000 |
| 4 | Subject: Expose AdjustAmountOfExternalAllocatedMemoryImpl as public API |
| 5 | |
| 6 | The deprecated AdjustAmountOfExternalAllocatedMemory is being replaced |
| 7 | by ExternalMemoryAccounter, but ExternalMemoryAccounter requires that |
| 8 | adjustments return to zero before destruction. This is incompatible with |
| 9 | workerd's design where external memory may outlive the isolate. |
| 10 | |
| 11 | V8 already has AdjustAmountOfExternalAllocatedMemoryImpl as a private |
| 12 | method. This patch simply makes it public for embedder use. |
| 13 | |
| 14 | Signed-off-by: Aditya Tewari <adityaatewari@gmail.com> |
| 15 | |
| 16 | diff --git a/include/v8-isolate.h b/include/v8-isolate.h |
| 17 | index 33900f10e20b5046b57643755c0c8d5fbd8bf6c6..8b4cc0f16e93cb8922d932eb57764094ec4ebb4f 100644 |
| 18 | --- a/include/v8-isolate.h |
| 19 | +++ b/include/v8-isolate.h |
| 20 | @@ -1095,6 +1095,14 @@ class V8_EXPORT Isolate { |
| 21 | */ |
| 22 | size_t GetHeapSize(); |
| 23 | |
| 24 | + /** |
| 25 | + * Adjusts external memory without destructor constraints. |
| 26 | + * This directly calls the internal implementation without the |
| 27 | + * zero-balance requirement of ExternalMemoryAccounter. |
| 28 | + * Use when external memory may outlive the isolate. |
| 29 | + */ |
| 30 | + int64_t AdjustAmountOfExternalAllocatedMemoryImpl(int64_t change_in_bytes); |
| 31 | + |
| 32 | /** |
| 33 | * Returns heap profiler for this isolate. Will return NULL until the isolate |
| 34 | * is initialized. |
| 35 | @@ -1908,7 +1916,6 @@ class V8_EXPORT Isolate { |
| 36 | |
| 37 | internal::ValueHelper::InternalRepresentationType GetDataFromSnapshotOnce( |
| 38 | size_t index); |
| 39 | - int64_t AdjustAmountOfExternalAllocatedMemoryImpl(int64_t change_in_bytes); |
| 40 | }; |
| 41 | |
| 42 | void Isolate::SetData(uint32_t slot, void* data) { |