mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-10 01:00:18 +02:00
Creates a pool allocator for OpcodeDispatcher and IRCompaction that shares memory allocations between threads in a pool and supports reclaiming stale allocations from participating threads. A thread will use a heuristic to keep its claimed memory allocation around if it is allocating a lot of code. If it slows down then it will start putting the memory allocation back in to the thread pool. Additionally if the allocation has been "disowned" and gone to sleep while still retaining the allocation, then another thread can inspect these stale allocations and reclaim it from the idling thread. Saving further memory. This needs some more work and cleanup but this is an interesting concept that saves a decent amount of memory even in a basic test. Causes teeworlds' title screen to go from 754MB to 599MB in my simple test. 79.4% the memory usage is a good start.
34 lines
825 B
C++
34 lines
825 B
C++
#include "IRLoader/Loader.h"
|
|
#include <FEXCore/Utils/LogManager.h>
|
|
#include <FEXCore/Utils/ThreadPoolAllocator.h>
|
|
|
|
|
|
#include <FEXCore/IR/IR.h>
|
|
#include <FEXCore/IR/IREmitter.h>
|
|
|
|
#include <fstream>
|
|
#include <stdio.h>
|
|
|
|
namespace FEX::IRLoader {
|
|
Loader::Loader(std::string const &Filename, std::string const &ConfigFilename) {
|
|
Config.Init(ConfigFilename);
|
|
std::fstream fp(Filename, std::fstream::binary | std::fstream::in);
|
|
|
|
if (!fp.is_open()) {
|
|
LogMan::Msg::EFmt("Couldn't open IR file '{}'", Filename);
|
|
return;
|
|
}
|
|
|
|
ParsedCode = FEXCore::IR::Parse(Allocator, &fp);
|
|
|
|
if (ParsedCode) {
|
|
auto NewIR = ParsedCode->ViewIR();
|
|
EntryRIP = 0x40000;
|
|
|
|
std::stringstream out;
|
|
FEXCore::IR::Dump(&out, &NewIR, nullptr);
|
|
fmt::print("IR:\n{}\n@@@@@\n", out.str());
|
|
}
|
|
}
|
|
}
|