dont break strict aliasing

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-10-19 23:58:36 +00:00
parent e237bd52ce
commit a8fb85badf
No known key found for this signature in database
GPG key ID: 00287378CADCAB13
2 changed files with 11 additions and 5 deletions

View file

@ -795,17 +795,22 @@ std::optional<u64> MatchAndExecuteOneInstruction(Core::Memory::Memory& memory, v
CTX_DECLARE(raw_context);
std::span<u64, 31> regs(reinterpret_cast<u64*>(&CTX_X(0)), 31);
std::span<u128, 32> vregs(reinterpret_cast<u128*>(&CTX_Q(0)), 32);
u64& sp = *reinterpret_cast<u64*>(&CTX_SP);
const u64& pc = *reinterpret_cast<u64*>(&CTX_PC);
InterpreterVisitor visitor(memory, regs, vregs, sp, pc);
u32 instruction = memory.Read32(pc);
// Store temporal to not break aliasing rules :)
u64 tmp_sp = CTX_SP;
u64 tmp_pc = CTX_PC;
InterpreterVisitor visitor(memory, regs, vregs, tmp_sp, tmp_pc);
CTX_SP = tmp_sp;
CTX_PC = tmp_pc;
u32 instruction = memory.Read32(tmp_pc);
bool was_executed = false;
if (auto decoder = Dynarmic::A64::Decode<VisitorBase>(instruction)) {
was_executed = decoder->get().call(visitor, instruction);
} else {
LOG_ERROR(Core_ARM, "Unallocated encoding: {:#x}", instruction);
}
return was_executed ? std::optional<u64>(pc + 4) : std::nullopt;
return was_executed ? std::optional<u64>(tmp_pc + 4) : std::nullopt;
}
} // namespace Core

View file

@ -7,6 +7,7 @@
#include <shared_mutex>
#include <unordered_map>
#include <utility>
#include <mutex>
#include "common/logging/log.h"