From 5f97f74a9aeed0b00b7592becef58a6fc4943d6a Mon Sep 17 00:00:00 2001 From: yzct12345 <87620833+yzct12345@users.noreply.github.com> Date: Sat, 7 Aug 2021 03:03:21 +0000 Subject: [PATCH] memory: Address lioncash's review --- src/core/memory.cpp | 58 +++++---------------------------------------- 1 file changed, 6 insertions(+), 52 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 778d152dd..51c4dea26 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -5,10 +5,6 @@ #include #include -#define BOOST_HANA_CONFIG_ENABLE_STRING_UDL -#include -#undef BOOST_HANA_CONFIG_ENABLE_STRING_UDL - #include "common/assert.h" #include "common/atomic_ops.h" #include "common/common_types.h" @@ -23,8 +19,6 @@ #include "core/memory.h" #include "video_core/gpu.h" -using namespace boost::hana::literals; - namespace Core::Memory { // Implementation class used to keep the specifics of the memory subsystem hidden @@ -446,42 +440,6 @@ struct Memory::Impl { } } - /** - * Returns a message like "Unmapped NameBits @ 0x{:016X}Suffix". - * - * @tparam NAME The caller name like "Read"_s or "Write"_s. - * @tparam BYTES The number of bits written. 0 is for read and sizeof(T) is for write. - * @tparam SUFFIX A suffix. ""_s is for read and " = 0x{:016X}" is for write. - */ - template - static consteval const char* GetPointerImplError() { - constexpr auto unmapped_fmt = ([]() { - constexpr auto prefix = "Unmapped "_s + NAME; - constexpr auto suffix = " @ 0x{:016X}"_s + SUFFIX; - const char* result = nullptr; - switch (BYTES * 8) { - case 0: - result = (prefix + suffix).c_str(); - break; -#define BITS_CASE(x) \ - case x: \ - result = (prefix + BOOST_HANA_STRING(#x) + suffix).c_str(); \ - break; - BITS_CASE(8) - BITS_CASE(16) - BITS_CASE(32) - BITS_CASE(64) - BITS_CASE(128) -#undef BITS_CASE - default: - break; - } - return result; - })(); - static_assert(unmapped_fmt); - return unmapped_fmt; - } - [[nodiscard]] u8* GetPointerImpl(VAddr vaddr, auto on_unmapped, auto on_rasterizer) const { // AARCH64 masks the upper 16 bit of all memory accesses vaddr &= 0xffffffffffffLL; @@ -516,10 +474,7 @@ struct Memory::Impl { [[nodiscard]] u8* GetPointer(const VAddr vaddr) const { return GetPointerImpl( - vaddr, - [vaddr]() { - LOG_ERROR(HW_Memory, GetPointerImplError<"GetPointer"_s, 0, ""_s>(), vaddr); - }, + vaddr, [vaddr]() { LOG_ERROR(HW_Memory, "Unmapped GetPointer @ 0x{:016X}", vaddr); }, []() {}); } @@ -540,7 +495,7 @@ struct Memory::Impl { const u8* const ptr = GetPointerImpl( vaddr, [vaddr]() { - LOG_ERROR(HW_Memory, GetPointerImplError<"Read"_s, sizeof(T), ""_s>(), vaddr); + LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8, vaddr); }, [&system = system, vaddr]() { system.GPU().FlushRegion(vaddr, sizeof(T)); }); if (ptr) { @@ -563,7 +518,7 @@ struct Memory::Impl { u8* const ptr = GetPointerImpl( vaddr, [vaddr, data]() { - LOG_ERROR(HW_Memory, GetPointerImplError<"Write"_s, sizeof(T), " = 0x{:016X}"_s>(), + LOG_ERROR(HW_Memory, "Unmapped Write{} @ 0x{:016X} = 0x{:016X}", sizeof(T) * 8, vaddr, static_cast(data)); }, [&system = system, vaddr]() { system.GPU().InvalidateRegion(vaddr, sizeof(T)); }); @@ -577,8 +532,8 @@ struct Memory::Impl { u8* const ptr = GetPointerImpl( vaddr, [vaddr, data]() { - LOG_ERROR(HW_Memory, GetPointerImplError<"Write"_s, sizeof(T), " = 0x{:016X}"_s>(), - vaddr, static_cast(data)); + LOG_ERROR(HW_Memory, "Unmapped WriteExclusive{} @ 0x{:016X} = 0x{:016X}", + sizeof(T) * 8, vaddr, static_cast(data)); }, [&system = system, vaddr]() { system.GPU().InvalidateRegion(vaddr, sizeof(T)); }); if (ptr) { @@ -592,8 +547,7 @@ struct Memory::Impl { u8* const ptr = GetPointerImpl( vaddr, [vaddr, data]() { - LOG_ERROR(HW_Memory, - GetPointerImplError<"Write"_s, sizeof(u128), " = 0x{:016X}{:016X}"_s>(), + LOG_ERROR(HW_Memory, "Unmapped WriteExclusive128 @ 0x{:016X} = 0x{:016X}{:016X}", vaddr, static_cast(data[1]), static_cast(data[0])); }, [&system = system, vaddr]() { system.GPU().InvalidateRegion(vaddr, sizeof(u128)); });