mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-10-03 02:56:41 -04:00
Reduce recompiler output memory usage, and added multi-threading to recomp process (#128)
* feat(recomp): Reduce recompiler output memory usage Stream output generation, add low-memory config controls, and avoid pathological indirect-jump switch expansion in generated C++. Low-memory mode now avoids retaining per-instruction disassembly strings while still emitting asm comments during output generation. Output workers are bounded/configurable, combined output is streamed, and decoded buffers are released after generation. Also document the new output memory settings. * fix(recomp): added tests for unregistered JR/JALR, updated fallback logic to cover JR/JALR, moved Rabbitizer formatting into R5900Decoder
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <thread>
|
||||
|
||||
namespace ps2recomp
|
||||
{
|
||||
@@ -29,6 +32,21 @@ namespace ps2recomp
|
||||
config.ghidraMapPath = toml::find_or<std::string>(general, "ghidra_output", "");
|
||||
config.outputPath = toml::find<std::string>(general, "output");
|
||||
config.singleFileOutput = toml::find_or<bool>(general, "single_file_output", false);
|
||||
config.lowMemoryMode = toml::find_or<bool>(general, "low_memory_mode", config.lowMemoryMode);
|
||||
const int64_t configuredOutputWorkers = toml::find_or<int64_t>(
|
||||
general,
|
||||
"output_worker_threads",
|
||||
toml::find_or<int64_t>(general, "output_worker_thread", config.outputWorkerThreads));
|
||||
const int64_t clampedOutputWorkers = std::clamp<int64_t>(
|
||||
configuredOutputWorkers,
|
||||
0,
|
||||
std::thread::hardware_concurrency() * 2);
|
||||
if (configuredOutputWorkers != clampedOutputWorkers)
|
||||
{
|
||||
std::cerr << "Warning: output_worker_threads value " << configuredOutputWorkers
|
||||
<< " is out of range; clamped to " << clampedOutputWorkers << "." << std::endl;
|
||||
}
|
||||
config.outputWorkerThreads = static_cast<uint32_t>(clampedOutputWorkers);
|
||||
config.patchSyscalls = toml::find_or<bool>(general, "patch_syscalls", config.patchSyscalls);
|
||||
config.patchCop0 = toml::find_or<bool>(general, "patch_cop0", config.patchCop0);
|
||||
config.patchCache = toml::find_or<bool>(general, "patch_cache", config.patchCache);
|
||||
@@ -234,6 +252,8 @@ namespace ps2recomp
|
||||
general["ghidra_output"] = config.ghidraMapPath;
|
||||
general["output"] = config.outputPath;
|
||||
general["single_file_output"] = config.singleFileOutput;
|
||||
general["low_memory_mode"] = config.lowMemoryMode;
|
||||
general["output_worker_threads"] = static_cast<int64_t>(config.outputWorkerThreads);
|
||||
general["patch_syscalls"] = config.patchSyscalls;
|
||||
general["patch_cop0"] = config.patchCop0;
|
||||
general["patch_cache"] = config.patchCache;
|
||||
|
||||
Reference in New Issue
Block a user