From 91d80aa7b9bbbf077a048029e0681967855032ea Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 7 Apr 2020 16:09:47 +0300 Subject: [PATCH] Implement jit_compiler::check Instead of checking file existence (because file may be damaged). --- Utilities/JIT.cpp | 13 +++++++++++++ Utilities/JIT.h | 3 +++ rpcs3/Emu/Cell/PPUThread.cpp | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index dddb7bb18f..056f32c981 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -1200,6 +1200,19 @@ void jit_compiler::add(const std::string& path) } } +bool jit_compiler::check(const std::string& path) +{ + if (auto cache = ObjectCache::load(path)) + { + if (auto object_file = llvm::object::ObjectFile::createObjectFile(*cache)) + { + return true; + } + } + + return false; +} + void jit_compiler::fin() { m_engine->finalizeObject(); diff --git a/Utilities/JIT.h b/Utilities/JIT.h index 2243c1e3e9..ecd55716e0 100644 --- a/Utilities/JIT.h +++ b/Utilities/JIT.h @@ -171,6 +171,9 @@ public: // Add object (path to obj file) void add(const std::string& path); + // Check object file + static bool check(const std::string& path); + // Finalize void fin(); diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 98293f3be6..f29b824c9c 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1650,7 +1650,7 @@ extern void ppu_initialize(const ppu_module& info) link_workload.emplace_back(obj_name, false); // Check object file - if (fs::is_file(cache_path + obj_name + ".gz") || fs::is_file(cache_path + obj_name)) + if (jit_compiler::check(cache_path + obj_name)) { if (!jit) {