diff --git a/tests/A64/fuzz_with_unicorn.cpp b/tests/A64/fuzz_with_unicorn.cpp index d9142012..49c9d4c9 100644 --- a/tests/A64/fuzz_with_unicorn.cpp +++ b/tests/A64/fuzz_with_unicorn.cpp @@ -90,27 +90,31 @@ restart: } static void RunTestInstance(const std::array& regs, const std::array& vecs, const size_t instructions_offset, const std::vector& instructions, const u32 pstate) { - TestEnv jit_env; - TestEnv uni_env; + static TestEnv jit_env; + static TestEnv uni_env; std::copy(instructions.begin(), instructions.end(), jit_env.code_mem.begin() + instructions_offset); std::copy(instructions.begin(), instructions.end(), uni_env.code_mem.begin() + instructions_offset); jit_env.code_mem[instructions.size() + instructions_offset] = 0x14000000; // B . uni_env.code_mem[instructions.size() + instructions_offset] = 0x14000000; // B . + jit_env.modified_memory.clear(); + uni_env.modified_memory.clear(); - Dynarmic::A64::Jit jit{Dynarmic::A64::UserConfig{&jit_env}}; - Unicorn uni{uni_env}; + static Dynarmic::A64::Jit jit{Dynarmic::A64::UserConfig{&jit_env}}; + static Unicorn uni{uni_env}; jit.SetRegisters(regs); jit.SetVectors(vecs); jit.SetPC(instructions_offset * 4); jit.SetSP(0x08000000); jit.SetPstate(pstate); + jit.ClearCache(); uni.SetRegisters(regs); uni.SetVectors(vecs); uni.SetPC(instructions_offset * 4); uni.SetSP(0x08000000); uni.SetPstate(pstate); + uni.ClearPageCache(); jit_env.ticks_left = instructions.size(); jit.Run(); diff --git a/tests/A64/unicorn_emu/unicorn.cpp b/tests/A64/unicorn_emu/unicorn.cpp index 9985484d..93cc4966 100644 --- a/tests/A64/unicorn_emu/unicorn.cpp +++ b/tests/A64/unicorn_emu/unicorn.cpp @@ -28,9 +28,7 @@ Unicorn::Unicorn(TestEnv& testenv) : testenv(testenv) { } Unicorn::~Unicorn() { - for (const auto& page : pages) { - CHECKED(uc_mem_unmap(uc, page->address, 4096)); - } + ClearPageCache(); CHECKED(uc_hook_del(uc, intr_hook)); CHECKED(uc_hook_del(uc, mem_invalid_hook)); CHECKED(uc_close(uc)); @@ -135,6 +133,9 @@ void Unicorn::SetPstate(u32 value) { } void Unicorn::ClearPageCache() { + for (const auto& page : pages) { + CHECKED(uc_mem_unmap(uc, page->address, 4096)); + } pages.clear(); }