Jelajahi Sumber

add oop jit support for arm; fix core build issues

Michael Holman 9 tahun lalu
induk
melakukan
8ce882abd6

+ 31 - 0
Build/Common.Build.props

@@ -1,6 +1,34 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemDefinitionGroup>
+    <Midl>
+      <StructMemberAlignment Condition="'%(Midl.StructMemberAlignment)' == ''">8</StructMemberAlignment>
+      <DefaultCharType>Unsigned</DefaultCharType>
+
+      <IdlType>Ole</IdlType>
+      <!-- Default Idl type -->
+
+      <!-- Force all MIDL compiles to be treated as English unless otherwise specified -->
+      <LocaleID>1033</LocaleID>
+
+      <!-- Disable the settings comment to make the headers more diff-able.  Only available in midl 8 -->
+      <AdditionalOptions>%(AdditionalOptions) /no_settings_comment</AdditionalOptions>
+
+      <!--Disable midl timestamps wherever possible-->
+      <AdditionalOptions>%(AdditionalOptions) /no_stamp</AdditionalOptions>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+
+      <!-- Other defaults -->
+      <HeaderFileName>%(Filename).h</HeaderFileName>
+      <OutputDirectory>$(IntDir)</OutputDirectory>
+
+      <!-- ======== makefiledef ======== -->
+      <AdditionalOptions>%(AdditionalOptions) -sal</AdditionalOptions>
+      
+      <!-- ======== sources.inc ======== -->
+      <!-- generates SAL annotations for our interface -->
+      <AdditionalOptions>%(AdditionalOptions) -sal_local</AdditionalOptions>
+    </Midl>
     <ClCompile>
       <PreprocessorDefinitions>%(PreprocessorDefinitions);_CHAKRACOREBUILD;NOMINMAX;USE_EDGEMODE_JSRT</PreprocessorDefinitions>
       <!-- Some of our STDMETHOD can throw
@@ -12,6 +40,9 @@
       <!-- Add any preprocessor definitions passed using msbuild environment -->
       <PreprocessorDefinitions Condition="'$(AdditionalPreprocessorDefinitions)'!=''">%(PreprocessorDefinitions);$(AdditionalPreprocessorDefinitions)</PreprocessorDefinitions>
       
+      <!-- MIDL generate code uses this define -->
+      <PreprocessorDefinitions Condition="'$(Platform)'=='ARM'">%(PreprocessorDefinitions);_ARM_</PreprocessorDefinitions>
+            
       <!-- /W4 -->
       <WarningLevel>Level4</WarningLevel>
       <!-- /WX -->

+ 0 - 27
lib/Backend/CodeGenWorkItem.h

@@ -22,8 +22,6 @@ protected:
     Js::FunctionBody *const functionBody;
     size_t codeAddress;
     ptrdiff_t codeSize;
-    ushort pdataCount;
-    ushort xdataSize;
 
 public:
     HRESULT codeGenResult;
@@ -75,12 +73,6 @@ public:
     void SetCodeSize(ptrdiff_t codeSize) { this->codeSize = codeSize; }
     ptrdiff_t GetCodeSize() { return codeSize; }
 
-    void SetPdataCount(ushort pdataCount) { this->pdataCount = pdataCount; }
-    ushort GetPdataCount() { return pdataCount; }
-
-    void SetXdataSize(ushort xdataSize) { this->xdataSize = xdataSize; }
-    ushort GetXdataSize() { return xdataSize; }
-
 protected:
     virtual uint GetLoopNumber() const
     {
@@ -123,11 +115,6 @@ public:
     }
 #endif
 private:
-
-    void SetAllocation(EmitBufferAllocation *allocation)
-    {
-        this->allocation = allocation;
-    }
     EmitBufferAllocation *GetAllocation() { return allocation; }
 
 public:
@@ -192,20 +179,6 @@ public:
         return jitData.isJitInDebugMode != 0;
     }
 
-#if _M_ARM
-    void RecordPdataEntry(int index, DWORD beginAddress, DWORD unwindData)
-    {
-        RUNTIME_FUNCTION *function = GetAllocation()->allocation->xdata.GetPdataArray() + index;
-        function->BeginAddress = beginAddress;
-        function->UnwindData = unwindData;
-    }
-
-    void FinalizePdata()
-    {
-        GetAllocation()->allocation->RegisterPdata((ULONG_PTR)GetCodeAddress(), GetCodeSize());
-    }
-#endif
-
     void OnWorkItemProcessFail(NativeCodeGenerator *codeGen);
 
     void RecordNativeThrowMap(Js::SmallSpanSequenceIter& iter, uint32 nativeOffset, uint32 statementIndex)

+ 2 - 3
lib/Backend/Encoder.cpp

@@ -324,8 +324,8 @@ Encoder::Encode()
         alloc->allocation->xdata.address,
         m_func->GetThreadContextInfo()->GetProcessHandle());
 #elif _M_ARM
-    m_func->m_unwindInfo.EmitUnwindInfo(workItem);
-    workItem->SetCodeAddress(workItem->GetCodeAddress() | 0x1); // Set thumb mode
+    m_func->m_unwindInfo.EmitUnwindInfo(m_func->GetJITOutput(), alloc);
+    m_func->GetJITOutput()->SetCodeAddress(m_func->GetJITOutput()->GetCodeAddress() | 0x1); // Set thumb mode
 #endif
 
     const bool isSimpleJit = m_func->IsSimpleJit();
@@ -333,7 +333,6 @@ Encoder::Encode()
     if (this->m_inlineeFrameMap->Count() > 0 &&
         !(this->m_inlineeFrameMap->Count() == 1 && this->m_inlineeFrameMap->Item(0).record == nullptr))
     {
-        // TODO: OOP JIT, inlinee frame map
         if (!m_func->IsOOPJIT()) // in-proc JIT
         {
             m_func->GetInProcJITEntryPointInfo()->RecordInlineeFrameMap(m_inlineeFrameMap);

+ 31 - 1
lib/Backend/JITOutput.cpp

@@ -67,12 +67,42 @@ JITOutput::GetCodeAddress() const
     return (intptr_t)m_outputData->codeAddress;
 }
 
+void
+JITOutput::SetCodeAddress(intptr_t addr)
+{
+    m_outputData->codeAddress = addr;
+}
+
+size_t
+JITOutput::GetCodeSize() const
+{
+    return (size_t)m_outputData->codeSize;
+}
+
+ushort
+JITOutput::GetPdataCount() const
+{
+    return m_outputData->pdataCount;
+}
+
+ushort
+JITOutput::GetXdataSize() const
+{
+    return m_outputData->xdataSize;
+}
+
 EmitBufferAllocation *
 JITOutput::RecordNativeCodeSize(Func *func, uint32 bytes, ushort pdataCount, ushort xdataSize)
 {
     BYTE *buffer;
 
-    EmitBufferAllocation *allocation = func->GetEmitBufferManager()->AllocateBuffer(bytes, &buffer, pdataCount, xdataSize, true, true);
+#if defined(_M_ARM32_OR_ARM64)
+    bool canAllocInPreReservedHeapPageSegment = false;
+#else
+    bool canAllocInPreReservedHeapPageSegment = func->CanAllocInPreReservedHeapPageSegment();
+#endif
+
+    EmitBufferAllocation *allocation = func->GetEmitBufferManager()->AllocateBuffer(bytes, &buffer, pdataCount, xdataSize, canAllocInPreReservedHeapPageSegment, true);
 
 #if DBG
     MEMORY_BASIC_INFORMATION memBasicInfo;

+ 5 - 0
lib/Backend/JITOutput.h

@@ -21,6 +21,11 @@ public:
 
     uint16 GetArgUsedForBranch() const;
     intptr_t GetCodeAddress() const;
+    size_t GetCodeSize() const;
+    ushort GetPdataCount() const;
+    ushort GetXdataSize() const;
+
+    void SetCodeAddress(intptr_t addr);
 
     EmitBufferAllocation * RecordNativeCodeSize(Func *func, uint32 bytes, ushort pdataCount, ushort xdataSize);
     void RecordNativeCode(Func *func, const BYTE* sourceBuffer, EmitBufferAllocation * alloc);

+ 8 - 12
lib/Backend/LowerMDShared.cpp

@@ -7079,11 +7079,6 @@ LowererMD::LoadFloatValue(IR::Opnd * opndDst, double value, IR::Instr * instrIns
     {
         opnd = IR::MemRefOpnd::New((void*)pValue, isFloat64 ? TyMachDouble : TyFloat32,
             instrInsert->m_func, isFloat64 ? IR::AddrOpndKindDynamicDoubleRef : IR::AddrOpndKindDynamicFloatRef);
-
-        IR::Instr * instr = IR::Instr::New(LowererMDArch::GetAssignOp(opndDst->GetType()), opndDst, opnd, instrInsert->m_func);
-        instrInsert->InsertBefore(instr);
-        Legalize(instr);
-        return instr;
     }
     else // OOP JIT
     {
@@ -7092,7 +7087,7 @@ LowererMD::LoadFloatValue(IR::Opnd * opndDst, double value, IR::Instr * instrIns
 
         Lowerer::InsertMove(
             addressRegOpnd,
-            IR::MemRefOpnd::New((void*)instrInsert->m_func->GetWorkItem()->GetWorkItemData()->nativeDataAddr, TyMachPtr, instrInsert->m_func, IR::AddrOpndKindDynamicNativeCodeDataRef),
+            IR::MemRefOpnd::New(instrInsert->m_func->GetWorkItem()->GetWorkItemData()->nativeDataAddr, TyMachPtr, instrInsert->m_func, IR::AddrOpndKindDynamicNativeCodeDataRef),
             instrInsert);
 
         opnd = IR::IndirOpnd::New(addressRegOpnd, offset, isFloat64 ? TyMachDouble : TyFloat32,
@@ -7100,14 +7095,15 @@ LowererMD::LoadFloatValue(IR::Opnd * opndDst, double value, IR::Instr * instrIns
             NativeCodeData::GetDataDescription(pValue, instrInsert->m_func->m_alloc),
 #endif
             instrInsert->m_func);
-
-        // movsd xmm, [reg+offset]
-        auto instr = IR::Instr::New(LowererMDArch::GetAssignOp(opndDst->GetType()), opndDst, opnd, instrInsert->m_func);
-        instrInsert->InsertBefore(instr);
-        Legalize(instr);
-        return instr;
     }
 
+    // movsd xmm, [reg+offset]
+    IR::Instr * instr = IR::Instr::New(LowererMDArch::GetAssignOp(opndDst->GetType()), opndDst, opnd, instrInsert->m_func);
+
+    instrInsert->InsertBefore(instr);
+    Legalize(instr);
+    return instr;
+
 }
 
 IR::Instr *

+ 7 - 1
lib/Backend/NativeCodeGenerator.cpp

@@ -1048,7 +1048,13 @@ NativeCodeGenerator::CodeGen(PageAllocator * pageAllocator, CodeGenWorkItem* wor
     }
 
 #if defined(_M_X64) || defined(_M_ARM32_OR_ARM64)
-    XDataInfo * xdataInfo = XDataAllocator::Register(jitWriteData.xdataAddr, jitWriteData.codeAddress, jitWriteData.codeSize);
+    XDataAllocation * xdataInfo = HeapNew(XDataAllocation);
+    xdataInfo->address = (byte*)jitWriteData.xdataAddr;
+#if defined(_M_ARM32_OR_ARM64)
+    xdataInfo->pdataCount = jitWriteData.pdataCount;
+    xdataInfo->xdataSize = jitWriteData.xdataSize;
+#endif
+    XDataAllocator::Register(xdataInfo, jitWriteData.codeAddress, jitWriteData.codeSize);
     epInfo->SetXDataInfo(xdataInfo);
 #endif
     scriptContext->GetThreadContext()->SetValidCallTargetForCFG((PVOID)jitWriteData.codeAddress);

+ 8 - 1
lib/Backend/ServerThreadContext.cpp

@@ -12,7 +12,12 @@ ServerThreadContext::ServerThreadContext(ThreadContextDataIDL * data) :
     m_preReservedVirtualAllocator((HANDLE)data->processHandle),
     m_codePageAllocators(&m_policyManager, ALLOC_XDATA, &m_preReservedVirtualAllocator, (HANDLE)data->processHandle),
     m_codeGenAlloc(&m_policyManager, nullptr, &m_codePageAllocators, (HANDLE)data->processHandle),
-    m_jitChakraBaseAddress((intptr_t)GetModuleHandle(L"Chakra.dll")), // TODO: OOP JIT, don't hardcode name
+    // TODO: OOP JIT, don't hardcode name
+#ifdef NTBUILD
+    m_jitChakraBaseAddress((intptr_t)GetModuleHandle(L"Chakra.dll")),
+#else
+    m_jitChakraBaseAddress((intptr_t)GetModuleHandle(L"ChakraCore.dll")),
+#endif
     m_jitCRTBaseAddress((intptr_t)GetModuleHandle(UCrtC99MathApis::LibraryName))
 {
     m_propertyMap = HeapNew(PropertyMap, &HeapAllocator::Instance, TotalNumberOfBuiltInProperties + 700);
@@ -117,12 +122,14 @@ ServerThreadContext::GetImplicitCallFlagsAddr() const
     return static_cast<intptr_t>(m_threadContextData.implicitCallFlagsAddr);
 }
 
+#if defined(_M_IX86) || defined(_M_X64)
 intptr_t
 ServerThreadContext::GetSimdTempAreaAddr(uint8 tempIndex) const
 {
     Assert(tempIndex < SIMD_TEMP_SIZE);
     return m_threadContextData.simdTempAreaBaseAddr + tempIndex * sizeof(_x86_SIMDValue);
 }
+#endif
 
 intptr_t
 ServerThreadContext::GetThreadStackLimitAddr() const

+ 2 - 0
lib/Backend/ServerThreadContext.h

@@ -19,7 +19,9 @@ public:
 
     virtual intptr_t GetThreadStackLimitAddr() const override;
 
+#if defined(_M_IX86) || defined(_M_X64)
     virtual intptr_t GetSimdTempAreaAddr(uint8 tempIndex) const override;
+#endif
 
     virtual intptr_t GetDisableImplicitFlagsAddr() const override;
     virtual intptr_t GetImplicitCallFlagsAddr() const override;

+ 2 - 2
lib/Backend/arm/LegalizeMD.cpp

@@ -73,7 +73,7 @@ void LegalizeMD::LegalizeDst(IR::Instr * instr, bool fPostRegAlloc)
         // MemRefOpnd is a deference of the memory location.
         // So extract the location, load it to register, replace the MemRefOpnd with an IndirOpnd taking the
         // register as base, and fall through to legalize the IndirOpnd.
-        void *memLoc = opnd->AsMemRefOpnd()->GetMemLoc();
+        intptr_t memLoc = opnd->AsMemRefOpnd()->GetMemLoc();
         IR::RegOpnd *newReg = IR::RegOpnd::New(TyMachPtr, instr->m_func);
         if (fPostRegAlloc)
         {
@@ -180,7 +180,7 @@ void LegalizeMD::LegalizeSrc(IR::Instr * instr, IR::Opnd * opnd, uint opndNum, b
         // MemRefOpnd is a deference of the memory location.
         // So extract the location, load it to register, replace the MemRefOpnd with an IndirOpnd taking the
         // register as base, and fall through to legalize the IndirOpnd.
-        void *memLoc = opnd->AsMemRefOpnd()->GetMemLoc();
+        intptr_t memLoc = opnd->AsMemRefOpnd()->GetMemLoc();
         IR::RegOpnd *newReg = IR::RegOpnd::New(TyMachPtr, instr->m_func);
         if (fPostRegAlloc)
         {

+ 1 - 1
lib/Backend/arm/LinearScanMD.cpp

@@ -218,7 +218,7 @@ LinearScanMD::GenerateBailOut(
     Func *const func = instr->m_func;
     BailOutInfo *const bailOutInfo = instr->GetBailOutInfo();
     IR::Instr *firstInstr = instr->m_prev;
-    Js::Var *const registerSaveSpace = (Js::Var*)func->GetThreadContextInfo()->GetBailOutRegisterSaveSpace();
+    Js::Var *const registerSaveSpace = (Js::Var*)func->GetThreadContextInfo()->GetBailOutRegisterSaveSpaceAddr();
 
     const auto LoadRegSaveSpaceIntoScratch = [&](const RegNum reg)
     {

+ 30 - 10
lib/Backend/arm/LowerMD.cpp

@@ -2426,7 +2426,7 @@ LowererMD::ChangeToHelperCall(IR::Instr * callInstr, IR::JnHelperMethod helperMe
     if (helperCallOpnd->IsDiagHelperCallOpnd())
     {
         // Load arguments for the wrapper.
-        this->LoadHelperArgument(callInstr, IR::AddrOpnd::New((Js::Var)IR::GetMethodOriginalAddress(helperMethod), IR::AddrOpndKindDynamicMisc, m_func));
+        this->LoadHelperArgument(callInstr, IR::AddrOpnd::New((Js::Var)IR::GetMethodOriginalAddress(m_func->GetThreadContextInfo(), helperMethod), IR::AddrOpndKindDynamicMisc, m_func));
         this->m_lowerer->LoadScriptContext(callInstr);
     }
     callInstr->SetSrc1(helperCallOpnd);
@@ -5099,7 +5099,7 @@ LowererMD::GenerateFastLdMethodFromFlags(IR::Instr * instrLdFld)
     IR::RegOpnd *      opndBase;
     IR::RegOpnd *      opndType;
     IR::RegOpnd *      opndInlineCache;
-    Js::InlineCache *  inlineCache;
+    intptr_t           inlineCache;
 
     opndSrc = instrLdFld->GetSrc1();
 
@@ -5129,7 +5129,7 @@ LowererMD::GenerateFastLdMethodFromFlags(IR::Instr * instrLdFld)
     opndDst = instrLdFld->GetDst();
 
     inlineCache = propertySymOpnd->m_runtimeInlineCache;
-    Assert(inlineCache != nullptr);
+    Assert(inlineCache != 0);
 
     opndInlineCache = IR::RegOpnd::New(TyMachReg, this->m_func);
 
@@ -6860,7 +6860,7 @@ bool LowererMD::GenerateFastCharAt(Js::BuiltinFunction index, IR::Opnd *dst, IR:
     }
 
     // Bail out if index a constant and is less than zero.
-    if (srcIndex->IsImmediateOpnd() && srcIndex->GetImmediateValue(instr->m_func) < 0)
+    if (srcIndex->IsImmediateOpnd() && srcIndex->GetImmediateValue(this->m_func) < 0)
     {
         instr = IR::BranchInstr::New(Js::OpCode::B, labelHelper, this->m_func);
         insertInstr->InsertBefore(instr);
@@ -6954,15 +6954,15 @@ bool LowererMD::GenerateFastCharAt(Js::BuiltinFunction index, IR::Opnd *dst, IR:
     IR::RegOpnd *charResult = IR::RegOpnd::New(TyUint32, this->m_func);
     LowererMD::CreateAssign(charResult, indirOpnd, insertInstr);
 
-    if (index == Js::BuiltinFunction::String_CharAt)
+    if (index == Js::BuiltinFunction::JavascriptString_CharAt)
     {
         this->m_lowerer->GenerateGetSingleCharString(charResult, dst, labelHelper, labelDone, insertInstr, false);
     }
     else
     {
-        Assert(index == Js::BuiltinFunction::String_CharCodeAt || index == Js::BuiltinFunction::String_CodePointAt);
+        Assert(index == Js::BuiltinFunction::JavascriptString_CharCodeAt || index == Js::BuiltinFunction::JavascriptString_CodePointAt);
 
-        if (index == Js::BuiltinFunction::String_CodePointAt)
+        if (index == Js::BuiltinFunction::JavascriptString_CodePointAt)
         {
             this->m_lowerer->GenerateFastInlineStringCodePointAt(insertInstr, this->m_func, length, srcIndex, charResult, psz);
         }
@@ -8352,7 +8352,7 @@ void LowererMD::GenerateFastInlineBuiltInCall(IR::Instr* instr, IR::JnHelperMeth
 
         // lr = MOV helperAddr
         //      BLX lr
-        IR::AddrOpnd* targetAddr = IR::AddrOpnd::New((Js::Var)IR::GetMethodOriginalAddress(helperMethod), IR::AddrOpndKind::AddrOpndKindDynamicMisc, this->m_func);
+        IR::AddrOpnd* targetAddr = IR::AddrOpnd::New((Js::Var)IR::GetMethodOriginalAddress(m_func->GetThreadContextInfo(), helperMethod), IR::AddrOpndKind::AddrOpndKindDynamicMisc, this->m_func);
         IR::RegOpnd *targetOpnd = IR::RegOpnd::New(nullptr, RegLR, TyMachPtr, this->m_func);
         IR::Instr   *movInstr   = IR::Instr::New(Js::OpCode::LDIMM, targetOpnd, targetAddr, this->m_func);
         targetOpnd->m_isCallArg = true;
@@ -9083,8 +9083,28 @@ LowererMD::LoadFloatValue(IR::Opnd * opndDst, double value, IR::Instr * instrIns
     {
         return LowererMD::LoadFloatZero(opndDst, instrInsert);
     }
-    double *pValue = NativeCodeDataNew(instrInsert->m_func->GetNativeCodeDataAllocator(), double, value);
-    IR::Opnd * opnd = IR::MemRefOpnd::New((void*)pValue, TyMachDouble, instrInsert->m_func);
+    void * pValue = NativeCodeDataNewNoFixup(instrInsert->m_func->GetNativeCodeDataAllocator(), DoubleType<DataDesc_LowererMD_LoadFloatValue_Double>, value);
+    IR::Opnd * opnd;
+    if (instrInsert->m_func->IsOOPJIT())
+    {
+        int offset = NativeCodeData::GetDataTotalOffset(pValue);
+        auto addressRegOpnd = IR::RegOpnd::New(TyMachPtr, instrInsert->m_func);
+
+        Lowerer::InsertMove(
+            addressRegOpnd,
+            IR::MemRefOpnd::New(instrInsert->m_func->GetWorkItem()->GetWorkItemData()->nativeDataAddr, TyMachPtr, instrInsert->m_func, IR::AddrOpndKindDynamicNativeCodeDataRef),
+            instrInsert);
+
+        opnd = IR::IndirOpnd::New(addressRegOpnd, offset, TyMachDouble,
+#if DBG
+            NativeCodeData::GetDataDescription(pValue, instrInsert->m_func->m_alloc),
+#endif
+            instrInsert->m_func);
+    }
+    else
+    {
+        opnd = IR::MemRefOpnd::New((void*)pValue, TyMachDouble, instrInsert->m_func);
+    }
     IR::Instr * instr = IR::Instr::New(Js::OpCode::VLDR, opndDst, opnd, instrInsert->m_func);
     instrInsert->InsertBefore(instr);
     LegalizeMD::LegalizeInstr(instr,false);

+ 1 - 1
lib/Backend/arm/LowerMD.h

@@ -203,7 +203,7 @@ public:
             void                EmitLoadFloatFromNumber(IR::Opnd *dst, IR::Opnd *src, IR::Instr *insertInstr);
             IR::LabelInstr*     EmitLoadFloatCommon(IR::Opnd *dst, IR::Opnd *src, IR::Instr *insertInstr, bool needHelperLabel);
             static IR::Instr *  LoadFloatZero(IR::Opnd * opndDst, IR::Instr * instrInsert);
-            IR::Instr *  LoadFloatValue(IR::Opnd * opndDst, double value, IR::Instr * instrInsert);
+            static IR::Instr *  LoadFloatValue(IR::Opnd * opndDst, double value, IR::Instr * instrInsert);
 
             IR::Instr *         LowerEntryInstr(IR::EntryInstr * entryInstr);
             IR::Instr *         LowerExitInstr(IR::ExitInstr * exitInstr);

+ 24 - 18
lib/Backend/arm/UnwindInfoManager.cpp

@@ -60,6 +60,7 @@ DWORD UnwindInfoManager::RelativeRegEncoding(RegNum reg, RegNum baseReg) const
 void UnwindInfoManager::Init(Func * func)
 {
     this->SetFunc(func);
+    this->processHandle = func->GetThreadContextInfo()->GetProcessHandle();
 }
 
 DWORD UnwindInfoManager::GetPDataCount(DWORD length)
@@ -95,15 +96,17 @@ DWORD UnwindInfoManager::GetPDataCount(DWORD length)
     return count;
 }
 
-void UnwindInfoManager::EmitUnwindInfo(CodeGenWorkItem *workItem)
+void UnwindInfoManager::EmitUnwindInfo(JITOutput *jitOutput, EmitBufferAllocation * alloc)
 {
-    this->workItem = workItem;
+    this->jitOutput = jitOutput;
+    this->alloc = alloc;
+    this->processHandle = processHandle;
 
     // First handle the main function, which we may have to emit in multiple
     // fragments depending on its length.
     DWORD remainingLength = this->GetEpilogEndOffset();
     this->fragmentHasProlog = true;
-    this->fragmentStart = workItem->GetCodeAddress();
+    this->fragmentStart = jitOutput->GetCodeAddress();
 
     this->pdataIndex = 0;
     this->xdataTotal = 0;
@@ -115,15 +118,15 @@ void UnwindInfoManager::EmitUnwindInfo(CodeGenWorkItem *workItem)
     this->fragmentHasEpilog = true;
     this->EmitPdata();
 
-    Assert(workItem->GetCodeSize() >= (ptrdiff_t)this->GetEpilogEndOffset());
+    Assert(jitOutput->GetCodeSize() >= (ptrdiff_t)this->GetEpilogEndOffset());
 
-    if (workItem->GetCodeSize() > (ptrdiff_t)this->GetEpilogEndOffset())
+    if (jitOutput->GetCodeSize() > (ptrdiff_t)this->GetEpilogEndOffset())
     {
         // Set the start/end pointers to indicate the boundaries of the fragment.
         // Almost identical to the code above, except that all chunks have neither prolog nor epilog.
-        this->fragmentStart = workItem->GetCodeAddress() + this->GetEpilogEndOffset();
+        this->fragmentStart = jitOutput->GetCodeAddress() + this->GetEpilogEndOffset();
         this->fragmentHasProlog = false;
-        remainingLength = workItem->GetCodeSize() - this->GetEpilogEndOffset();
+        remainingLength = jitOutput->GetCodeSize() - this->GetEpilogEndOffset();
 
         while (remainingLength > MaxXdataFuncLength)
         {
@@ -133,9 +136,8 @@ void UnwindInfoManager::EmitUnwindInfo(CodeGenWorkItem *workItem)
         this->fragmentHasEpilog = false;
         this->EmitPdata();
     }
-    AssertMsg(this->pdataIndex == workItem->GetPdataCount(), "The length of pdata array is not in sync with the usage");
-    AssertMsg(this->xdataTotal <= workItem->GetXdataSize(), "We under-allocated the size of the xdata");
-    this->workItem->FinalizePdata();
+    AssertMsg(this->pdataIndex == jitOutput->GetPdataCount(), "The length of pdata array is not in sync with the usage");
+    AssertMsg(this->xdataTotal <= jitOutput->GetXdataSize(), "We under-allocated the size of the xdata");
 }
 
 DWORD UnwindInfoManager::EmitLongUnwindInfoChunk(DWORD remainingLength)
@@ -287,7 +289,7 @@ void UnwindInfoManager::EncodePackedUnwindData()
     Assert((depth & ~PackedStackDepthMask) == 0);
     dwFlags |= depth << PackedStackDepthShift;
 
-    this->workItem->RecordPdataEntry(this->pdataIndex, ((DWORD)this->GetFragmentStart()) | 1, dwFlags);
+    RecordPdataEntry(((DWORD)this->GetFragmentStart()) | 1, dwFlags);
 }
 
 void UnwindInfoManager::EncodeExpandedUnwindData()
@@ -491,9 +493,9 @@ void UnwindInfoManager::EncodeExpandedUnwindData()
 
     size_t totalSize = (xDataDwordCount * 4);
 
-    size_t xdataFinal = this->workItem->RecordUnwindInfo(this->xdataTotal, xData, totalSize);
+    size_t xdataFinal = this->jitOutput->RecordUnwindInfo(this->xdataTotal, xData, totalSize, this->alloc->allocation->xdata.address, this->processHandle);
     this->xdataTotal += totalSize;
-    this->workItem->RecordPdataEntry(this->pdataIndex, (DWORD)(this->GetFragmentStart() + this->GetPrologOffset()) | 1, (DWORD)xdataFinal);
+    RecordPdataEntry((DWORD)(this->GetFragmentStart() + this->GetPrologOffset()) | 1, (DWORD)xdataFinal);
 }
 
 DWORD UnwindInfoManager::EmitXdataStackAlloc(BYTE xData[], DWORD byte, DWORD stack)
@@ -535,6 +537,15 @@ DWORD UnwindInfoManager::EmitXdataStackAlloc(BYTE xData[], DWORD byte, DWORD sta
     return this->WriteXdataBytes(xData, byte, encoding, this->XdataLength(op));
 }
 
+void UnwindInfoManager::RecordPdataEntry(DWORD beginAddress, DWORD unwindData)
+{
+    RUNTIME_FUNCTION *function = this->alloc->allocation->xdata.GetPdataArray() + this->pdataIndex;
+    RUNTIME_FUNCTION localFunc;
+    localFunc.BeginAddress = beginAddress;
+    localFunc.UnwindData = unwindData;
+    ChakraMemCopy(function, sizeof(RUNTIME_FUNCTION), &localFunc, sizeof(RUNTIME_FUNCTION), this->processHandle);
+}
+
 DWORD UnwindInfoManager::EmitXdataHomeParams(BYTE xData[], DWORD byte)
 {
     Assert(this->homedParamCount >= MIN_HOMED_PARAM_REGS &&
@@ -774,11 +785,6 @@ bool UnwindInfoManager::IsR4SavedRegRange(DWORD savedRegMask)
     return ((savedRegMask + (1 << RegEncode[RegR4])) & savedRegMask) == 0;
 }
 
-bool UnwindInfoManager::IsPdataPacked(const DWORD *pdata) const
-{
-    return (pdata[1] & PackedPdataFlagMask) != ExpandedPdataFlag;
-}
-
 bool UnwindInfoManager::GetHasChkStk() const
 {
     return (!LowererMD::IsSmallStack(this->stackDepth));

+ 7 - 5
lib/Backend/arm/UnwindInfoManager.h

@@ -22,7 +22,8 @@ public:
         hasCalls(false),
         prologLabelId(0),
         epilogEndLabelId(0),
-        workItem(nullptr),
+        jitOutput(nullptr),
+        alloc(nullptr),
         xdataTotal(0),
         pdataIndex(0),
         savedScratchReg(false)
@@ -30,7 +31,7 @@ public:
     }
 
     void Init(Func * func);
-    void EmitUnwindInfo(CodeGenWorkItem *workItem);
+    void EmitUnwindInfo(JITOutput *jitOutput, EmitBufferAllocation * alloc);
     DWORD EmitLongUnwindInfoChunk(DWORD remainingLength);
 
     void SetFunc(Func *func)
@@ -150,7 +151,9 @@ private:
     size_t fragmentStart;
     int pdataIndex;
     int xdataTotal;
-    CodeGenWorkItem *workItem;
+    HANDLE processHandle;
+    JITOutput *jitOutput;
+    EmitBufferAllocation * alloc;
     DWORD fragmentLength;
     DWORD prologOffset;
     DWORD prologLabelId;
@@ -171,7 +174,6 @@ private:
     void EncodeExpandedUnwindData();
     BYTE * GetBaseAddress();
 
-    bool IsPdataPacked(const DWORD *pdata) const;
     bool IsR4SavedRegRange(bool saveR11) const;
     static bool IsR4SavedRegRange(DWORD saveRegMask);
 
@@ -188,10 +190,10 @@ private:
     DWORD EmitXdataEnd(BYTE xData[], DWORD byte);
     DWORD EmitXdataEndPlus16(BYTE xData[], DWORD byte);
     DWORD EmitXdataLocalsPointer(BYTE xData[], DWORD byte, BYTE regEncode);
-
     DWORD RelativeRegEncoding(RegNum reg, RegNum baseReg) const;
     DWORD WriteXdataBytes(BYTE xdata[], DWORD byte, DWORD encoding, DWORD length);
 
+    void RecordPdataEntry(DWORD beginAddress, DWORD unwindData);
     // Constants defined in the ABI.
 
     static const DWORD MaxPackedPdataFuncLength = 0xFFE;

+ 0 - 1
lib/Backend/arm64/UnwindInfoManager.h

@@ -164,7 +164,6 @@ private:
     void EncodeExpandedUnwindData();
     BYTE * GetBaseAddress();
 
-    bool IsPdataPacked(const DWORD *pdata) const;
     bool IsR4SavedRegRange(bool saveR11) const;
     static bool IsR4SavedRegRange(DWORD saveRegMask);
 

+ 0 - 8
lib/Common/Memory/CustomHeap.h

@@ -117,14 +117,6 @@ struct Allocation
         return allocator;
     }
 
-#if defined(_M_ARM32_OR_ARM64)
-    void RegisterPdata(ULONG_PTR functionStart, DWORD length)
-    {
-        Assert(this->xdata.pdataCount > 0);
-        XDataAllocator* xdataAllocator = GetXDataAllocator();
-        xdataAllocator->Register(this->xdata, functionStart, length);
-    }
-#endif
 #endif
 
 };

+ 8 - 1
lib/Common/Memory/PageAllocator.h

@@ -82,12 +82,19 @@ struct SecondaryAllocation
     }
 };
 
-#if defined(_M_X64) || defined(_M_ARM32_OR_ARM64)
+#if defined(_M_X64)
 struct XDataInfo
 {
     RUNTIME_FUNCTION pdata;
     FunctionTableHandle functionTable;
 };
+#elif defined(_M_ARM32_OR_ARM64)
+struct XDataInfo
+{
+    ushort pdataCount;
+    ushort xdataSize;
+    FunctionTableHandle functionTable;
+};
 #endif
 
 //

+ 3 - 15
lib/Common/Memory/amd64/XDataAllocator.cpp

@@ -95,15 +95,6 @@ bool XDataAllocator::CanAllocate()
     return ((End() - current) >= XDATA_SIZE) || this->freeList;
 }
 
-void XDataAllocator::ReleaseAll()
-{
-#ifdef RECYCLER_MEMORY_VERIFY
-    ChakraMemSet(this->start, Recycler::VerifyMemFill, this->size, this->processHandle);
-#endif
-    this->current = this->start;
-    ClearFreeList();
-}
-
 void XDataAllocator::ClearFreeList()
 {
     XDataAllocationEntry* next = this->freeList;
@@ -118,14 +109,12 @@ void XDataAllocator::ClearFreeList()
 }
 
 /* static */
-XDataInfo * XDataAllocator::Register(ULONG_PTR xdataAddr, ULONG_PTR functionStart, DWORD functionSize)
+void XDataAllocator::Register(XDataAllocation * xdataInfo, ULONG_PTR functionStart, DWORD functionSize)
 {
-    XDataInfo * xdataInfo = HeapNewStructZ(XDataInfo);
-
     ULONG_PTR baseAddress = functionStart;
     xdataInfo->pdata.BeginAddress = (DWORD)(functionStart - baseAddress);
     xdataInfo->pdata.EndAddress = (DWORD)(xdataInfo->pdata.BeginAddress + functionSize);
-    xdataInfo->pdata.UnwindInfoAddress = (DWORD)(xdataAddr - baseAddress);
+    xdataInfo->pdata.UnwindInfoAddress = (DWORD)((intptr_t)xdataInfo->address - baseAddress);
 
     BOOLEAN success = FALSE;
     if (AutoSystemInfo::Data.IsWin8OrLater())
@@ -154,11 +143,10 @@ XDataInfo * XDataAllocator::Register(ULONG_PTR xdataAddr, ULONG_PTR functionStar
     RUNTIME_FUNCTION  *runtimeFunction = RtlLookupFunctionEntry((DWORD64)functionStart, &imageBase, nullptr);
     Assert(runtimeFunction != NULL);
 #endif
-    return xdataInfo;
 }
 
 /* static */
-void XDataAllocator::Unregister(XDataInfo* xdataInfo)
+void XDataAllocator::Unregister(XDataAllocation * xdataInfo)
 {
     // Delete the table
     if (AutoSystemInfo::Data.IsWin8OrLater())

+ 4 - 3
lib/Common/Memory/amd64/XDataAllocator.h

@@ -24,6 +24,8 @@ struct XDataAllocation : public SecondaryAllocation
     {
         address = nullptr;
     }
+    RUNTIME_FUNCTION pdata;
+    FunctionTableHandle functionTable;
 };
 
 //
@@ -65,11 +67,10 @@ public:
     void Delete();
     bool Alloc(ULONG_PTR functionStart, DWORD functionSize, ushort pdataCount, ushort xdataSize, SecondaryAllocation* allocation);
     void Release(const SecondaryAllocation& address);
-    void ReleaseAll();
     bool CanAllocate();
 
-    static XDataInfo * XDataAllocator::Register(ULONG_PTR xdataAddr, ULONG_PTR functionStart, DWORD functionSize);
-    static void Unregister(XDataInfo* xdataInfo);
+    static void XDataAllocator::Register(XDataAllocation * xdataInfo, ULONG_PTR functionStart, DWORD functionSize);
+    static void Unregister(XDataAllocation * xdataInfo);
 
 // -------- Private helpers ---------/
 private:

+ 24 - 19
lib/Common/Memory/arm/XDataAllocator.cpp

@@ -11,7 +11,8 @@ CompileAssert(false)
 #include "XDataAllocator.h"
 #include "Core/DelayLoadLibrary.h"
 
-XDataAllocator::XDataAllocator(BYTE* address, uint size)
+XDataAllocator::XDataAllocator(BYTE* address, uint size, HANDLE processHandle) :
+    processHandle(processHandle)
 {
     Assert(size == 0);
 }
@@ -47,45 +48,49 @@ bool XDataAllocator::Alloc(ULONG_PTR functionStart, DWORD functionSize, ushort p
     return false; //fail;
 }
 
-void XDataAllocator::Register(XDataAllocation& allocation, DWORD functionStart, DWORD functionSize)
+
+void XDataAllocator::Release(const SecondaryAllocation& allocation)
+{
+    const XDataAllocation& xdata = static_cast<const XDataAllocation&>(allocation);
+    if(xdata.address  != nullptr)
+    {
+        HeapDeleteArray(GetAllocSize(xdata.pdataCount, xdata.xdataSize), xdata.address);
+    }
+}
+
+/* static */
+void XDataAllocator::Register(XDataAllocation * xdataInfo, DWORD functionStart, DWORD functionSize)
 {
-    RUNTIME_FUNCTION* pdataArray = allocation.GetPdataArray();
-    for(ushort i = 0; i < allocation.pdataCount; i++)
+    RUNTIME_FUNCTION* pdataArray = xdataInfo->GetPdataArray();
+    for (ushort i = 0; i < xdataInfo->pdataCount; i++)
     {
         RUNTIME_FUNCTION* pdata = pdataArray + i;
         Assert(pdata->UnwindData != 0);
         Assert(pdata->BeginAddress != 0);
         pdata->BeginAddress = pdata->BeginAddress - (DWORD)functionStart;
-        if(pdata->Flag != 1) // if it is not packed unwind data
+        if (pdata->Flag != 1) // if it is not packed unwind data
         {
             pdata->UnwindData = pdata->UnwindData - (DWORD)functionStart;
         }
     }
-    Assert(allocation.functionTable == nullptr);
+    Assert(xdataInfo->functionTable == nullptr);
 
     // Since we do not expect many thunk functions to be created, we are using 1 table/function
     // for now. This can be optimized further if needed.
-    DWORD status = NtdllLibrary::Instance->AddGrowableFunctionTable(&allocation.functionTable,
+    DWORD status = NtdllLibrary::Instance->AddGrowableFunctionTable(&xdataInfo->functionTable,
         pdataArray,
-        /*MaxEntryCount*/ allocation.pdataCount,
-        /*Valid entry count*/ allocation.pdataCount,
+        /*MaxEntryCount*/ xdataInfo->pdataCount,
+        /*Valid entry count*/ xdataInfo->pdataCount,
         /*RangeBase*/ functionStart,
         /*RangeEnd*/ functionStart + functionSize);
 
     Js::Throw::CheckAndThrowOutOfMemory(NT_SUCCESS(status));
 }
 
-void XDataAllocator::Release(const SecondaryAllocation& allocation)
+/* static */
+void XDataAllocator::Unregister(XDataAllocation * xdataInfo)
 {
-    const XDataAllocation& xdata = static_cast<const XDataAllocation&>(allocation);
-    if(xdata.address  != nullptr)
-    {
-        if(xdata.functionTable)
-        {
-            NtdllLibrary::Instance->DeleteGrowableFunctionTable(xdata.functionTable);
-        }
-        HeapDeleteArray(GetAllocSize(xdata.pdataCount, xdata.xdataSize), xdata.address);
-    }
+    NtdllLibrary::Instance->DeleteGrowableFunctionTable(xdataInfo->functionTable);
 }
 
 bool XDataAllocator::CanAllocate()

+ 5 - 4
lib/Common/Memory/arm/XDataAllocator.h

@@ -47,21 +47,22 @@ class XDataAllocator sealed : public SecondaryAllocator
 {
 // -------- Private members ---------/
 private:
-    ushort pdataCount;
-    FunctionTableHandle* functionTableHandles;
+    HANDLE processHandle;
 
 // --------- Public functions ---------/
 public:
-    XDataAllocator(BYTE* address, uint size);
+    XDataAllocator(BYTE* address, uint size, HANDLE processHandle);
 
     bool Initialize(void* segmentStart, void* segmentEnd);
     void Delete();
     bool Alloc(ULONG_PTR functionStart, DWORD functionSize, ushort pdataCount, ushort xdataSize, SecondaryAllocation* allocation);
-    void Register(XDataAllocation& allocation, DWORD functionStart, DWORD functionSize);
     void Release(const SecondaryAllocation& address);
     bool CanAllocate();
     DWORD GetAllocSize(ushort pdataCount, ushort xdataSize)
     {
         return sizeof(RUNTIME_FUNCTION) * pdataCount + xdataSize;
     }
+
+    static void Register(XDataAllocation * xdataInfo, DWORD functionStart, DWORD functionSize);
+    static void Unregister(XDataAllocation * xdataInfo);
 };

+ 3 - 22
lib/JITIDL/Chakra.JITIDL.vcxproj

@@ -18,34 +18,15 @@
   <PropertyGroup>
     <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
   </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+  <ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
     <Midl>
-      <HeaderFileName>%(Filename).h</HeaderFileName>
-      <AdditionalOptions>-savePP /protocol ndr64 %(AdditionalOptions)</AdditionalOptions>
-      <SuppressStartupBanner>false</SuppressStartupBanner>
-    </Midl>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Midl>
-      <HeaderFileName>%(Filename).h</HeaderFileName>
-      <AdditionalOptions>-savePP %(AdditionalOptions)</AdditionalOptions>
-    </Midl>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <Midl>
-      <AdditionalOptions>-savePP /protocol ndr64 %(AdditionalOptions)</AdditionalOptions>
-    </Midl>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Test|x64'">
-    <Midl>
-      <AdditionalOptions>-savePP /protocol ndr64 %(AdditionalOptions)</AdditionalOptions>
+      <AdditionalOptions>/protocol ndr64 %(AdditionalOptions)</AdditionalOptions>
     </Midl>
   </ItemDefinitionGroup>
   <ItemGroup Condition="'$(BuildingInsideVisualStudio)'=='true'">
     <Midl Include="$(MsBuildThisFileDirectory)ChakraJIT.idl">
       <OutputDirectory>$(IntDir)</OutputDirectory>
-      <AdditionalOptions>%(AdditionalOptions) /target NT62 /prefix client "Client" server "Server"</AdditionalOptions>
-      <HeaderFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).h</HeaderFileName>
+      <AdditionalOptions>%(AdditionalOptions) /target NT61 /prefix client "Client" server "Server"</AdditionalOptions>
     </Midl>
   </ItemGroup>
   <ItemGroup Condition="'$(BuildingWithBuildExe)'=='true'">

+ 3 - 2
lib/JITIDL/JITTypes.h

@@ -766,6 +766,9 @@ typedef struct JITOutputIDL
 
     unsigned int propertyGuardCount;
     unsigned int ctorCachesCount;
+
+    CHAKRA_PTR codeAddress;
+    CHAKRA_PTR xdataAddr;
     TypeGuardTransferEntryIDL* typeGuardEntries;
 
     IDL_DEF([size_is(ctorCachesCount)]) CtorCacheTransferEntryIDL ** ctorCacheEntries;
@@ -776,7 +779,5 @@ typedef struct JITOutputIDL
     EquivalentTypeGuardOffsets* equivalentTypeGuardOffsets;
     XProcNumberPageSegment* numberPageSegments;
 
-    __int64 codeAddress;
-    __int64 xdataAddr;
     __int64 startTime;
 } JITOutputIDL;

+ 5 - 0
lib/Jsrt/Chakra.Jsrt.vcxproj

@@ -80,6 +80,11 @@
   <ItemGroup>
     <None Include="JsrtCommonExports.inc" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\JITIDL\Chakra.JITIDL.vcxproj">
+      <Project>{0db5ecbc-9385-4a65-be2c-4ef7c65cb719}</Project>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(BuildConfigPropsPath)Chakra.Build.targets" Condition="exists('$(BuildConfigPropsPath)Chakra.Build.targets')" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
 </Project>

+ 5 - 0
lib/Jsrt/Core/Chakra.Jsrt.Core.vcxproj

@@ -41,6 +41,11 @@
   <ItemGroup>
     <ClInclude Include="JsrtContextCore.h" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\JITIDL\Chakra.JITIDL.vcxproj">
+      <Project>{0db5ecbc-9385-4a65-be2c-4ef7c65cb719}</Project>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(BuildConfigPropsPath)Chakra.Build.targets" Condition="exists('$(BuildConfigPropsPath)Chakra.Build.targets')" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
 </Project>

+ 3 - 3
lib/Runtime/Base/FunctionBody.h

@@ -557,7 +557,7 @@ namespace Js
         void **runtimeTypeRefs;
 
 #if _M_AMD64 || _M_ARM32_OR_ARM64
-        XDataInfo * xdataInfo;
+        XDataAllocation * xdataInfo;
 #endif
 
         uint32 pendingPolymorphicCacheState;
@@ -628,8 +628,8 @@ namespace Js
         JitTransferData* GetJitTransferData() { return this->jitTransferData; }
         JitTransferData* EnsureJitTransferData(Recycler* recycler);
 #if defined(_M_X64) || defined(_M_ARM32_OR_ARM64)
-        XDataInfo* GetXDataInfo() { return this->xdataInfo; }
-        void SetXDataInfo(XDataInfo* xdataInfo) { this->xdataInfo = xdataInfo; }
+        XDataAllocation* GetXDataInfo() { return this->xdataInfo; }
+        void SetXDataInfo(XDataAllocation* xdataInfo) { this->xdataInfo = xdataInfo; }
 #endif
 
 #ifdef FIELD_ACCESS_STATS

+ 6 - 1
lib/Runtime/Base/ThreadContext.cpp

@@ -319,7 +319,7 @@ ThreadContext::GetThreadStackLimitAddr() const
     return (intptr_t)GetAddressOfStackLimitForCurrentThread();
 }
 
-#if ENABLE_NATIVE_CODEGEN
+#if ENABLE_NATIVE_CODEGEN && (defined(_M_IX86) || defined(_M_X64))
 intptr_t
 ThreadContext::GetSimdTempAreaAddr(uint8 tempIndex) const
 {
@@ -1943,8 +1943,13 @@ ThreadContext::InitJITThreadContext()
 
     ThreadContextDataIDL contextData;
     contextData.processHandle = (intptr_t)JITManager::GetJITManager()->GetJITTargetHandle();
+
     // TODO: OOP JIT, use more generic method for getting name, e.g. in case of ChakraTest.dll
+#ifdef NTBUILD
     contextData.chakraBaseAddress = (intptr_t)GetModuleHandle(L"Chakra.dll");
+#else
+    contextData.chakraBaseAddress = (intptr_t)GetModuleHandle(L"ChakraCore.dll");
+#endif
     contextData.crtBaseAddress = (intptr_t)GetModuleHandle(UCrtC99MathApis::LibraryName);
     contextData.threadStackLimitAddr = reinterpret_cast<intptr_t>(GetAddressOfStackLimitForCurrentThread());
     contextData.bailOutRegisterSaveSpaceAddr = (intptr_t)bailOutRegisterSaveSpace;

+ 1 - 1
lib/Runtime/Base/ThreadContext.h

@@ -1285,7 +1285,7 @@ public:
 
     virtual intptr_t GetThreadStackLimitAddr() const override;
 
-#if ENABLE_NATIVE_CODEGEN
+#if ENABLE_NATIVE_CODEGEN && (defined(_M_IX86) || defined(_M_X64))
     virtual intptr_t GetSimdTempAreaAddr(uint8 tempIndex) const override;
 #endif
 

+ 3 - 0
lib/Runtime/Base/ThreadContextInfo.cpp

@@ -169,6 +169,8 @@ ThreadContextInfo::GetMantissaMaskAddr() const
     return SHIFT_ADDR(this, &Js::Constants::MantissaMask);
 }
 
+#if _M_IX86 || _M_AMD64
+
 intptr_t
 ThreadContextInfo::GetX86AbsMaskF4Addr() const
 {
@@ -276,6 +278,7 @@ ThreadContextInfo::GetX86FourLanesMaskAddr(uint8 minorityLane) const
 {
     return SHIFT_ADDR(this, &X86_4LANES_MASKS[minorityLane]);
 }
+#endif
 
 intptr_t
 ThreadContextInfo::GetStringReplaceNameAddr() const

+ 4 - 0
lib/Runtime/Base/ThreadContextInfo.h

@@ -41,6 +41,7 @@ public:
     intptr_t GetMantissaMaskAddr() const;
     intptr_t GetExponentMaskAddr() const;
 
+#if _M_IX86 || _M_AMD64
     intptr_t GetX86AbsMaskF4Addr() const;
     intptr_t GetX86AbsMaskD2Addr() const;
     intptr_t GetX86NegMaskF4Addr() const;
@@ -59,6 +60,7 @@ public:
     intptr_t GetX86TwoPower31I4Addr() const;
     intptr_t GetX86NegTwoPower31F4Addr() const;
     intptr_t GetX86FourLanesMaskAddr(uint8 minorityLane) const;
+#endif
 
     intptr_t GetStringReplaceNameAddr() const;
     intptr_t GetStringMatchNameAddr() const;
@@ -79,7 +81,9 @@ public:
     virtual intptr_t GetImplicitCallFlagsAddr() const = 0;
 
 #if ENABLE_NATIVE_CODEGEN
+#if defined(_M_IX86) || defined(_M_X64)
     virtual intptr_t GetSimdTempAreaAddr(uint8 tempIndex) const = 0;
+#endif
     virtual intptr_t GetBailOutRegisterSaveSpaceAddr() const = 0;
     virtual PreReservedVirtualAllocWrapper * GetPreReservedVirtualAllocator() = 0;
 #endif