Allocate guest objects in last quarter of memory heap
This commit is contained in:
parent
7be4b7a138
commit
af806ee98f
|
@ -553,9 +553,9 @@ uint32_t Memory::SystemHeapAlloc(uint32_t size, uint32_t alignment,
|
||||||
bool is_physical = !!(system_heap_flags & kSystemHeapPhysical);
|
bool is_physical = !!(system_heap_flags & kSystemHeapPhysical);
|
||||||
auto heap = LookupHeapByType(is_physical, 4096);
|
auto heap = LookupHeapByType(is_physical, 4096);
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
if (!heap->Alloc(size, alignment,
|
if (!heap->AllocSystemHeap(
|
||||||
kMemoryAllocationReserve | kMemoryAllocationCommit,
|
size, alignment, kMemoryAllocationReserve | kMemoryAllocationCommit,
|
||||||
kMemoryProtectRead | kMemoryProtectWrite, false, &address)) {
|
kMemoryProtectRead | kMemoryProtectWrite, false, &address)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Zero(address, size);
|
Zero(address, size);
|
||||||
|
@ -1059,6 +1059,24 @@ bool BaseHeap::AllocRange(uint32_t low_address, uint32_t high_address,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BaseHeap::AllocSystemHeap(uint32_t size, uint32_t alignment,
|
||||||
|
uint32_t allocation_type, uint32_t protect,
|
||||||
|
bool top_down, uint32_t* out_address) {
|
||||||
|
*out_address = 0;
|
||||||
|
size = xe::round_up(size, page_size_);
|
||||||
|
alignment = xe::round_up(alignment, page_size_);
|
||||||
|
|
||||||
|
uint32_t low_address = heap_base_;
|
||||||
|
if (heap_type_ == xe::HeapType::kGuestVirtual) {
|
||||||
|
// Both virtual heaps are same size, so we can assume that we substract
|
||||||
|
// constant value.
|
||||||
|
low_address = heap_base_ + heap_size_ - 0x10000000;
|
||||||
|
}
|
||||||
|
uint32_t high_address = heap_base_ + (heap_size_ - 1);
|
||||||
|
return AllocRange(low_address, high_address, size, alignment, allocation_type,
|
||||||
|
protect, top_down, out_address);
|
||||||
|
}
|
||||||
|
|
||||||
bool BaseHeap::Decommit(uint32_t address, uint32_t size) {
|
bool BaseHeap::Decommit(uint32_t address, uint32_t size) {
|
||||||
uint32_t page_count = get_page_count(size, page_size_);
|
uint32_t page_count = get_page_count(size, page_size_);
|
||||||
uint32_t start_page_number = (address - heap_base_) / page_size_;
|
uint32_t start_page_number = (address - heap_base_) / page_size_;
|
||||||
|
|
Loading…
Reference in New Issue