2
0
Эх сурвалжийг харах

Avoid calling VirtualAlloc to commit the secondary pages if the secondary allocation size is 0

Curtis Man 10 жил өмнө
parent
commit
9847a1b5c7

+ 5 - 4
lib/Common/Memory/PageAllocator.cpp

@@ -2419,14 +2419,15 @@ bool HeapPageAllocator<T>::CreateSecondaryAllocator(SegmentBase<T>* segment, boo
     // If we are not allocating xdata there is nothing to do
 
     // ARM might allocate XDATA but not have a reserved region for it (no secondary alloc reserved space)
-    if(!allocXdata)
+    if (!allocXdata)
     {
         Assert(segment->GetSecondaryAllocSize() == 0);
         *allocator = nullptr;
         return true;
     }
 
-    if (!committed && !this->GetVirtualAllocator()->Alloc(segment->GetSecondaryAllocStartAddress(), segment->GetSecondaryAllocSize(),
+    if (!committed && segment->GetSecondaryAllocSize() != 0 &&
+        !this->GetVirtualAllocator()->Alloc(segment->GetSecondaryAllocStartAddress(), segment->GetSecondaryAllocSize(),
         MEM_COMMIT, PAGE_READWRITE, true))
     {
         *allocator = nullptr;
@@ -2435,9 +2436,9 @@ bool HeapPageAllocator<T>::CreateSecondaryAllocator(SegmentBase<T>* segment, boo
 
     XDataAllocator* secondaryAllocator = HeapNewNoThrow(XDataAllocator, (BYTE*)segment->GetSecondaryAllocStartAddress(), segment->GetSecondaryAllocSize());
     bool success = false;
-    if(secondaryAllocator)
+    if (secondaryAllocator)
     {
-        if(secondaryAllocator->Initialize((BYTE*)segment->GetAddress(), (BYTE*)segment->GetEndAddress()))
+        if (secondaryAllocator->Initialize((BYTE*)segment->GetAddress(), (BYTE*)segment->GetEndAddress()))
         {
             success = true;
         }

+ 2 - 2
lib/Common/Memory/amd64/XDataAllocator.cpp

@@ -21,7 +21,7 @@ XDataAllocator::XDataAllocator(BYTE* address, uint size) :
     functionTableHandles(nullptr)
 {
 #ifdef RECYCLER_MEMORY_VERIFY
-        memset(this->start, Recycler::VerifyMemFill, this->size);
+    memset(this->start, Recycler::VerifyMemFill, this->size);
 #endif
     Assert(size > 0);
     Assert(address != nullptr);
@@ -97,7 +97,7 @@ bool XDataAllocator::Alloc(ULONG_PTR functionStart, DWORD functionSize, ushort p
     Assert(current != nullptr);
     Assert(current >= start);
     Assert(xdataSize <= XDATA_SIZE);
-    Assert(AutoSystemInfo::Data.IsWin8OrLater() || pdataCount == 1);
+    Assert(pdataCount == 1);
 
     // Allocate a new xdata entry
     if((End() - current) >= XDATA_SIZE)