Minor cleanup in BlockCache

This commit is contained in:
Ryan Houdek 2019-10-09 17:36:41 -07:00 committed by Stefanos Kornilios Mitsis Poiitidis
parent 47d91e05f0
commit c2e8c8d430
2 changed files with 6 additions and 4 deletions

View File

@ -21,7 +21,7 @@ BlockCache::BlockCache(FEXCore::Context::Context *CTX)
// At 64GB of virtual memory this will allocate 128MB of virtual memory space
PagePointer = reinterpret_cast<uintptr_t>(mmap(nullptr, ctx->Config.VirtualMemSize / 4096 * 8, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
// Allocate our memory backing our pageso
// Allocate our memory backing our pages
// We need 32KB per guest page (One pointer per byte)
// XXX: We can drop down to 16KB if we store 4byte offsets from the code base
// We currently limit to 128MB of real memory for caching for the total cache size.

View File

@ -21,14 +21,14 @@ public:
Address >>= 12;
uintptr_t *Pointers = reinterpret_cast<uintptr_t*>(PagePointer);
uint64_t PagePointer = Pointers[Address];
if (!PagePointer) {
uint64_t LocalPagePointer = Pointers[Address];
if (!LocalPagePointer) {
// Page for this code didn't even exist, nothing to do
return;
}
// Page exists, just set the offset to zero
uintptr_t *BlockPointers = reinterpret_cast<uintptr_t*>(PagePointer);
uintptr_t *BlockPointers = reinterpret_cast<uintptr_t*>(LocalPagePointer);
BlockPointers[PageOffset] = 0;
}
@ -61,6 +61,8 @@ public:
void HintUsedRange(uint64_t Address, uint64_t Size);
uintptr_t GetPagePointer() { return PagePointer; }
private:
uintptr_t AllocateBackingForPage() {
uintptr_t NewBase = AllocateOffset;