From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aditya Tewari Date: Wed, 15 Jan 2025 12:00:00 +0000 Subject: Expose AdjustAmountOfExternalAllocatedMemoryImpl as public API The deprecated AdjustAmountOfExternalAllocatedMemory is being replaced by ExternalMemoryAccounter, but ExternalMemoryAccounter requires that adjustments return to zero before destruction. This is incompatible with workerd's design where external memory may outlive the isolate. V8 already has AdjustAmountOfExternalAllocatedMemoryImpl as a private method. This patch simply makes it public for embedder use. Signed-off-by: Aditya Tewari diff --git a/include/v8-isolate.h b/include/v8-isolate.h index 33900f10e20b5046b57643755c0c8d5fbd8bf6c6..8b4cc0f16e93cb8922d932eb57764094ec4ebb4f 100644 --- a/include/v8-isolate.h +++ b/include/v8-isolate.h @@ -1095,6 +1095,14 @@ class V8_EXPORT Isolate { */ size_t GetHeapSize(); + /** + * Adjusts external memory without destructor constraints. + * This directly calls the internal implementation without the + * zero-balance requirement of ExternalMemoryAccounter. + * Use when external memory may outlive the isolate. + */ + int64_t AdjustAmountOfExternalAllocatedMemoryImpl(int64_t change_in_bytes); + /** * Returns heap profiler for this isolate. Will return NULL until the isolate * is initialized. @@ -1908,7 +1916,6 @@ class V8_EXPORT Isolate { internal::ValueHelper::InternalRepresentationType GetDataFromSnapshotOnce( size_t index); - int64_t AdjustAmountOfExternalAllocatedMemoryImpl(int64_t change_in_bytes); }; void Isolate::SetData(uint32_t slot, void* data) {