Skip to content

Commit abd6d13

Browse files
committed
[MERGE #1666 @leirocks] report number allocator allocated pages by the JIT server
Merge pull request #1666 from leirocks:numpagereport
2 parents 7830e58 + 237527d commit abd6d13

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

lib/Common/Memory/AllocationPolicyManager.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,20 @@ typedef bool (__stdcall * PageAllocatorMemoryAllocationCallback)(__in LPVOID con
6363
memoryLimit = newLimit;
6464
}
6565

66-
bool RequestAlloc(DECLSPEC_GUARD_OVERFLOW size_t byteCount)
66+
bool RequestAlloc(DECLSPEC_GUARD_OVERFLOW size_t byteCount, bool externalAlloc = false)
6767
{
6868
if (supportConcurrency)
6969
{
7070
AutoCriticalSection auto_cs(&cs);
71-
return RequestAllocImpl(byteCount);
71+
return RequestAllocImpl(byteCount, externalAlloc);
7272
}
7373
else
7474
{
75-
return RequestAllocImpl(byteCount);
75+
return RequestAllocImpl(byteCount, externalAlloc);
7676
}
7777
}
7878

79+
7980
void ReportFailure(size_t byteCount)
8081
{
8182
if (supportConcurrency)
@@ -119,7 +120,7 @@ typedef bool (__stdcall * PageAllocatorMemoryAllocationCallback)(__in LPVOID con
119120
}
120121

121122
private:
122-
inline bool RequestAllocImpl(size_t byteCount)
123+
inline bool RequestAllocImpl(size_t byteCount, bool externalAlloc = false)
123124
{
124125
size_t newCurrentMemory = currentMemory + byteCount;
125126

@@ -131,6 +132,12 @@ typedef bool (__stdcall * PageAllocatorMemoryAllocationCallback)(__in LPVOID con
131132
{
132133
memoryAllocationCallback(context, MemoryAllocateEvent::MemoryFailure, byteCount);
133134
}
135+
136+
// oopjit number allocator allocated pages, we can't stop it from allocating so just increase the usage number
137+
if (externalAlloc)
138+
{
139+
currentMemory = newCurrentMemory;
140+
}
134141

135142
return false;
136143
}

lib/Common/Memory/PageAllocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ PageSegmentBase<T> *
735735
PageAllocatorBase<T>::AllocPageSegment(DListBase<PageSegmentBase<T>>& segmentList, PageAllocatorBase<T> * pageAllocator, void* address, uint pageCount, uint committedCount)
736736
{
737737
PageSegmentBase<T> * segment = segmentList.PrependNode(&NoThrowNoMemProtectHeapAllocator::Instance, pageAllocator, address, pageCount, committedCount);
738-
738+
pageAllocator->ReportExternalAlloc(pageCount * AutoSystemInfo::PageSize);
739739
return segment;
740740
}
741741

lib/Common/Memory/PageAllocator.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,14 @@ class PageAllocatorBase
725725
return true;
726726
}
727727

728+
void ReportExternalAlloc(size_t byteCount)
729+
{
730+
if (policyManager != nullptr)
731+
{
732+
policyManager->RequestAlloc(byteCount, true);
733+
}
734+
}
735+
728736
void ReportFree(size_t byteCount)
729737
{
730738
if (policyManager != nullptr)

0 commit comments

Comments
 (0)