From abd5a5fc821352933edd11811abf8fcb8d3685b5 Mon Sep 17 00:00:00 2001 From: Sandeep Agarwal Date: Thu, 8 Feb 2018 14:19:11 -0800 Subject: [PATCH] OS#15659337: Try to allocate JIT code in PreReservedSegment even if CFG is not enabled This speeds up stack walking IsNativeAddress checks when CFG is not enabled. --- lib/Backend/Func.cpp | 3 +-- lib/Common/Memory/SectionAllocWrapper.cpp | 2 +- lib/Common/Memory/VirtualAllocWrapper.cpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Backend/Func.cpp b/lib/Backend/Func.cpp index b439097ff1e..f60b4d66de6 100644 --- a/lib/Backend/Func.cpp +++ b/lib/Backend/Func.cpp @@ -1144,8 +1144,7 @@ bool Func::CanAllocInPreReservedHeapPageSegment () { #ifdef _CONTROL_FLOW_GUARD return PHASE_FORCE1(Js::PreReservedHeapAllocPhase) || (!PHASE_OFF1(Js::PreReservedHeapAllocPhase) && - !IsJitInDebugMode() && GetThreadContextInfo()->IsCFGEnabled() - //&& !GetScriptContext()->IsScriptContextInDebugMode() + !IsJitInDebugMode() #if _M_IX86 && m_workItem->GetJitMode() == ExecutionMode::FullJit diff --git a/lib/Common/Memory/SectionAllocWrapper.cpp b/lib/Common/Memory/SectionAllocWrapper.cpp index 6c39914aa6f..73acc0c9ae1 100644 --- a/lib/Common/Memory/SectionAllocWrapper.cpp +++ b/lib/Common/Memory/SectionAllocWrapper.cpp @@ -868,7 +868,7 @@ LPVOID PreReservedSectionAllocWrapper::AllocPages(LPVOID lpAddress, DECLSPEC_GUA size_t dwSize = pageCount * AutoSystemInfo::PageSize; AssertMsg(isCustomHeapAllocation, "PreReservation used for allocations other than CustomHeap?"); - AssertMsg(AutoSystemInfo::Data.IsCFGEnabled() || PHASE_FORCE1(Js::PreReservedHeapAllocPhase), "PreReservation without CFG ?"); + Assert(dwSize != 0); { diff --git a/lib/Common/Memory/VirtualAllocWrapper.cpp b/lib/Common/Memory/VirtualAllocWrapper.cpp index 351f3118f80..a2ee44b1de8 100644 --- a/lib/Common/Memory/VirtualAllocWrapper.cpp +++ b/lib/Common/Memory/VirtualAllocWrapper.cpp @@ -279,7 +279,7 @@ LPVOID PreReservedVirtualAllocWrapper::AllocPages(LPVOID lpAddress, size_t pageC size_t dwSize = pageCount * AutoSystemInfo::PageSize; AssertMsg(isCustomHeapAllocation, "PreReservation used for allocations other than CustomHeap?"); - AssertMsg(AutoSystemInfo::Data.IsCFGEnabled() || PHASE_FORCE1(Js::PreReservedHeapAllocPhase), "PreReservation without CFG ?"); + Assert(dwSize != 0); {