From e69b351c7604797ee9722af7d8095f63ba1319bc Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Tue, 25 Oct 2022 10:12:28 -0700 Subject: [PATCH] Remove unused MemoryAllocation members. Remove MemoryAllocation::GetMappedPointer #679 --- src/gpgmm/common/JSONSerializer.cpp | 8 -------- src/gpgmm/common/JSONSerializer.h | 2 -- src/gpgmm/common/MemoryAllocation.cpp | 26 ++++++++------------------ src/gpgmm/common/MemoryAllocation.h | 21 ++++++--------------- 4 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/gpgmm/common/JSONSerializer.cpp b/src/gpgmm/common/JSONSerializer.cpp index 937702671..62b520bc1 100644 --- a/src/gpgmm/common/JSONSerializer.cpp +++ b/src/gpgmm/common/JSONSerializer.cpp @@ -64,14 +64,6 @@ namespace gpgmm { return dict; } - // static - JSONDict JSONSerializer::Serialize(const MemoryAllocationInfo& info) { - JSONDict dict; - dict.AddItem("SizeInBytes", info.SizeInBytes); - dict.AddItem("Alignment", info.Alignment); - return dict; - } - // static JSONDict JSONSerializer::Serialize(const void* objectPtr) { JSONDict dict; diff --git a/src/gpgmm/common/JSONSerializer.h b/src/gpgmm/common/JSONSerializer.h index fe52148d3..9767eeb35 100644 --- a/src/gpgmm/common/JSONSerializer.h +++ b/src/gpgmm/common/JSONSerializer.h @@ -22,7 +22,6 @@ namespace gpgmm { // Forward declare common types. struct MemoryPoolInfo; struct MemoryAllocatorStats; - struct MemoryAllocationInfo; struct MemoryAllocationRequest; struct EventMessageInfo; @@ -32,7 +31,6 @@ namespace gpgmm { static JSONDict Serialize(const EventMessageInfo& info); static JSONDict Serialize(const MemoryAllocatorStats& info); static JSONDict Serialize(const MemoryAllocationRequest& desc); - static JSONDict Serialize(const MemoryAllocationInfo& info); static JSONDict Serialize(const MemoryPoolInfo& desc); static JSONDict Serialize(const void* objectPtr); }; diff --git a/src/gpgmm/common/MemoryAllocation.cpp b/src/gpgmm/common/MemoryAllocation.cpp index 2228a3a16..e8b8dde20 100644 --- a/src/gpgmm/common/MemoryAllocation.cpp +++ b/src/gpgmm/common/MemoryAllocation.cpp @@ -26,8 +26,10 @@ namespace gpgmm { mMemory(nullptr), mOffset(kInvalidOffset), mMethod(AllocationMethod::kUndefined), - mBlock(nullptr), - mMappedPointer(nullptr) { +#ifdef GPGMM_ENABLE_MEMORY_ALIGN_CHECKS + mRequestSize(kInvalidSize), +#endif + mBlock(nullptr) { } MemoryAllocation::MemoryAllocation(MemoryAllocator* allocator, @@ -35,32 +37,28 @@ namespace gpgmm { uint64_t offset, AllocationMethod method, MemoryBlock* block, - uint64_t requestSize, - uint8_t* mappedPointer) + uint64_t requestSize) : mAllocator(allocator), mMemory(memory), mOffset(offset), mMethod(method), - mBlock(block), #ifdef GPGMM_ENABLE_MEMORY_ALIGN_CHECKS mRequestSize(requestSize), #endif - mMappedPointer(mappedPointer) { + mBlock(block) { } MemoryAllocation::MemoryAllocation(MemoryAllocator* allocator, MemoryBase* memory, - uint64_t requestSize, - uint8_t* mappedPointer) + uint64_t requestSize) : mAllocator(allocator), mMemory(memory), mOffset(0), mMethod(AllocationMethod::kStandalone), - mBlock(nullptr), #ifdef GPGMM_ENABLE_MEMORY_ALIGN_CHECKS mRequestSize(requestSize), #endif - mMappedPointer(mappedPointer) { + mBlock(nullptr) { } bool MemoryAllocation::operator==(const MemoryAllocation& other) const { @@ -72,18 +70,10 @@ namespace gpgmm { return !operator==(other); } - MemoryAllocationInfo MemoryAllocation::GetInfo() const { - return {GetSize(), GetAlignment()}; - } - MemoryBase* MemoryAllocation::GetMemory() const { return mMemory; } - uint8_t* MemoryAllocation::GetMappedPointer() const { - return mMappedPointer; - } - MemoryAllocator* MemoryAllocation::GetAllocator() const { return mAllocator; } diff --git a/src/gpgmm/common/MemoryAllocation.h b/src/gpgmm/common/MemoryAllocation.h index 3d4b6b2aa..9cb9534ef 100644 --- a/src/gpgmm/common/MemoryAllocation.h +++ b/src/gpgmm/common/MemoryAllocation.h @@ -26,11 +26,6 @@ namespace gpgmm { struct MemoryBlock; class MemoryAllocator; - struct MemoryAllocationInfo { - uint64_t SizeInBytes; - uint64_t Alignment; - }; - // Represents a location and range in memory. class MemoryAllocation { public: @@ -43,14 +38,10 @@ namespace gpgmm { uint64_t offset, AllocationMethod method, MemoryBlock* block, - uint64_t requestSize, - uint8_t* mappedPointer = nullptr); + uint64_t requestSize); // Constructs a "standalone" memory allocation. - MemoryAllocation(MemoryAllocator* allocator, - MemoryBase* memory, - uint64_t requestSize, - uint8_t* mappedPointer = nullptr); + MemoryAllocation(MemoryAllocator* allocator, MemoryBase* memory, uint64_t requestSize); virtual ~MemoryAllocation() = default; @@ -59,9 +50,7 @@ namespace gpgmm { bool operator==(const MemoryAllocation&) const; bool operator!=(const MemoryAllocation& other) const; - MemoryAllocationInfo GetInfo() const; MemoryBase* GetMemory() const; - uint8_t* GetMappedPointer() const; MemoryAllocator* GetAllocator() const; uint64_t GetSize() const; uint64_t GetRequestSize() const; @@ -79,10 +68,12 @@ namespace gpgmm { MemoryBase* mMemory; uint64_t mOffset; // Offset always local to the memory. AllocationMethod mMethod; - MemoryBlock* mBlock; +#ifdef GPGMM_ENABLE_MEMORY_ALIGN_CHECKS uint64_t mRequestSize; - uint8_t* mMappedPointer; +#endif + + MemoryBlock* mBlock; }; } // namespace gpgmm