Skip to content

Commit

Permalink
fix issue that prevented using prereserved segment on x86
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeHolman committed Sep 15, 2016
1 parent 8f5d428 commit 1e7d27e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
13 changes: 12 additions & 1 deletion lib/Backend/NativeCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2865,12 +2865,23 @@ NativeCodeGenerator::GatherCodeGenData(Js::FunctionBody *const topFunctionBody,
if (JITManager::GetJITManager()->IsOOPJITEnabled() )
{
// ensure jit contexts have been set up
scriptContext->GetThreadContext()->EnsureJITThreadContext();
if (!scriptContext->GetRemoteScriptAddr())
{
scriptContext->InitializeRemoteScriptContext();
}

bool allowPrereserveAlloc = true;
#if !_M_X64_OR_ARM64
if (this->scriptContext->webWorkerId != Js::Constants::NonWebWorkerContextId)
{
allowPrereserveAlloc = false;
}
#endif
#ifndef _CONTROL_FLOW_GUARD
allowPrereserveAlloc = false;
#endif
scriptContext->GetThreadContext()->EnsureJITThreadContext(allowPrereserveAlloc);

// batch send all new property records
ThreadContext::PropertyList * pendingProps = scriptContext->GetThreadContext()->GetPendingJITProperties();
if (pendingProps->Count() > 0)
Expand Down
1 change: 1 addition & 0 deletions lib/Backend/ServerThreadContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ServerThreadContext::ServerThreadContext(ThreadContextDataIDL * data) :
#endif
m_jitCRTBaseAddress((intptr_t)GetModuleHandle(UCrtC99MathApis::LibraryName))
{
m_codeGenAlloc.canCreatePreReservedSegment = data->allowPrereserveAlloc != FALSE;
m_propertyMap = HeapNew(PropertyMap, &HeapAllocator::Instance, TotalNumberOfBuiltInProperties + 700);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/JITIDL/JITTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ typedef struct ProfileDataIDL
typedef struct ThreadContextDataIDL
{
boolean isThreadBound;
boolean allowPrereserveAlloc;

IDL_PAD1(0)
IDL_PAD2(1)
IDL_PAD4(2)
CHAKRA_PTR processHandle;
Expand Down
4 changes: 2 additions & 2 deletions lib/Runtime/Base/ThreadContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ ThreadContext::SetJITConnectionInfo(HANDLE processHandle, void* serverSecurityDe
}
}
void
ThreadContext::EnsureJITThreadContext()
ThreadContext::EnsureJITThreadContext(bool allowPrereserveAlloc)
{
Assert(JITManager::GetJITManager()->IsOOPJITEnabled());
Assert(JITManager::GetJITManager()->IsConnected());
Expand Down Expand Up @@ -1984,7 +1984,7 @@ ThreadContext::EnsureJITThreadContext()
contextData.debugScriptIdWhenSetAddr = (intptr_t)this->debugManager->stepController.GetAddressOfScriptIdWhenSet();
contextData.scriptStackLimit = GetScriptStackLimit();
contextData.isThreadBound = IsThreadBound();

contextData.allowPrereserveAlloc = allowPrereserveAlloc;
#if _M_IX86 || _M_AMD64
contextData.simdTempAreaBaseAddr = (intptr_t)GetSimdTempArea();
#endif
Expand Down
2 changes: 1 addition & 1 deletion lib/Runtime/Base/ThreadContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ class ThreadContext sealed :
}

static void SetJITConnectionInfo(HANDLE processHandle, void* serverSecurityDescriptor, UUID connectionId);
void EnsureJITThreadContext();
void EnsureJITThreadContext(bool allowPrereserveAlloc);

intptr_t GetRemoteThreadContextAddr() const
{
Expand Down

0 comments on commit 1e7d27e

Please sign in to comment.