A32/x64: Create a global_offset optimization for the page table (#507)

Instead of looking up the page table like:
  table[addr >> 12][addr & 0xFFF]
We can use a global offset on the table to query the memory like:
  table[addr >> 12][addr]

This saves two instructions on *every* memory access within the recompiler.

Original change by degasus in A64 emitter
This commit is contained in:
Marshall Mohror 2020-03-22 12:55:07 -05:00 committed by MerryMage
parent e10985d179
commit 1ebc1895ee
2 changed files with 49 additions and 37 deletions

View file

@ -93,6 +93,13 @@ struct UserConfig {
static constexpr std::size_t PAGE_BITS = 12;
static constexpr std::size_t NUM_PAGE_TABLE_ENTRIES = 1 << (32 - PAGE_BITS);
std::array<std::uint8_t*, NUM_PAGE_TABLE_ENTRIES>* page_table = nullptr;
/// Determines if the pointer in the page_table shall be offseted locally or globally.
/// 'false' will access page_table[addr >> bits][addr & mask]
/// 'true' will access page_table[addr >> bits][addr]
/// Note: page_table[addr >> bits] will still be checked to verify active pages.
/// So there might be wrongly faulted pages which maps to nullptr.
/// This can be avoided by carefully allocating the memory region.
bool absolute_offset_page_table = false;
// Coprocessors
std::array<std::shared_ptr<Coprocessor>, 16> coprocessors;