page_table.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2019 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/page_table.h"
  5. namespace Common {
  6. PageTable::PageTable(std::size_t page_size_in_bits) : page_size_in_bits{page_size_in_bits} {}
  7. PageTable::~PageTable() = default;
  8. void PageTable::Resize(std::size_t address_space_width_in_bits) {
  9. const std::size_t num_page_table_entries = 1ULL
  10. << (address_space_width_in_bits - page_size_in_bits);
  11. pointers.resize(num_page_table_entries);
  12. attributes.resize(num_page_table_entries);
  13. backing_addr.resize(num_page_table_entries);
  14. // The default is a 39-bit address space, which causes an initial 1GB allocation size. If the
  15. // vector size is subsequently decreased (via resize), the vector might not automatically
  16. // actually reallocate/resize its underlying allocation, which wastes up to ~800 MB for
  17. // 36-bit titles. Call shrink_to_fit to reduce capacity to what's actually in use.
  18. pointers.shrink_to_fit();
  19. attributes.shrink_to_fit();
  20. backing_addr.shrink_to_fit();
  21. }
  22. } // namespace Common