Files
FEX-Emu--FEX/Source/Tests/IRLoader/Loader.cpp
T
Ryan Houdek 753d0ede6c FEXCore: Reclaimable thread pool allocator
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.
2022-04-26 10:01:56 -07:00

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());
}
}
}