Browse Source

address CR comments

Michael Holman 9 years ago
parent
commit
351fc5cba8
39 changed files with 310 additions and 240 deletions
  1. 6 1
      bin/ChakraCore/ChakraCoreDllFunc.cpp
  2. 1 9
      bin/ch/JITProcessManager.cpp
  3. 2 0
      bin/ch/ch.cpp
  4. 0 2
      bin/ch/ch.vcxproj
  5. 33 30
      lib/Backend/BackwardPass.cpp
  6. 4 8
      lib/Backend/Encoder.cpp
  7. 3 3
      lib/Backend/FlowGraph.cpp
  8. 1 1
      lib/Backend/FlowGraph.h
  9. 4 7
      lib/Backend/Func.cpp
  10. 2 2
      lib/Backend/GlobOpt.cpp
  11. 17 17
      lib/Backend/GlobOptFields.cpp
  12. 4 1
      lib/Backend/IR.cpp
  13. 2 2
      lib/Backend/Inline.cpp
  14. 0 6
      lib/Backend/JITTimeWorkItem.h
  15. 26 8
      lib/Backend/JITType.cpp
  16. 4 0
      lib/Backend/JITType.h
  17. 22 22
      lib/Backend/Lower.cpp
  18. 2 0
      lib/Backend/NativeCodeGenerator.cpp
  19. 24 24
      lib/Backend/Opnd.cpp
  20. 2 2
      lib/Backend/Opnd.h
  21. 2 2
      lib/Backend/ServerThreadContext.h
  22. 0 1
      lib/Common/Memory/PageAllocator.cpp
  23. 0 2
      lib/Common/Memory/PageAllocator.h
  24. 0 0
      lib/JITClient/JITClient.cpp
  25. 52 15
      lib/JITClient/JITManager.cpp
  26. 6 1
      lib/JITClient/JITManager.h
  27. 4 0
      lib/JITIDL/ChakraJIT.idl
  28. 36 20
      lib/JITIDL/JITTypes.h
  29. 10 1
      lib/JITServer/JITServer.cpp
  30. 0 17
      lib/Runtime/Base/FunctionBody.h
  31. 2 2
      lib/Runtime/Base/ThreadContext.h
  32. 25 2
      lib/Runtime/Base/ThreadContextInfo.cpp
  33. 2 19
      lib/Runtime/Base/ThreadContextInfo.h
  34. 3 0
      lib/Runtime/Language/InlineCache.cpp
  35. 3 1
      lib/Runtime/Language/JavascriptOperators.cpp
  36. 2 1
      lib/Runtime/Language/ObjTypeSpecFldInfo.cpp
  37. 1 0
      lib/Runtime/Library/JavascriptNumber.inl
  38. 3 1
      lib/Runtime/Types/RecyclableObject.cpp
  39. 0 10
      test/Miscellaneous/rlexe.xml

+ 6 - 1
bin/ChakraCore/ChakraCoreDllFunc.cpp

@@ -213,4 +213,9 @@ HRESULT JsInitializeJITServer(
 {
     return E_NOTIMPL;
 }
-#endif
+EXPORT_FUNC
+HRESULT JsShutdownJITServer()
+{
+    return E_NOTIMPL;
+}
+#endif

+ 1 - 9
bin/ch/JITProcessManager.cpp

@@ -105,7 +105,7 @@ HRESULT JITProcessManager::CreateServerProcess(int argc, __in_ecount(argc) LPWST
         NULL,
         NULL,
         FALSE,
-        CREATE_SUSPENDED,
+        NULL,
         NULL,
         NULL,
         &si,
@@ -116,14 +116,6 @@ HRESULT JITProcessManager::CreateServerProcess(int argc, __in_ecount(argc) LPWST
 
     free(cmdLine);
 
-    if (ResumeThread(processInfo.hThread) == (DWORD)-1)
-    {
-        TerminateProcess(processInfo.hProcess, GetLastError());
-        CloseHandle(processInfo.hProcess);
-        CloseHandle(processInfo.hThread);
-        return HRESULT_FROM_WIN32(GetLastError());
-    }
-
     CloseHandle(processInfo.hThread);
     s_rpcServerProcessHandle = processInfo.hProcess;
 

+ 2 - 0
bin/ch/ch.cpp

@@ -668,7 +668,9 @@ bool HandleJITServerFlag(int& argc, _Inout_updates_to_(argc, argc) LPWSTR argv[]
     }
 
     if (i == argc)
+    {
         return false;
+    }
 
     // remove this flag now
     HostConfigFlags::RemoveArg(argc, argv, i);

+ 0 - 2
bin/ch/ch.vcxproj

@@ -38,8 +38,6 @@
         kernel32.lib;
         Rpcrt4.lib;
       </AdditionalDependencies>
-      <IgnoreAllDefaultLibraries Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-      </IgnoreAllDefaultLibraries>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>

+ 33 - 30
lib/Backend/BackwardPass.cpp

@@ -710,7 +710,7 @@ BackwardPass::MergeSuccBlocksInfo(BasicBlock * block)
             auto fixupFrom = [block, blockSucc, this](Bucket<AddPropertyCacheBucket> &bucket)
             {
                 AddPropertyCacheBucket *fromData = &bucket.element;
-                if (fromData->GetInitialType().t == nullptr ||
+                if (fromData->GetInitialType() == nullptr ||
                     fromData->GetFinalType() == fromData->GetInitialType())
                 {
                     return;
@@ -722,7 +722,7 @@ BackwardPass::MergeSuccBlocksInfo(BasicBlock * block)
             auto fixupTo = [blockSucc, this](Bucket<AddPropertyCacheBucket> &bucket)
             {
                 AddPropertyCacheBucket *toData = &bucket.element;
-                if (toData->GetInitialType().t == nullptr ||
+                if (toData->GetInitialType() == nullptr ||
                     toData->GetFinalType() == toData->GetInitialType())
                 {
                     return;
@@ -1184,7 +1184,7 @@ BackwardPass::MergeGuardedProperties(ObjTypeGuardBucket bucket1, ObjTypeGuardBuc
     ObjTypeGuardBucket bucket;
     bucket.SetGuardedPropertyOps(mergedPropertyOps);
     JITTypeHolder monoGuardType = bucket1.GetMonoGuardType();
-    if (monoGuardType.t != nullptr)
+    if (monoGuardType != nullptr)
     {
         Assert(!bucket2.NeedsMonoCheck() || monoGuardType == bucket2.GetMonoGuardType());
     }
@@ -3662,7 +3662,7 @@ BackwardPass::ProcessNewScObject(IR::Instr* instr)
                 // transition here.
                 AddPropertyCacheBucket *pBucket = block->stackSymToFinalType->Get(objSym->m_id);
                 if (pBucket &&
-                    pBucket->GetInitialType().t != nullptr &&
+                    pBucket->GetInitialType() != nullptr &&
                     pBucket->GetFinalType() != pBucket->GetInitialType())
                 {
                     Assert(pBucket->GetInitialType() == ctorCache->GetType());
@@ -3672,7 +3672,7 @@ BackwardPass::ProcessNewScObject(IR::Instr* instr)
                     }
 #if DBG
                     pBucket->deadStoreUnavailableInitialType = pBucket->GetInitialType();
-                    if (pBucket->deadStoreUnavailableFinalType.t == nullptr)
+                    if (pBucket->deadStoreUnavailableFinalType == nullptr)
                     {
                         pBucket->deadStoreUnavailableFinalType = pBucket->GetFinalType();
                     }
@@ -4256,7 +4256,7 @@ BackwardPass::ProcessPropertySymOpndUse(IR::PropertySymOpnd * opnd)
                 StackSym *baseSym = opnd->GetObjectSym();
                 AddPropertyCacheBucket *pBucket = block->stackSymToFinalType->Get(baseSym->m_id);
                 if (pBucket &&
-                    pBucket->GetFinalType().t != nullptr &&
+                    pBucket->GetFinalType() != nullptr &&
                     pBucket->GetFinalType() != pBucket->GetInitialType())
                 {
                     this->InsertTypeTransition(this->currentInstr->m_next, baseSym, pBucket);
@@ -4501,7 +4501,7 @@ BackwardPass::TrackAddPropertyTypes(IR::PropertySymOpnd *opnd, BasicBlock *block
     JITTypeHolder typeWithProperty = opnd->IsMono() ? opnd->GetType() : opnd->GetFirstEquivalentType();
     JITTypeHolder typeWithoutProperty = opnd->HasInitialType() ? opnd->GetInitialType() : JITTypeHolder(nullptr);
 
-    if (typeWithoutProperty.t == nullptr ||
+    if (typeWithoutProperty == nullptr ||
         typeWithProperty == typeWithoutProperty ||
         (opnd->IsTypeChecked() && !opnd->IsInitialTypeChecked()))
     {
@@ -4510,7 +4510,7 @@ BackwardPass::TrackAddPropertyTypes(IR::PropertySymOpnd *opnd, BasicBlock *block
             PropertySym *propertySym = opnd->m_sym->AsPropertySym();
             AddPropertyCacheBucket *pBucket =
                 block->stackSymToFinalType->Get(propertySym->m_stackSym->m_id);
-            if (pBucket && pBucket->GetFinalType().t && pBucket->GetInitialType() != pBucket->GetFinalType())
+            if (pBucket && pBucket->GetFinalType() != nullptr && pBucket->GetInitialType() != pBucket->GetFinalType())
             {
                 opnd->SetFinalType(pBucket->GetFinalType());
             }
@@ -4519,12 +4519,13 @@ BackwardPass::TrackAddPropertyTypes(IR::PropertySymOpnd *opnd, BasicBlock *block
         return;
     }
 
-#if 0 // TODO: OOP JIT, add these assert back (ReadProcessMemory?)
+#if DBG
     Assert(typeWithProperty != nullptr);
-    Js::DynamicTypeHandler * typeWithoutPropertyTypeHandler = static_cast<Js::DynamicType *>(typeWithoutProperty)->GetTypeHandler();
-    Js::DynamicTypeHandler * typeWithPropertyTypeHandler = static_cast<Js::DynamicType *>(typeWithProperty)->GetTypeHandler();
-    Assert(typeWithoutPropertyTypeHandler->GetPropertyCount() + 1 == typeWithPropertyTypeHandler->GetPropertyCount());
-    AssertMsg(Js::DynamicObject::IsTypeHandlerCompatibleForObjectHeaderInlining(typeWithoutPropertyTypeHandler, typeWithPropertyTypeHandler),
+    const JITTypeHandler * typeWithoutPropertyTypeHandler = typeWithoutProperty->GetTypeHandler();
+    const JITTypeHandler * typeWithPropertyTypeHandler = typeWithProperty->GetTypeHandler();
+    // TODO: OOP JIT, reenable assert
+    //Assert(typeWithoutPropertyTypeHandler->GetPropertyCount() + 1 == typeWithPropertyTypeHandler->GetPropertyCount());
+    AssertMsg(JITTypeHandler::IsTypeHandlerCompatibleForObjectHeaderInlining(typeWithoutPropertyTypeHandler, typeWithPropertyTypeHandler),
         "TypeHandlers are not compatible for transition?");
     Assert(typeWithoutPropertyTypeHandler->GetSlotCapacity() <= typeWithPropertyTypeHandler->GetSlotCapacity());
 #endif
@@ -4545,7 +4546,7 @@ BackwardPass::TrackAddPropertyTypes(IR::PropertySymOpnd *opnd, BasicBlock *block
 #if DBG
     JITTypeHolder deadStoreUnavailableFinalType(nullptr);
 #endif
-    if (pBucket->GetInitialType().t == nullptr || opnd->GetType() != pBucket->GetInitialType())
+    if (pBucket->GetInitialType() == nullptr || opnd->GetType() != pBucket->GetInitialType())
     {
 #if DBG
         if (opnd->GetType() == pBucket->deadStoreUnavailableInitialType)
@@ -4571,7 +4572,7 @@ BackwardPass::TrackAddPropertyTypes(IR::PropertySymOpnd *opnd, BasicBlock *block
 
     if (!PHASE_OFF(Js::ObjTypeSpecStorePhase, this->func))
     {
-#if 0 //TODO: OOP JIT, reenable assert
+#if DBG
 
         // We may regress in this case:
         // if (b)
@@ -4592,15 +4593,17 @@ BackwardPass::TrackAddPropertyTypes(IR::PropertySymOpnd *opnd, BasicBlock *block
         if (!opnd->IsTypeDead())
         {
             // This is the type that would have been propagated if we didn't kill it because the type isn't available
-            JITTypeHolder checkFinalType = deadStoreUnavailableFinalType ? deadStoreUnavailableFinalType : finalType;
+            JITTypeHolder checkFinalType = deadStoreUnavailableFinalType != nullptr ? deadStoreUnavailableFinalType : finalType;
             if (opnd->HasFinalType() && opnd->GetFinalType() != checkFinalType)
             {
                 // Final type discovery must be progressively better (unless we kill it in the deadstore pass
                 // when the type is not available during the forward pass)
-                Js::DynamicTypeHandler * oldFinalTypeHandler = static_cast<Js::DynamicType *>(opnd->GetFinalType())->GetTypeHandler();
-                Js::DynamicTypeHandler * checkFinalTypeHandler = static_cast<Js::DynamicType *>(checkFinalType)->GetTypeHandler();
-                Assert(oldFinalTypeHandler->GetPropertyCount() < checkFinalTypeHandler->GetPropertyCount());
-                AssertMsg(Js::DynamicObject::IsTypeHandlerCompatibleForObjectHeaderInlining(oldFinalTypeHandler, checkFinalTypeHandler),
+                const JITTypeHandler * oldFinalTypeHandler = opnd->GetFinalType()->GetTypeHandler();
+                const JITTypeHandler * checkFinalTypeHandler = checkFinalType->GetTypeHandler();
+
+                // TODO: OOP JIT, enable assert
+                //Assert(oldFinalTypeHandler->GetPropertyCount() < checkFinalTypeHandler->GetPropertyCount());
+                AssertMsg(JITTypeHandler::IsTypeHandlerCompatibleForObjectHeaderInlining(oldFinalTypeHandler, checkFinalTypeHandler),
                     "TypeHandlers should be compatible for transition.");
                 Assert(oldFinalTypeHandler->GetSlotCapacity() <= checkFinalTypeHandler->GetSlotCapacity());
             }
@@ -4644,7 +4647,7 @@ BackwardPass::TrackAddPropertyTypes(IR::PropertySymOpnd *opnd, BasicBlock *block
     {
 #if DBG
         pBucket->deadStoreUnavailableInitialType = pBucket->GetInitialType();
-        if (pBucket->deadStoreUnavailableFinalType.t == nullptr)
+        if (pBucket->deadStoreUnavailableFinalType == nullptr)
         {
             pBucket->deadStoreUnavailableFinalType = pBucket->GetFinalType();
         }
@@ -4671,11 +4674,11 @@ BackwardPass::InsertTypeTransition(IR::Instr *instrInsertBefore, StackSym *objSy
     baseOpnd->SetIsJITOptimizedReg(true);
 
     IR::AddrOpnd *initialTypeOpnd =
-        IR::AddrOpnd::New(data->GetInitialType().t->GetAddr(), IR::AddrOpndKindDynamicType, this->func);
+        IR::AddrOpnd::New(data->GetInitialType()->GetAddr(), IR::AddrOpndKindDynamicType, this->func);
     initialTypeOpnd->m_metadata = data->GetInitialType().t;
 
     IR::AddrOpnd *finalTypeOpnd =
-        IR::AddrOpnd::New(data->GetFinalType().t->GetAddr(), IR::AddrOpndKindDynamicType, this->func);
+        IR::AddrOpnd::New(data->GetFinalType()->GetAddr(), IR::AddrOpndKindDynamicType, this->func);
     finalTypeOpnd->m_metadata = data->GetFinalType().t;
 
     IR::Instr *adjustTypeInstr =
@@ -4722,8 +4725,8 @@ BackwardPass::InsertTypeTransitionAtBlock(BasicBlock *block, int symId, AddPrope
                 {
                     // This symbol already has a type transition at this point.
                     // It *must* be doing the same transition we're already trying to do.
-                    Assert((intptr_t)instr->GetDst()->AsAddrOpnd()->m_address == data->GetFinalType().t->GetAddr() &&
-                           (intptr_t)instr->GetSrc2()->AsAddrOpnd()->m_address == data->GetInitialType().t->GetAddr());
+                    Assert((intptr_t)instr->GetDst()->AsAddrOpnd()->m_address == data->GetFinalType()->GetAddr() &&
+                           (intptr_t)instr->GetSrc2()->AsAddrOpnd()->m_address == data->GetInitialType()->GetAddr());
                     // Nothing to do.
                     return;
                 }
@@ -4824,7 +4827,7 @@ BackwardPass::ForEachAddPropertyCacheBucket(Fn fn)
     FOREACH_HASHTABLE_ENTRY(AddPropertyCacheBucket, bucket, block->stackSymToFinalType)
     {
         AddPropertyCacheBucket *data = &bucket.element;
-        if (data->GetInitialType().t != nullptr &&
+        if (data->GetInitialType() != nullptr &&
             data->GetInitialType() != data->GetFinalType())
         {
             bool done = fn(bucket.value, data);
@@ -4841,22 +4844,22 @@ bool
 BackwardPass::TransitionUndoesObjectHeaderInlining(AddPropertyCacheBucket *data) const
 {
     JITTypeHolder type = data->GetInitialType();
-    if (type.t == nullptr || !Js::DynamicType::Is(type.t->GetTypeId()))
+    if (type == nullptr || !Js::DynamicType::Is(type->GetTypeId()))
     {
         return false;
     }
 
-    if (!type.t->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler())
+    if (!type->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler())
     {
         return false;
     }
 
     type = data->GetFinalType();
-    if (type.t == nullptr || !Js::DynamicType::Is(type.t->GetTypeId()))
+    if (type == nullptr || !Js::DynamicType::Is(type->GetTypeId()))
     {
         return false;
     }
-    return !type.t->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler();
+    return !type->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler();
 }
 
 void

+ 4 - 8
lib/Backend/Encoder.cpp

@@ -271,8 +271,6 @@ Encoder::Encode()
         }
     }
 
-    JITTimeWorkItem * workItem = m_func->GetWorkItem();
-
     BEGIN_CODEGEN_PHASE(m_func, Js::EmitterPhase);
 
     // Copy to permanent buffer.
@@ -440,7 +438,7 @@ Encoder::Encode()
                 equivalentTypeGuardOffsets->guards[i].cache.nextEvictionVictim = cache->nextEvictionVictim;
                 equivalentTypeGuardOffsets->guards[i].cache.record.propertyCount = cache->record.propertyCount;
                 equivalentTypeGuardOffsets->guards[i].cache.record.propertyOffset = NativeCodeData::GetDataTotalOffset(cache->record.properties);
-                for (int j = 0; j < EQUIVALENT_TYPE_CACHE_SIZE_IDL; j++)
+                for (int j = 0; j < EQUIVALENT_TYPE_CACHE_SIZE; j++)
                 {
                     equivalentTypeGuardOffsets->guards[i].cache.types[j] = (intptr_t)cache->types[j];
                 }
@@ -477,10 +475,8 @@ Encoder::Encode()
     if (this->m_func->propertyGuardsByPropertyId != nullptr)
     {
         Assert(!isSimpleJit);
-# if 0 // TODO: OOP JIT, is this assert valid?
         AssertMsg(!(PHASE_OFF(Js::ObjTypeSpecPhase, this->m_func) && PHASE_OFF(Js::FixedMethodsPhase, this->m_func)),
             "Why do we have type guards if we don't do object type spec or fixed methods?");
-#endif
 
 #if DBG
         int totalGuardCount = (this->m_func->singleTypeGuards != nullptr ? this->m_func->singleTypeGuards->Count() : 0)
@@ -687,10 +683,10 @@ Encoder::Encode()
         Js::Configuration::Global.flags.DumpIRAddresses = dumpIRAddressesValue;
     }
 
-    if (PHASE_DUMP(Js::EncoderPhase, m_func) && Js::Configuration::Global.flags.Verbose)
+    if (PHASE_DUMP(Js::EncoderPhase, m_func) && Js::Configuration::Global.flags.Verbose && !m_func->IsOOPJIT())
     {
-        workItem->DumpNativeOffsetMaps();
-        workItem->DumpNativeThrowSpanSequence();
+        m_func->GetInProcJITEntryPointInfo()->DumpNativeOffsetMaps();
+        m_func->GetInProcJITEntryPointInfo()->DumpNativeThrowSpanSequence();
         this->DumpInlineeFrameMap(m_func->GetJITOutput()->GetCodeAddress());
         Output::Flush();
     }

+ 3 - 3
lib/Backend/FlowGraph.cpp

@@ -3354,9 +3354,9 @@ BasicBlock::Dump()
 void
 AddPropertyCacheBucket::Dump() const
 {
-    Assert(this->initialType.t != nullptr);
-    Assert(this->finalType.t != nullptr);
-    Output::Print(_u(" initial type: 0x%x, final type: 0x%x "), this->initialType.t->GetAddr(), this->finalType.t->GetAddr());
+    Assert(this->initialType != nullptr);
+    Assert(this->finalType != nullptr);
+    Output::Print(_u(" initial type: 0x%x, final type: 0x%x "), this->initialType->GetAddr(), this->finalType->GetAddr());
 }
 
 void

+ 1 - 1
lib/Backend/FlowGraph.h

@@ -91,7 +91,7 @@ public:
     void SetGuardedPropertyOps(BVSparse<JitArenaAllocator> *guardedPropertyOps) { this->guardedPropertyOps = guardedPropertyOps; }
     void AddToGuardedPropertyOps(uint propertyOpId) { Assert(this->guardedPropertyOps != nullptr); this->guardedPropertyOps->Set(propertyOpId); }
 
-    bool NeedsMonoCheck() const { return this->monoGuardType.t != nullptr; }
+    bool NeedsMonoCheck() const { return this->monoGuardType != nullptr; }
     void SetMonoGuardType(JITTypeHolder type) { this->monoGuardType = type; }
     JITTypeHolder GetMonoGuardType() const { return this->monoGuardType; }
 

+ 4 - 7
lib/Backend/Func.cpp

@@ -804,11 +804,8 @@ Func::AjustLocalVarSlotOffset()
         int localsOffset = m_localVarSlotsOffset - (m_localStackHeight + m_ArgumentsOffset);
         int valueChangeOffset = m_hasLocalVarChangedOffset - (m_localStackHeight + m_ArgumentsOffset);
 
-        Js::FunctionEntryPointInfo * entryPointInfo = static_cast<Js::FunctionEntryPointInfo*>(this->m_workItem->GetEntryPoint());
-        Assert(entryPointInfo != nullptr);
-
-        entryPointInfo->localVarSlotsOffset = localsOffset;
-        entryPointInfo->localVarChangedOffset = valueChangeOffset;
+        m_output.SetVarSlotsOffset(localsOffset);
+        m_output.SetVarChangedOffset(valueChangeOffset);
     }
 }
 #endif
@@ -1389,7 +1386,7 @@ Func::CreateEquivalentTypeGuard(JITTypeHolder type, uint32 objTypeSpecFldId)
 {
     EnsureEquivalentTypeGuards();
 
-    Js::JitEquivalentTypeGuard* guard = NativeCodeDataNew(GetNativeCodeDataAllocator(), Js::JitEquivalentTypeGuard, type.t->GetAddr(), this->indexedPropertyGuardCount++, objTypeSpecFldId);
+    Js::JitEquivalentTypeGuard* guard = NativeCodeDataNewNoFixup(GetNativeCodeDataAllocator(), Js::JitEquivalentTypeGuard, type->GetAddr(), this->indexedPropertyGuardCount++, objTypeSpecFldId);
 
     // If we want to hard code the address of the cache, we will need to go back to allocating it from the native code data allocator.
     // We would then need to maintain consistency (double write) to both the recycler allocated cache and the one on the heap.
@@ -1400,7 +1397,7 @@ Func::CreateEquivalentTypeGuard(JITTypeHolder type, uint32 objTypeSpecFldId)
     }
     else
     {
-        cache = NativeCodeDataNewZ(GetTransferDataAllocator(), Js::EquivalentTypeCache);
+        cache = NativeCodeDataNewZNoFixup(GetTransferDataAllocator(), Js::EquivalentTypeCache);
     }
     guard->SetCache(cache);
 

+ 2 - 2
lib/Backend/GlobOpt.cpp

@@ -3506,7 +3506,7 @@ JsTypeValueInfo* GlobOpt::MergeJsTypeValueInfo(JsTypeValueInfo * toValueInfo, Js
         return toValueInfo;
     }
 
-    if (mergedType.t == nullptr && mergedTypeSet == nullptr)
+    if (mergedType == nullptr && mergedTypeSet == nullptr)
     {
         // No info, so don't bother making a value.
         return nullptr;
@@ -20534,7 +20534,7 @@ void ValueInfo::Dump()
     else if(IsJsType())
     {
         const JITTypeHolder type(AsJsType()->GetJsType());
-        type.t != nullptr ? Output::Print(_u("type: 0x%p, "), type.t->GetAddr()) : Output::Print(_u("type: null, "));
+        type != nullptr ? Output::Print(_u("type: 0x%p, "), type->GetAddr()) : Output::Print(_u("type: null, "));
         Output::Print(_u("type Set: "));
         Js::EquivalentTypeSet* typeSet = AsJsType()->GetJsTypeSet();
         if (typeSet != nullptr)

+ 17 - 17
lib/Backend/GlobOptFields.cpp

@@ -2265,12 +2265,12 @@ GlobOpt::KillObjectHeaderInlinedTypeSyms(BasicBlock *block, bool isObjTypeSpecia
         {
             JsTypeValueInfo *valueInfo = value->GetValueInfo()->AsJsType();
             Assert(valueInfo);
-            if (valueInfo->GetJsType().t != nullptr)
+            if (valueInfo->GetJsType() != nullptr)
             {
                 JITTypeHolder type(valueInfo->GetJsType());
-                if (Js::DynamicType::Is(type.t->GetTypeId()))
+                if (Js::DynamicType::Is(type->GetTypeId()))
                 {
-                    if (type.t->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler())
+                    if (type->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler())
                     {
                         this->blockData.liveFields->Clear(symId);
                     }
@@ -2282,9 +2282,9 @@ GlobOpt::KillObjectHeaderInlinedTypeSyms(BasicBlock *block, bool isObjTypeSpecia
                 for (uint16 i = 0; i < typeSet->GetCount(); i++)
                 {
                     JITTypeHolder type = typeSet->GetType(i);
-                    if (type.t != nullptr && Js::DynamicType::Is(type.t->GetTypeId()))
+                    if (type != nullptr && Js::DynamicType::Is(type->GetTypeId()))
                     {
-                        if (type.t->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler())
+                        if (type->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler())
                         {
                             this->blockData.liveFields->Clear(symId);
                             break;
@@ -2379,7 +2379,7 @@ GlobOpt::ProcessPropOpInTypeCheckSeq(IR::Instr* instr, IR::PropertySymOpnd *opnd
         // We need a monomorphic type check here (e.g., final type opt, fixed field check on non-proto property).
         JITTypeHolder opndType = opnd->GetType();
 
-        if (valueInfo == nullptr || (valueInfo->GetJsType().t == nullptr && valueInfo->GetJsTypeSet() == nullptr))
+        if (valueInfo == nullptr || (valueInfo->GetJsType() == nullptr && valueInfo->GetJsTypeSet() == nullptr))
         {
             // This is the initial type check.
             opnd->SetTypeAvailable(false);
@@ -2391,7 +2391,7 @@ GlobOpt::ProcessPropOpInTypeCheckSeq(IR::Instr* instr, IR::PropertySymOpnd *opnd
                 SetObjectTypeFromTypeSym(typeSym, opndType, nullptr, block, updateExistingValue);
             }
         }
-        else if (valueInfo->GetJsType().t != nullptr)
+        else if (valueInfo->GetJsType() != nullptr)
         {
             // We have a monomorphic type check upstream. Check against initial/final type.
             const JITTypeHolder valueType(valueInfo->GetJsType());
@@ -2497,7 +2497,7 @@ GlobOpt::ProcessPropOpInTypeCheckSeq(IR::Instr* instr, IR::PropertySymOpnd *opnd
         Js::EquivalentTypeSet * opndTypeSet = opnd->GetEquivalentTypeSet();
         uint16 checkedTypeSetIndex = (uint16)-1;
 
-        if (valueInfo == nullptr || (valueInfo->GetJsType().t == nullptr && valueInfo->GetJsTypeSet() == nullptr))
+        if (valueInfo == nullptr || (valueInfo->GetJsType() == nullptr && valueInfo->GetJsTypeSet() == nullptr))
         {
             // If we don't have a value for the type we will have to emit a type check and we produce a new type value here.
             if (produceType)
@@ -2514,7 +2514,7 @@ GlobOpt::ProcessPropOpInTypeCheckSeq(IR::Instr* instr, IR::PropertySymOpnd *opnd
             isSpecialized = !isTypeDead;
             emitsTypeCheck = isSpecialized;
         }
-        else if (valueInfo->GetJsType().t != nullptr ?
+        else if (valueInfo->GetJsType() != nullptr ?
                  opndTypeSet->Contains(valueInfo->GetJsType(), &checkedTypeSetIndex) :
                  IsSubsetOf(valueInfo->GetJsTypeSet(), opndTypeSet))
         {
@@ -2958,7 +2958,7 @@ GlobOpt::SetObjectTypeFromTypeSym(StackSym *typeSym, const JITTypeHolder type, J
         // value created during loop pre-pass for field hoisting, so we expect the value info to still be blank.
         Assert(value != nullptr && value->GetValueInfo() != nullptr && value->GetValueInfo()->IsJsType());
         JsTypeValueInfo* valueInfo = value->GetValueInfo()->AsJsType();
-        Assert(valueInfo->GetJsType().t == nullptr && valueInfo->GetJsTypeSet() == nullptr);
+        Assert(valueInfo->GetJsType() == nullptr && valueInfo->GetJsTypeSet() == nullptr);
         UpdateObjectTypeValue(value, type, true, typeSet, true);
     }
     else
@@ -3144,10 +3144,10 @@ GlobOpt::UpdateObjPtrValueType(IR::Opnd * opnd, IR::Instr * instr)
     }
     JsTypeValueInfo * typeValueInfo = typeValue->GetValueInfo()->AsJsType();
     JITTypeHolder type = typeValueInfo->GetJsType();
-    if (type.t != nullptr)
+    if (type != nullptr)
     {
-        if (Js::DynamicType::Is(type.t->GetTypeId()) &&
-            !type.t->GetTypeHandler()->IsLocked())
+        if (Js::DynamicType::Is(type->GetTypeId()) &&
+            !type->GetTypeHandler()->IsLocked())
         {
             return;
         }
@@ -3159,16 +3159,16 @@ GlobOpt::UpdateObjPtrValueType(IR::Opnd * opnd, IR::Instr * instr)
         for (uint16 i = 0; i < typeSet->GetCount(); i++)
         {
             type = typeSet->GetType(i);
-            if (Js::DynamicType::Is(type.t->GetTypeId()) &&
-                !type.t->GetTypeHandler()->IsLocked())
+            if (Js::DynamicType::Is(type->GetTypeId()) &&
+                !type->GetTypeHandler()->IsLocked())
             {
                 return;
             }
         }
     }
 
-    AnalysisAssert(type.t != nullptr);
-    Js::TypeId typeId = type.t->GetTypeId();
+    AnalysisAssert(type != nullptr);
+    Js::TypeId typeId = type->GetTypeId();
 
     // Passing false for useVirtual as we would never have a virtual typed array hitting this code path
     ValueType newValueType = ValueType::FromTypeId(typeId, false);

+ 4 - 1
lib/Backend/IR.cpp

@@ -1865,7 +1865,10 @@ PragmaInstr::Record(uint32 nativeBufferOffset)
 {
     // Currently the only pragma instructions are for Source Info
     Assert(this->m_func->GetTopFunc()->DoRecordNativeMap());
-    this->m_func->GetTopFunc()->m_workItem->RecordNativeMap(nativeBufferOffset, m_statementIndex);
+    if (!m_func->IsOOPJIT())
+    {
+        m_func->GetTopFunc()->GetInProcJITEntryPointInfo()->RecordNativeMap(nativeBufferOffset, m_statementIndex);
+    }
 }
 #endif
 

+ 2 - 2
lib/Backend/Inline.cpp

@@ -834,14 +834,14 @@ Inline::InlinePolymorphicFunctionUsingFixedMethods(IR::Instr *callInstr, const F
         InsertOneInlinee(callInstr, returnValueOpnd, constMethodValueOpnd, inlineesDataArray[i], inlineesDataArray[i]->GetRuntimeInfo(), doneLabel, symCallerThis, safeThis, recursiveInlineDepth);
         while (fixedFunctionInfoArray[i].NextHasSameFixedField())
         {
-            dispatchStartLabel->InsertBefore(IR::BranchInstr::New(Js::OpCode::BrAddr_A, inlineeStartLabel, typeOpnd, IR::AddrOpnd::New(methodPropertyOpnd->GetType(i).t->GetAddr(),
+            dispatchStartLabel->InsertBefore(IR::BranchInstr::New(Js::OpCode::BrAddr_A, inlineeStartLabel, typeOpnd, IR::AddrOpnd::New(methodPropertyOpnd->GetType(i)->GetAddr(),
                 IR::AddrOpndKindDynamicType, dispatchStartLabel->m_func), dispatchStartLabel->m_func));
             this->topFunc->PinTypeRef(methodPropertyOpnd->GetType(i).t); // Keep the types alive as the types may not be equivalent and, hence, won't be kept alive by EquivalentTypeCache
             i++;
         }
 
         dispatchStartLabel->InsertBefore(IR::BranchInstr::New(Js::OpCode::BrAddr_A, inlineeStartLabel,
-            typeOpnd, IR::AddrOpnd::New(methodPropertyOpnd->GetType(i).t->GetAddr(), IR::AddrOpndKindDynamicType, dispatchStartLabel->m_func), dispatchStartLabel->m_func));
+            typeOpnd, IR::AddrOpnd::New(methodPropertyOpnd->GetType(i)->GetAddr(), IR::AddrOpndKindDynamicType, dispatchStartLabel->m_func), dispatchStartLabel->m_func));
         this->topFunc->PinTypeRef(methodPropertyOpnd->GetType(i).t); // Keep the types alive as the types may not be equivalent and, hence, won't be kept alive by EquivalentTypeCache
     }
 

+ 0 - 6
lib/Backend/JITTimeWorkItem.h

@@ -48,10 +48,4 @@ private:
     CodeGenWorkItemIDL * m_workItemData;
     JITTimeFunctionBody m_jitBody;
     Js::SmallSpanSequence m_statementMap;
-
-public: // TODO: (michhol) remove these. currently needed to compile
-    Js::EntryPointInfo * GetEntryPoint() { __debugbreak(); return nullptr; }
-    void DumpNativeOffsetMaps() { __debugbreak(); }
-    void DumpNativeThrowSpanSequence() { __debugbreak(); }
-    void RecordNativeMap(...) { __debugbreak(); }
 };

+ 26 - 8
lib/Backend/JITType.cpp

@@ -88,28 +88,46 @@ JITTypeHolder::JITTypeHolder(JITType * t) :
 {
 }
 
+const JITType *
+JITTypeHolder::operator->() const
+{
+    return this->t;
+}
+
 bool
 JITTypeHolder::operator==(const JITTypeHolder& p) const
 {
-    if (this->t != nullptr && p.t != nullptr)
+    if (this->t != nullptr && p != nullptr)
     {
-        return this->t->GetAddr() == p.t->GetAddr();
+        return this->t->GetAddr() == p->GetAddr();
     }
-    return this->t == nullptr && p.t == nullptr;
+    return this->t == nullptr && p == nullptr;
 }
 
 bool
-JITTypeHolder::operator!= (const JITTypeHolder& p) const
+JITTypeHolder::operator!=(const JITTypeHolder& p) const
 {
     return !(*this == p);
 }
 
+bool
+JITTypeHolder::operator==(const nullptr_t &p) const
+{
+    return this->t == nullptr;
+}
+
+bool
+JITTypeHolder::operator!=(const nullptr_t &p) const
+{
+    return this->t != nullptr;
+}
+
 bool
 JITTypeHolder::operator>(const JITTypeHolder& p) const
 {
-    if (this->t != nullptr && p.t != nullptr)
+    if (this->t != nullptr && p != nullptr)
     {
-        return this->t->GetAddr() > p.t->GetAddr();
+        return this->t->GetAddr() > p->GetAddr();
     }
     return false;
 }
@@ -123,9 +141,9 @@ JITTypeHolder::operator<=(const JITTypeHolder& p) const
 bool
 JITTypeHolder::operator>=(const JITTypeHolder& p) const
 {
-    if (this->t != nullptr && p.t != nullptr)
+    if (this->t != nullptr && p != nullptr)
     {
-        return this->t->GetAddr() >= p.t->GetAddr();
+        return this->t->GetAddr() >= p->GetAddr();
     }
     return false;
 }

+ 4 - 0
lib/Backend/JITType.h

@@ -36,6 +36,7 @@ public:
 
     JITTypeHolder();
     JITTypeHolder(JITType * t);
+    const JITType* operator->() const;
     bool operator== (const JITTypeHolder& p) const;
     bool operator!= (const JITTypeHolder& p) const;
     bool operator> (const JITTypeHolder& p) const;
@@ -43,6 +44,8 @@ public:
     bool operator< (const JITTypeHolder& p) const;
     bool operator<= (const JITTypeHolder& p) const;
     void operator =(const JITTypeHolder &p);
+    bool operator== (const nullptr_t &p) const;
+    bool operator!= (const nullptr_t &p) const;
 
 private:
     // prevent implicit conversion
@@ -53,4 +56,5 @@ private:
     template<typename T> bool operator< (T p) const;
     template<typename T> bool operator<= (T p) const;
     template<typename T> void operator =(T p);
+    template<typename T> T* operator->();
 };

+ 22 - 22
lib/Backend/Lower.cpp

@@ -4650,7 +4650,7 @@ bool Lowerer::TryLowerNewScObjectWithFixedCtorCache(IR::Instr* newObjInstr, IR::
         return true;
     }
 
-    AssertMsg(ctorCache->GetType().t != nullptr, "Why did we hard-code a mismatched, invalidated or polymorphic constructor cache?");
+    AssertMsg(ctorCache->GetType() != nullptr, "Why did we hard-code a mismatched, invalidated or polymorphic constructor cache?");
 
 #if 0 // TODO: oop jit, add constructor info for tracing
     if (PHASE_TRACE(Js::FixedNewObjPhase, newObjInstr->m_func) || PHASE_TESTTRACE(Js::FixedNewObjPhase, newObjInstr->m_func))
@@ -4703,16 +4703,16 @@ bool Lowerer::TryLowerNewScObjectWithFixedCtorCache(IR::Instr* newObjInstr, IR::
     else
     {
         JITTypeHolder newObjectType(ctorCache->GetType());
-        Assert(newObjectType.t->IsShared());
+        Assert(newObjectType->IsShared());
 
-        IR::AddrOpnd* typeSrc = IR::AddrOpnd::New(newObjectType.t->GetAddr(), IR::AddrOpndKindDynamicType, m_func);
+        IR::AddrOpnd* typeSrc = IR::AddrOpnd::New(newObjectType->GetAddr(), IR::AddrOpndKindDynamicType, m_func);
 
         // For the next call:
         //     inlineSlotSize == Number of slots to allocate beyond the DynamicObject header
         //     slotSize - inlineSlotSize == Number of aux slots to allocate
         int inlineSlotSize = ctorCache->GetInlineSlotCount();
         int slotSize = ctorCache->GetSlotCount();
-        if (newObjectType.t->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler())
+        if (newObjectType->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler())
         {
             Assert(inlineSlotSize >= Js::DynamicTypeHandler::GetObjectHeaderInlinableSlotCapacity());
             Assert(inlineSlotSize == slotSize);
@@ -6897,8 +6897,8 @@ Lowerer::GenerateCachedTypeCheck(IR::Instr *instrChk, IR::PropertySymOpnd *prope
 
     if (typeCheckGuard == nullptr)
     {
-        Assert(type.t != nullptr);
-        expectedTypeOpnd = IR::AddrOpnd::New(type.t->GetAddr(), IR::AddrOpndKindDynamicType, func, true);
+        Assert(type != nullptr);
+        expectedTypeOpnd = IR::AddrOpnd::New(type->GetAddr(), IR::AddrOpndKindDynamicType, func, true);
     }
     else
     {
@@ -7050,7 +7050,7 @@ Lowerer::GenerateCachedTypeWithoutPropertyCheck(IR::Instr *instrInsert, IR::Prop
     JITTypeHolder typeWithoutProperty = propertySymOpnd->GetInitialType();
 
     // We should never add properties to objects of static types.
-    Assert(Js::DynamicType::Is(typeWithoutProperty.t->GetTypeId()));
+    Assert(Js::DynamicType::Is(typeWithoutProperty->GetTypeId()));
 
     if (typeOpnd == nullptr)
     {
@@ -7095,11 +7095,11 @@ Lowerer::GenerateCachedTypeWithoutPropertyCheck(IR::Instr *instrInsert, IR::Prop
         emitDirectCheck = false;
 
         OUTPUT_VERBOSE_TRACE_FUNC(Js::ObjTypeSpecPhase, this->m_func, _u("Emitted %s type check for type 0x%p.\n"),
-            emitDirectCheck ? _u("direct") : _u("indirect"), typeWithoutProperty.t->GetAddr());
+            emitDirectCheck ? _u("direct") : _u("indirect"), typeWithoutProperty->GetAddr());
     }
     else
     {
-        expectedTypeOpnd = IR::AddrOpnd::New(typeWithoutProperty.t->GetAddr(), IR::AddrOpndKindDynamicType, m_func, true);
+        expectedTypeOpnd = IR::AddrOpnd::New(typeWithoutProperty->GetAddr(), IR::AddrOpndKindDynamicType, m_func, true);
     }
 
     InsertCompareBranch(typeOpnd, expectedTypeOpnd, Js::OpCode::BrNeq_A, labelTypeCheckFailed, instrInsert);
@@ -7140,7 +7140,7 @@ Lowerer::CreateTypePropertyGuardForGuardedProperties(JITTypeHolder type, IR::Pro
             {
                 if (guard == nullptr)
                 {
-                    guard = this->m_func->GetOrCreateSingleTypeGuard(type.t->GetAddr());
+                    guard = this->m_func->GetOrCreateSingleTypeGuard(type->GetAddr());
                 }
 
                 if (PHASE_TRACE(Js::ObjTypeSpecPhase, this->m_func) || PHASE_TRACE(Js::TracePropertyGuardsPhase, this->m_func))
@@ -7200,7 +7200,7 @@ Lowerer::CreateEquivalentTypeGuardAndLinkToGuardedProperties(JITTypeHolder type,
     uint16 cachedTypeCount = typeSet->GetCount() < EQUIVALENT_TYPE_CACHE_SIZE ? typeSet->GetCount() : EQUIVALENT_TYPE_CACHE_SIZE;
     for (uint16 ti = 0; ti < cachedTypeCount; ti++)
     {
-        cache->types[ti] = (Js::Type*)typeSet->GetType(ti).t->GetAddr();
+        cache->types[ti] = (Js::Type*)typeSet->GetType(ti)->GetAddr();
     }
 
     // Populate property ID and slot index arrays on the guard's cache. We iterate over the
@@ -7211,7 +7211,7 @@ Lowerer::CreateEquivalentTypeGuardAndLinkToGuardedProperties(JITTypeHolder type,
     auto propOps = propertySymOpnd->GetGuardedPropOps();
     uint propOpCount = propOps->Count();
 
-    bool isTypeStatic = Js::StaticType::Is(type.t->GetTypeId());
+    bool isTypeStatic = Js::StaticType::Is(type->GetTypeId());
     JsUtil::BaseDictionary<Js::PropertyId, Js::EquivalentPropertyEntry*, JitArenaAllocator> propIds(this->m_alloc, propOpCount);
     Js::EquivalentPropertyEntry* properties = AnewArray(this->m_alloc, Js::EquivalentPropertyEntry, propOpCount);
     uint propIdCount = 0;
@@ -7312,7 +7312,7 @@ Lowerer::LinkCtorCacheToGuardedProperties(JITTimeConstructorCache* ctorCache)
                 char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
                 Output::Print(_u("ObjTypeSpec: function %s(%s) registered ctor cache 0x%p with value 0x%p for property %s (%u).\n"),
                     this->m_func->GetJITFunctionBody()->GetDisplayName(), this->m_func->GetDebugNumberSet(debugStringBuffer),
-                    ctorCache->GetRuntimeCacheAddr(), ctorCache->GetType().t->GetAddr(), m_func->GetThreadContextInfo()->GetPropertyRecord(propertyId)->GetBuffer(), propertyId);
+                    ctorCache->GetRuntimeCacheAddr(), ctorCache->GetType()->GetAddr(), m_func->GetThreadContextInfo()->GetPropertyRecord(propertyId)->GetBuffer(), propertyId);
                 Output::Flush();
             }
 
@@ -7431,8 +7431,8 @@ Lowerer::GenerateNonWritablePropertyCheck(IR::Instr *instrInsert, IR::PropertySy
     // If the helper finds a non-writable property, bail out, as we're counting on being able to add the property.
 
     JITTypeHolder typeWithoutProperty(propertySymOpnd->GetInitialType());
-    Assert(typeWithoutProperty.t != nullptr);
-    intptr_t protoAddr = typeWithoutProperty.t->GetPrototypeAddr();
+    Assert(typeWithoutProperty != nullptr);
+    intptr_t protoAddr = typeWithoutProperty->GetPrototypeAddr();
     Assert(protoAddr != 0);
 
     // s1 = MOV [proto->type].ptr
@@ -7482,12 +7482,12 @@ bool
 Lowerer::GenerateAdjustBaseSlots(IR::Instr *instrInsert, IR::RegOpnd *baseOpnd, JITTypeHolder initialType, JITTypeHolder finalType)
 {
     // Possibly allocate new slot capacity to accommodate a type transition.
-    AssertMsg(JITTypeHandler::IsTypeHandlerCompatibleForObjectHeaderInlining(initialType.t->GetTypeHandler(), finalType.t->GetTypeHandler()),
+    AssertMsg(JITTypeHandler::IsTypeHandlerCompatibleForObjectHeaderInlining(initialType->GetTypeHandler(), finalType->GetTypeHandler()),
         "Incompatible typeHandler transition?");
-    int oldCount = initialType.t->GetTypeHandler()->GetSlotCapacity();
-    int newCount = finalType.t->GetTypeHandler()->GetSlotCapacity();
-    Js::PropertyIndex inlineSlotCapacity = initialType.t->GetTypeHandler()->GetInlineSlotCapacity();
-    Js::PropertyIndex newInlineSlotCapacity = finalType.t->GetTypeHandler()->GetInlineSlotCapacity();
+    int oldCount = initialType->GetTypeHandler()->GetSlotCapacity();
+    int newCount = finalType->GetTypeHandler()->GetSlotCapacity();
+    Js::PropertyIndex inlineSlotCapacity = initialType->GetTypeHandler()->GetInlineSlotCapacity();
+    Js::PropertyIndex newInlineSlotCapacity = finalType->GetTypeHandler()->GetInlineSlotCapacity();
 
     if (oldCount >= newCount || newCount <= inlineSlotCapacity)
     {
@@ -7528,11 +7528,11 @@ Lowerer::GenerateFieldStoreWithTypeChange(IR::Instr * instrStFld, IR::PropertySy
     this->GenerateAdjustSlots(instrStFld, propertySymOpnd, initialType, finalType);
 
     // We should never add properties to objects of static types.
-    Assert(Js::DynamicType::Is(finalType.t->GetTypeId()));
+    Assert(Js::DynamicType::Is(finalType->GetTypeId()));
 
     // Let's pin the final type to be sure its alive when we try to do the type transition.
     PinTypeRef(finalType, finalType.t, instrStFld, propertySymOpnd->m_sym->AsPropertySym()->m_propertyId);
-    IR::Opnd *finalTypeOpnd = IR::AddrOpnd::New(finalType.t->GetAddr(), IR::AddrOpndKindDynamicType, instrStFld->m_func, true);
+    IR::Opnd *finalTypeOpnd = IR::AddrOpnd::New(finalType->GetAddr(), IR::AddrOpndKindDynamicType, instrStFld->m_func, true);
 
     // Set the new type.
     IR::RegOpnd *baseOpnd = propertySymOpnd->CreatePropertyOwnerOpnd(instrStFld->m_func);

+ 2 - 0
lib/Backend/NativeCodeGenerator.cpp

@@ -1050,6 +1050,8 @@ NativeCodeGenerator::CodeGen(PageAllocator * pageAllocator, CodeGenWorkItem* wor
 
         epInfo->GetJitTransferData()->SetEquivalentTypeGuardOffsets(jitWriteData.equivalentTypeGuardOffsets);
         epInfo->GetJitTransferData()->SetTypeGuardTransferData(&jitWriteData);
+
+        Assert(jitWriteData.ctorCacheEntries == nullptr || epInfo->GetConstructorCacheCount() > 0);
         epInfo->GetJitTransferData()->SetCtorCacheTransferData(&jitWriteData);
 
         workItem->GetEntryPoint()->GetJitTransferData()->SetIsReady();

+ 24 - 24
lib/Backend/Opnd.cpp

@@ -781,7 +781,7 @@ PropertySymOpnd::CopyWithoutFlowSensitiveInfo(Func *func)
     // an instruction elsewhere in the flow (e.g. field hoisting or copy propagation), these fields cannot be copied.
     // If the caller knows some of them can be safely copied, the caller must do so manually.
     Assert(newOpnd->typeCheckSeqFlags == 0);
-    Assert(newOpnd->finalType.t == nullptr);
+    Assert(newOpnd->finalType == nullptr);
     Assert(newOpnd->guardedPropOps == nullptr);
     Assert(newOpnd->writeGuards == nullptr);
 
@@ -824,9 +824,9 @@ PropertySymOpnd::IsObjectHeaderInlined() const
         type = this->GetFirstEquivalentType();
     }
 
-    if (type.t != nullptr && Js::DynamicType::Is(type.t->GetTypeId()))
+    if (type != nullptr && Js::DynamicType::Is(type->GetTypeId()))
     {
-        return type.t->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler();
+        return type->GetTypeHandler()->IsObjectHeaderInlinedTypeHandler();
     }
 
     return false;
@@ -838,14 +838,14 @@ PropertySymOpnd::ChangesObjectLayout() const
     JITTypeHolder cachedType = this->IsMono() ? this->GetType() : this->GetFirstEquivalentType();
 
     JITTypeHolder finalType = this->GetFinalType();
-    if (finalType.t && Js::DynamicType::Is(finalType.t->GetTypeId()))
+    if (finalType != nullptr && Js::DynamicType::Is(finalType->GetTypeId()))
     {
         // This is the case where final type opt may cause pro-active type transition to take place.
 
-    Assert(cachedType.t != nullptr && Js::DynamicType::Is(cachedType.t->GetTypeId()));
+    Assert(cachedType != nullptr && Js::DynamicType::Is(cachedType->GetTypeId()));
 
-    return cachedType.t->GetTypeHandler()->GetInlineSlotCapacity() != finalType.t->GetTypeHandler()->GetInlineSlotCapacity() ||
-        cachedType.t->GetTypeHandler()->GetOffsetOfInlineSlots() != finalType.t->GetTypeHandler()->GetOffsetOfInlineSlots();
+    return cachedType->GetTypeHandler()->GetInlineSlotCapacity() != finalType->GetTypeHandler()->GetInlineSlotCapacity() ||
+        cachedType->GetTypeHandler()->GetOffsetOfInlineSlots() != finalType->GetTypeHandler()->GetOffsetOfInlineSlots();
     }
 
     if (!this->HasInitialType())
@@ -854,15 +854,15 @@ PropertySymOpnd::ChangesObjectLayout() const
     }
 
     JITTypeHolder initialType = this->GetInitialType();
-    if (initialType.t && Js::DynamicType::Is(initialType.t->GetTypeId()))
+    if (initialType != nullptr && Js::DynamicType::Is(initialType->GetTypeId()))
     {
         // This is the case where the type transition actually occurs. (This is the only case that's detectable
         // during the loop pre-pass, since final types are not in place yet.)
 
-        Assert(cachedType.t && Js::DynamicType::Is(cachedType.t->GetTypeId()));
+        Assert(cachedType != nullptr && Js::DynamicType::Is(cachedType->GetTypeId()));
 
-        const JITTypeHandler * cachedTypeHandler = cachedType.t->GetTypeHandler();
-        const JITTypeHandler * initialTypeHandler = initialType.t->GetTypeHandler();
+        const JITTypeHandler * cachedTypeHandler = cachedType->GetTypeHandler();
+        const JITTypeHandler * initialTypeHandler = initialType->GetTypeHandler();
 
         return cachedTypeHandler->GetInlineSlotCapacity() != initialTypeHandler->GetInlineSlotCapacity() ||
             cachedTypeHandler->GetOffsetOfInlineSlots() != initialTypeHandler->GetOffsetOfInlineSlots();
@@ -880,8 +880,8 @@ PropertySymOpnd::UpdateSlotForFinalType()
     JITTypeHolder cachedType =
         this->IsMono() ? this->GetType() : this->GetEquivalentTypeSet()->GetType(checkedTypeSetIndex);
 
-    Assert(finalType.t != nullptr && Js::DynamicType::Is(finalType.t->GetTypeId()));
-    Assert(cachedType.t != nullptr && Js::DynamicType::Is(cachedType.t->GetTypeId()));
+    Assert(finalType != nullptr && Js::DynamicType::Is(finalType->GetTypeId()));
+    Assert(cachedType != nullptr && Js::DynamicType::Is(cachedType->GetTypeId()));
 
     if (finalType == cachedType)
     {
@@ -889,10 +889,10 @@ PropertySymOpnd::UpdateSlotForFinalType()
     }
 
     // TODO: OOP JIT: should assert about runtime type handler addr 
-    Assert(cachedType.t->GetTypeHandler() != finalType.t->GetTypeHandler());
+    Assert(cachedType->GetTypeHandler() != finalType->GetTypeHandler());
 
-    if (cachedType.t->GetTypeHandler()->GetInlineSlotCapacity() == finalType.t->GetTypeHandler()->GetInlineSlotCapacity() &&
-        cachedType.t->GetTypeHandler()->GetOffsetOfInlineSlots() == finalType.t->GetTypeHandler()->GetOffsetOfInlineSlots())
+    if (cachedType->GetTypeHandler()->GetInlineSlotCapacity() == finalType->GetTypeHandler()->GetInlineSlotCapacity() &&
+        cachedType->GetTypeHandler()->GetOffsetOfInlineSlots() == finalType->GetTypeHandler()->GetOffsetOfInlineSlots())
     {
         // Nothing can change, since the variables aren't changing.
         return;
@@ -902,30 +902,30 @@ PropertySymOpnd::UpdateSlotForFinalType()
     uint16 index = this->GetSlotIndex();
     if (this->UsesAuxSlot())
     {
-        index += cachedType.t->GetTypeHandler()->GetInlineSlotCapacity();
+        index += cachedType->GetTypeHandler()->GetInlineSlotCapacity();
     }
     else
     {
-        index -= cachedType.t->GetTypeHandler()->GetOffsetOfInlineSlots() / sizeof(Js::Var);
+        index -= cachedType->GetTypeHandler()->GetOffsetOfInlineSlots() / sizeof(Js::Var);
     }
 
     // Figure out the slot index and aux-ness from the property index
-    if (index >= finalType.t->GetTypeHandler()->GetInlineSlotCapacity())
+    if (index >= finalType->GetTypeHandler()->GetInlineSlotCapacity())
     {
         this->SetUsesAuxSlot(true);
-        index -= finalType.t->GetTypeHandler()->GetInlineSlotCapacity();
+        index -= finalType->GetTypeHandler()->GetInlineSlotCapacity();
     }
     else
     {
         this->SetUsesAuxSlot(false);
-        index += finalType.t->GetTypeHandler()->GetOffsetOfInlineSlots() / sizeof(Js::Var);
+        index += finalType->GetTypeHandler()->GetOffsetOfInlineSlots() / sizeof(Js::Var);
     }
     this->SetSlotIndex(index);
 }
 
 bool PropertySymOpnd::HasFinalType() const
 {
-    return this->finalType.t != nullptr;
+    return this->finalType != nullptr;
 }
 
 PropertySymOpnd *
@@ -1887,7 +1887,7 @@ AddrOpnd::New(Js::Var address, AddrOpndKind addrOpndKind, Func *func, bool dontE
             Js::Var var = varLocal ? varLocal : address;
             if (
 #if !FLOATVAR
-                !func->IsOOPJIT() && CONFIG_FLAG(OOPJITMissingOpts) &&
+                varLocal || (!func->IsOOPJIT() && CONFIG_FLAG(OOPJITMissingOpts)) &&
 #endif
                 Js::JavascriptNumber::Is_NoTaggedIntCheck(var))
             {
@@ -2791,7 +2791,7 @@ Opnd::Dump(IRDumpFlags flags, Func *func)
             if (propertySymOpnd->HasFinalType())
             {
                 Output::Print(_u(",final:"));
-                this->DumpAddress((void*)propertySymOpnd->GetFinalType().t->GetAddr(), /* printToConsole */ true, /* skipMaskedAddress */ false);
+                this->DumpAddress((void*)propertySymOpnd->GetFinalType()->GetAddr(), /* printToConsole */ true, /* skipMaskedAddress */ false);
             }
             if (propertySymOpnd->GetGuardedPropOps() != nullptr)
             {

+ 2 - 2
lib/Backend/Opnd.h

@@ -679,7 +679,7 @@ public:
 
     bool MustDoMonoCheck() const
     {
-        return this->monoGuardType.t != nullptr;
+        return this->monoGuardType != nullptr;
     }
 
     JITTypeHolder GetMonoGuardType() const
@@ -1036,7 +1036,7 @@ public:
 
     void SetFinalType(JITTypeHolder type)
     {
-        Assert(type.t != nullptr);
+        Assert(type != nullptr);
         this->finalType = type;
     }
 

+ 2 - 2
lib/Backend/ServerThreadContext.h

@@ -32,8 +32,8 @@ public:
     virtual intptr_t GetDebugFrameAddressAddr() const override;
     virtual intptr_t GetDebugScriptIdWhenSetAddr() const override;
 
-    virtual ptrdiff_t GetChakraBaseAddressDifference() const override;
-    virtual ptrdiff_t GetCRTBaseAddressDifference() const override;
+    ptrdiff_t GetChakraBaseAddressDifference() const;
+    ptrdiff_t GetCRTBaseAddressDifference() const;
 
     virtual Js::PropertyRecord const * GetPropertyRecord(Js::PropertyId propertyId) override;
     virtual PreReservedVirtualAllocWrapper * GetPreReservedVirtualAllocator() override;

+ 0 - 1
lib/Common/Memory/PageAllocator.cpp

@@ -1610,7 +1610,6 @@ PageAllocatorBase<T>::ZeroQueuedPages()
         // This helps low-end machines with limited cache size.
         //
 #if defined(_M_IX86) || defined(_M_X64)
-        // TODO: OOP JIT, do we need to do anything for this?
         if (CONFIG_FLAG(ZeroMemoryWithNonTemporalStore) && this->processHandle == GetCurrentProcess())
         {
             js_memset_zero_nontemporal(freePageEntry, AutoSystemInfo::PageSize * pageCount);

+ 0 - 2
lib/Common/Memory/PageAllocator.h

@@ -643,8 +643,6 @@ protected:
     friend class PageSegmentBase<TVirtualAlloc>;
     friend class IdleDecommit;
 
-    void SetProcessHandle(HANDLE hProcess) { processHandle = hProcess; }
-
 protected:
     virtual bool CreateSecondaryAllocator(SegmentBase<TVirtualAlloc>* segment, bool committed, SecondaryAllocator** allocator)
     {

+ 0 - 0
lib/JITClient/JITClient.cpp


+ 52 - 15
lib/JITClient/JITManager.cpp

@@ -29,12 +29,18 @@ JITManager JITManager::s_jitManager = JITManager();
 JITManager::JITManager() :
     m_rpcBindingHandle(nullptr),
     m_oopJitEnabled(false),
+    m_isJITServer(false),
+    m_targetHandle(nullptr),
     m_jitConnectionId()
 {
 }
 
 JITManager::~JITManager()
 {
+    if(m_targetHandle)
+    {
+        CleanupProcess();
+    }
     if (m_rpcBindingHandle)
     {
         RpcBindingFree(&m_rpcBindingHandle);
@@ -169,6 +175,19 @@ JITManager::CreateBinding(
     return S_OK;
 }
 
+bool
+JITManager::IsJITServer() const
+{
+    return m_isJITServer;
+}
+
+void
+JITManager::SetIsJITServer()
+{
+    m_isJITServer = true;
+    m_oopJitEnabled = true;
+}
+
 bool
 JITManager::IsConnected() const
 {
@@ -232,18 +251,36 @@ JITManager::ConnectRpcServer(__in HANDLE jitProcessHandle, __in_opt void* server
     return hr;
 }
 
+HRESULT
+JITManager::CleanupProcess()
+{
+    Assert(JITManager::IsOOPJITEnabled());
+
+    HRESULT hr = E_FAIL;
+    RpcTryExcept
+    {
+        hr = ClientCleanupProcess(m_rpcBindingHandle, (intptr_t)m_targetHandle);
+    }
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
+    {
+        hr = HRESULT_FROM_WIN32(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return hr;
+}
+
 HRESULT
 JITManager::Shutdown()
 {
     HRESULT hr = S_OK;
-
     Assert(IsOOPJITEnabled());
 
     RpcTryExcept
     {
         ClientShutdown(m_rpcBindingHandle);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -265,7 +302,7 @@ JITManager::InitializeThreadContext(
     {
         hr = ClientInitializeThreadContext(m_rpcBindingHandle, data, threadContextInfoAddress, prereservedRegionAddr);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -285,7 +322,7 @@ JITManager::CleanupThreadContext(
     {
         hr = ClientCleanupThreadContext(m_rpcBindingHandle, threadContextInfoAddress);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -307,7 +344,7 @@ JITManager::AddDOMFastPathHelper(
     {
         hr = ClientAddDOMFastPathHelper(m_rpcBindingHandle, scriptContextInfoAddress, funcInfoAddr, helper);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -326,7 +363,7 @@ JITManager::SetIsPRNGSeeded(
     {
         hr = ClientSetIsPRNGSeeded(m_rpcBindingHandle, scriptContextInfoAddress, value);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -349,7 +386,7 @@ JITManager::AddModuleRecordInfo(
     {
         hr = ClientAddModuleRecordInfo(m_rpcBindingHandle, scriptContextInfoAddress, moduleId, localExportSlotsAddr);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -372,7 +409,7 @@ JITManager::SetWellKnownHostTypeId(
     {
         hr = ClientSetWellKnownHostTypeId(m_rpcBindingHandle, threadContextRoot, typeId);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -395,7 +432,7 @@ JITManager::AddPropertyRecordArray(
     {
         hr = ClientAddPropertyRecordArray(m_rpcBindingHandle, threadContextInfoAddress, count, propertyRecordArray);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -416,7 +453,7 @@ JITManager::InitializeScriptContext(
     {
         hr = ClientInitializeScriptContext(m_rpcBindingHandle, data, scriptContextInfoAddress);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -436,7 +473,7 @@ JITManager::CleanupScriptContext(
     {
         hr = ClientCleanupScriptContext(m_rpcBindingHandle, scriptContextInfoAddress);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -456,7 +493,7 @@ JITManager::CloseScriptContext(
     {
         hr = ClientCloseScriptContext(m_rpcBindingHandle, scriptContextInfoAddress);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -477,7 +514,7 @@ JITManager::FreeAllocation(
     {
         hr = ClientFreeAllocation(m_rpcBindingHandle, threadContextInfoAddress, address);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -499,7 +536,7 @@ JITManager::IsNativeAddr(
     {
         hr = ClientIsNativeAddr(m_rpcBindingHandle, threadContextInfoAddress, address, result);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }
@@ -522,7 +559,7 @@ JITManager::RemoteCodeGenCall(
     {
         hr = ClientRemoteCodeGen(m_rpcBindingHandle, threadContextInfoAddress, scriptContextInfoAddress, workItemData, jitData);
     }
-        RpcExcept(1)
+        RpcExcept(RpcExceptionFilter(RpcExceptionCode()))
     {
         hr = HRESULT_FROM_WIN32(RpcExceptionCode());
     }

+ 6 - 1
lib/JITClient/JITManager.h

@@ -11,6 +11,8 @@ public:
     HRESULT ConnectRpcServer(__in HANDLE jitProcessHandle, __in_opt void* serverSecurityDescriptor, __in UUID connectionUuid);
 
     bool IsConnected() const;
+    bool IsJITServer() const;
+    void SetIsJITServer();
     bool IsOOPJITEnabled() const;
     void EnableOOPJIT();
 
@@ -47,6 +49,8 @@ public:
         __in ScriptContextDataIDL * data,
         __out intptr_t *scriptContextInfoAddress);
 
+    HRESULT CleanupProcess();
+
     HRESULT CleanupScriptContext(
         __in intptr_t scriptContextInfoAddress);
 
@@ -79,7 +83,7 @@ private:
     JITManager();
     ~JITManager();
 
-    HRESULT JITManager::CreateBinding(
+    HRESULT CreateBinding(
         __in HANDLE serverProcessHandle,
         __in_opt void* serverSecurityDescriptor,
         __in UUID* connectionUuid,
@@ -89,6 +93,7 @@ private:
     HANDLE m_targetHandle;
     UUID m_jitConnectionId;
     bool m_oopJitEnabled;
+    bool m_isJITServer;
 
     static JITManager s_jitManager;
 };

+ 4 - 0
lib/JITIDL/ChakraJIT.idl

@@ -19,6 +19,10 @@ interface IChakraJIT
         [out] CHAKRA_PTR * threadContextInfoAddress,
         [out] CHAKRA_PTR * prereservedRegionAddr);
 
+    HRESULT CleanupProcess(
+        [in] handle_t binding,
+        [in] CHAKRA_PTR processHandle);
+
     HRESULT CleanupThreadContext(
         [in] handle_t binding,
         [in] CHAKRA_PTR threadContextInfoAddress);

+ 36 - 20
lib/JITIDL/JITTypes.h

@@ -23,7 +23,7 @@ import "wtypes.idl";
 #define IDL_DEF(def)
 #endif
 
-#if defined(_M_X64) && defined(__midl)
+#if defined(__midl)
 #define IDL_PAD1(num) byte struct_pad_##num;
 #define IDL_PAD2(num) short struct_pad_##num;
 #define IDL_PAD4(num) int struct_pad_##num;
@@ -33,6 +33,18 @@ import "wtypes.idl";
 #define IDL_PAD4(num)
 #endif
 
+#if defined(__midl) && (defined(_M_X64) || defined(_M_ARM64))
+#define X64_PAD4(num) int struct_pad_##num;
+#else
+#define X64_PAD4(num)
+#endif
+
+#if defined(__midl) && (defined(_M_IX86) || defined(_M_ARM))
+#define X86_PAD4(num) int struct_pad_##num;
+#else
+#define X86_PAD4(num)
+#endif
+
 #ifndef __midl
 #ifndef _MSC_VER
 typedef unsigned char boolean;
@@ -41,7 +53,7 @@ typedef unsigned char boolean;
 
 // TODO: OOP JIT, how do we make this better?
 const int VTABLE_COUNT = 47;
-const int EQUIVALENT_TYPE_CACHE_SIZE_IDL = 8;
+const int EQUIVALENT_TYPE_CACHE_SIZE = 8;
 
 typedef struct TypeHandlerIDL
 {
@@ -51,7 +63,7 @@ typedef struct TypeHandlerIDL
     unsigned short inlineSlotCapacity;
     unsigned short offsetOfInlineSlots;
     IDL_PAD2(0)
-    IDL_PAD4(1)
+    X64_PAD4(1)
     int slotCapacity;
 } TypeHandlerIDL;
 
@@ -76,7 +88,7 @@ typedef struct EquivalentTypeSetIDL
     boolean sortedAndDuplicatesRemoved;
     IDL_PAD1(0)
     unsigned short count;
-    IDL_PAD4(1)
+    X64_PAD4(1)
     IDL_DEF([size_is(count)]) TypeIDL ** types;
 } EquivalentTypeSetIDL;
 
@@ -104,7 +116,7 @@ typedef struct JITTimeConstructorCacheIDL
     IDL_PAD2(0)
     int slotCount;
 
-    IDL_PAD4(1)
+    X64_PAD4(1)
     TypeIDL type;
 
     CHAKRA_PTR runtimeCacheAddr;
@@ -150,7 +162,7 @@ typedef struct BVUnitIDL
 typedef struct BVFixedIDL
 {
     unsigned int len;
-    IDL_PAD4(0)
+    X64_PAD4(0)
     IDL_DEF([size_is(((len - 1) >> BV_SHIFT) + 1)]) BVUnitIDL data[IDL_DEF(*)];
 } BVFixedIDL;
 
@@ -194,12 +206,14 @@ typedef struct LdElemIDL
     unsigned short arrayType;
     unsigned short elemType;
     byte bits;
+    IDL_PAD1(0)
 } LdElemIDL;
 
 typedef struct StElemIDL
 {
     unsigned short arrayType;
     byte bits;
+    IDL_PAD1(0)
 } StElemIDL;
 
 typedef struct ProfileDataIDL
@@ -209,7 +223,6 @@ typedef struct ProfileDataIDL
 
     ThisIDL thisData;
 
-
     unsigned short profiledLdElemCount;
     unsigned short profiledStElemCount;
     unsigned short profiledArrayCallSiteCount;
@@ -260,8 +273,8 @@ typedef struct ThreadContextDataIDL
     boolean isThreadBound;
     boolean allowPrereserveAlloc;
 
-    IDL_PAD2(1)
-    IDL_PAD4(2)
+    IDL_PAD2(0)
+    X64_PAD4(1)
     CHAKRA_PTR processHandle;
     CHAKRA_PTR chakraBaseAddress;
     CHAKRA_PTR crtBaseAddress;
@@ -323,7 +336,7 @@ typedef struct SmallSpanSequenceIDL
     int baseValue;
     unsigned int statementLength;
     IDL_DEF([size_is(statementLength)]) unsigned int * statementBuffer;
-    IDL_PAD4(1)
+    X64_PAD4(1)
     unsigned int actualOffsetLength; // REVIEW: are lengths the same?
     IDL_DEF([size_is(actualOffsetLength)]) unsigned int * actualOffsetList;
 } SmallSpanSequenceIDL;
@@ -394,7 +407,7 @@ typedef struct PropertyRecordIDL
 typedef struct FunctionJITRuntimeIDL
 {
     unsigned int clonedCacheCount;
-    IDL_PAD4(0)
+    X64_PAD4(0)
     IDL_DEF([size_is(clonedCacheCount)]) CHAKRA_PTR * clonedInlineCaches;
 } FunctionJITRuntimeIDL;
 
@@ -438,7 +451,7 @@ typedef struct RecyclableObjectIDL
 typedef struct ConstTableContentIDL
 {
     unsigned int count;
-    IDL_PAD4(0)
+    X64_PAD4(0)
     IDL_DEF([size_is(count)]) RecyclableObjectIDL** content;
 } ConstTableContentIDL;
 
@@ -512,7 +525,7 @@ typedef struct FunctionBodyDataIDL
     unsigned int fullStatementMapCount;
     unsigned int propertyIdsForRegSlotsCount;
 
-    IDL_PAD4(1)
+    X64_PAD4(1)
 
     IDL_DEF([size_is(propertyIdsForRegSlotsCount)]) int * propertyIdsForRegSlots;
 
@@ -583,7 +596,7 @@ typedef struct FunctionJITTimeDataIDL
 
     IDL_DEF([size_is(ldFldInlineeCount)]) struct FunctionJITTimeDataIDL ** ldFldInlinees;
 
-    IDL_PAD4(1)
+    X64_PAD4(1)
     unsigned int objTypeSpecFldInfoCount;
     IDL_DEF([size_is(objTypeSpecFldInfoCount)]) ObjTypeSpecFldIDL * objTypeSpecFldInfoArray;
 
@@ -613,7 +626,7 @@ typedef struct PolymorphicInlineCacheIDL
 {
     unsigned short size;
     IDL_PAD2(0)
-    IDL_PAD4(1)
+    X64_PAD4(1)
     CHAKRA_PTR addr;
     CHAKRA_PTR inlineCachesAddr;
 } PolymorphicInlineCacheIDL;
@@ -667,14 +680,14 @@ typedef struct NativeDataFixupRecord
     unsigned int index;
     unsigned int length;
     unsigned int startOffset;
-    IDL_PAD4(0)
+    X64_PAD4(0)
     struct NativeDataFixupEntry* updateList;
 } NativeDataFixupRecord;
 
 typedef struct NativeDataFixupTable
 {
     unsigned int count;
-    IDL_PAD4(0)
+    X64_PAD4(0)
     IDL_DEF([size_is(count)]) NativeDataFixupRecord fixupRecords[IDL_DEF(*)];
 } NativeDataFixupTable;
 
@@ -687,12 +700,13 @@ typedef struct TypeEquivalenceRecordIDL
 
 typedef struct EquivlentTypeCacheIDL
 {
-    CHAKRA_PTR types[EQUIVALENT_TYPE_CACHE_SIZE_IDL];
+    CHAKRA_PTR types[EQUIVALENT_TYPE_CACHE_SIZE];
     CHAKRA_PTR guardOffset;
     struct TypeEquivalenceRecordIDL record;
     unsigned int nextEvictionVictim;
     boolean isLoadedFromProto;
     boolean hasFixedValue;
+    IDL_PAD2(0)
 } EquivlentTypeCacheIDL;
 
 typedef struct EquivalentTypeGuardIDL
@@ -705,7 +719,7 @@ typedef struct EquivalentTypeGuardIDL
 typedef struct EquivalentTypeGuardOffsets
 {
     unsigned int count;
-    IDL_PAD4(0)
+    X64_PAD4(0)
     IDL_DEF([size_is(count)]) EquivalentTypeGuardIDL guards[IDL_DEF(*)];
 
 } EquivalentTypeGuardOffsets;
@@ -729,6 +743,8 @@ typedef struct NativeDataBuffer
 {
     unsigned int len;
     unsigned int unused;
+    IDL_PAD2(0)
+    IDL_PAD1(1)
     IDL_DEF([size_is(len)]) byte data[IDL_DEF(*)];
 } NativeDataBuffer;
 
@@ -779,6 +795,6 @@ typedef struct JITOutputIDL
     NativeDataBuffer* buffer;
     EquivalentTypeGuardOffsets* equivalentTypeGuardOffsets;
     XProcNumberPageSegment* numberPageSegments;
-
+    X86_PAD4(1)
     __int64 startTime;
 } JITOutputIDL;

+ 10 - 1
lib/JITServer/JITServer.cpp

@@ -69,7 +69,7 @@ HRESULT JsInitializeJITServer(
     {
         return status;
     }
-    JITManager::GetJITManager()->EnableOOPJIT();
+    JITManager::GetJITManager()->SetIsJITServer();
 
     status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE);
 
@@ -113,6 +113,15 @@ ServerShutdown(
     return ShutdownCommon();
 }
 
+HRESULT
+ServerCleanupProcess(
+    /* [in] */ handle_t binding,
+    /* [in] */ intptr_t processHandle)
+{
+    CloseHandle((HANDLE)processHandle);
+    return S_OK;
+}
+
 HRESULT
 ServerInitializeThreadContext(
     /* [in] */ handle_t binding,

+ 0 - 17
lib/Runtime/Base/FunctionBody.h

@@ -188,9 +188,6 @@ namespace Js
         CtorCacheGuardTransferEntry(): propertyId(Js::Constants::NoProperty) {}
     };
 
-
-#define EQUIVALENT_TYPE_CACHE_SIZE (EQUIVALENT_TYPE_CACHE_SIZE_IDL)
-
     struct EquivalentTypeCache
     {
         Js::Type* types[EQUIVALENT_TYPE_CACHE_SIZE];
@@ -207,13 +204,6 @@ namespace Js
         bool IsLoadedFromProto() const { return this->isLoadedFromProto; }
         void SetHasFixedValue() { this->hasFixedValue = true; }
         bool HasFixedValue() const { return this->hasFixedValue; }
-
-#if ENABLE_NATIVE_CODEGEN
-        void Fixup(NativeCodeData::DataChunk* chunkList)
-        {
-            Assert(false); // not implemented yet
-        }
-#endif
     };
 
     class JitEquivalentTypeGuard : public JitIndexedPropertyGuard
@@ -268,13 +258,6 @@ namespace Js
         {
             this->cache = cache;
         }
-
-#if ENABLE_NATIVE_CODEGEN
-        void Fixup(NativeCodeData::DataChunk* chunkList)
-        {
-            // cache will be recycler allocated pointer
-        }
-#endif
     };
 
 #pragma region Inline Cache Info class declarations

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

@@ -1303,8 +1303,8 @@ public:
     virtual intptr_t GetDebugFrameAddressAddr() const override;
     virtual intptr_t GetDebugScriptIdWhenSetAddr() const override;
 
-    virtual ptrdiff_t GetChakraBaseAddressDifference() const override;
-    virtual ptrdiff_t GetCRTBaseAddressDifference() const override;
+    ptrdiff_t GetChakraBaseAddressDifference() const;
+    ptrdiff_t GetCRTBaseAddressDifference() const;
 
 private:
     void RegisterInlineCache(InlineCacheListMapByPropertyId& inlineCacheMap, Js::InlineCache* inlineCache, Js::PropertyId propertyId);

+ 25 - 2
lib/Runtime/Base/ThreadContextInfo.cpp

@@ -5,6 +5,11 @@
 
 #include "RuntimeBasePch.h"
 
+#if ENABLE_NATIVE_CODEGEN
+#include "CodeGenAllocators.h"
+#include "ServerThreadContext.h"
+#endif
+
 ThreadContextInfo::ThreadContextInfo() :
     m_isAllJITCodeInPreReservedRegion(true),
     wellKnownHostTypeHTMLAllCollectionTypeId(Js::TypeIds_Undefined),
@@ -364,7 +369,16 @@ intptr_t SHIFT_ADDR(const ThreadContextInfo*const context, intptr_t address)
 {
 #if ENABLE_NATIVE_CODEGEN
     Assert(AutoSystemInfo::Data.IsJscriptModulePointer((void*)address));
-    return (intptr_t)address + context->GetChakraBaseAddressDifference();
+    ptrdiff_t diff = 0;
+    if (JITManager::GetJITManager()->IsJITServer())
+    {
+        diff = ((ServerThreadContext*)context)->GetChakraBaseAddressDifference();
+    }
+    else
+    {
+        diff = ((ThreadContext*)context)->GetChakraBaseAddressDifference();
+    }
+    return (intptr_t)address + diff;
 #else
     return address;
 #endif
@@ -379,7 +393,16 @@ intptr_t SHIFT_CRT_ADDR(const ThreadContextInfo*const context, intptr_t address)
         // the function is compiled to chakra.dll, or statically linked to crt 
         return SHIFT_ADDR(context, address);
     }
-    return (intptr_t)address + context->GetCRTBaseAddressDifference();
+    ptrdiff_t diff = 0;
+    if (JITManager::GetJITManager()->IsJITServer())
+    {
+        diff = ((ServerThreadContext*)context)->GetCRTBaseAddressDifference();
+    }
+    else
+    {
+        diff = ((ThreadContext*)context)->GetCRTBaseAddressDifference();
+    }
+    return (intptr_t)address + diff;
 #else
     return address;
 #endif

+ 2 - 19
lib/Runtime/Base/ThreadContextInfo.h

@@ -94,9 +94,6 @@ public:
     virtual intptr_t GetDebugFrameAddressAddr() const = 0;
     virtual intptr_t GetDebugScriptIdWhenSetAddr() const = 0;
 
-    virtual ptrdiff_t GetChakraBaseAddressDifference() const = 0;
-    virtual ptrdiff_t GetCRTBaseAddressDifference() const = 0;
-
     virtual Js::PropertyRecord const * GetPropertyRecord(Js::PropertyId propertyId) = 0;
 
     bool CanBeFalsy(Js::TypeId typeId) { return typeId == this->wellKnownHostTypeHTMLAllCollectionTypeId; }
@@ -125,28 +122,14 @@ private:
 template<typename T>
 intptr_t SHIFT_ADDR(const ThreadContextInfo*const context, T* address)
 {
-#if ENABLE_NATIVE_CODEGEN
-    Assert(AutoSystemInfo::Data.IsJscriptModulePointer((void*)address));
-    return (intptr_t)address + context->GetChakraBaseAddressDifference();
-#else
-    return (intptr_t)address;
-#endif
+    return SHIFT_ADDR(context, (intptr_t)address);
 }
 
 
 template<typename T>
 intptr_t SHIFT_CRT_ADDR(const ThreadContextInfo*const context, T* address)
 {
-#if ENABLE_NATIVE_CODEGEN
-    if (AutoSystemInfo::Data.IsJscriptModulePointer((void*)address))
-    {
-        // the function is compiled to chakra.dll, or statically linked to crt 
-        return SHIFT_ADDR(context, address);
-    }
-    return (intptr_t)address + context->GetCRTBaseAddressDifference();
-#else
-return (intptr_t)address;
-#endif
+    return SHIFT_CRT_ADDR(context, (intptr_t)address);
 }
 
 

+ 3 - 0
lib/Runtime/Language/InlineCache.cpp

@@ -3,7 +3,10 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #include "RuntimeLanguagePch.h"
+
+#if ENABLE_NATIVE_CODEGEN
 #include "JITType.h"
+#endif
 
 namespace Js
 {

+ 3 - 1
lib/Runtime/Language/JavascriptOperators.cpp

@@ -4983,7 +4983,9 @@ CommonNumber:
     {
         if (! JavascriptOperators::IsObjectType(typeId) && ! JavascriptOperators::IsUndefinedOrNullType(typeId))
         {
-            // OOP JIT code path should not get here
+#if ENABLE_NATIVE_CODEGEN
+            Assert(!JITManager::GetJITManager()->IsJITServer());
+#endif
 #if !FLOATVAR
             // We allowed stack number to be used as the "this" for getter and setter activation of
             // n.x and n[prop], where n is the Javascript Number

+ 2 - 1
lib/Runtime/Language/ObjTypeSpecFldInfo.cpp

@@ -4,10 +4,11 @@
 //-------------------------------------------------------------------------------------------------------
 #include "RuntimeLanguagePch.h"
 
+#if ENABLE_NATIVE_CODEGEN
+
 #include "JITType.h"
 #include "JITTimeConstructorCache.h"
 
-#if ENABLE_NATIVE_CODEGEN
 namespace Js
 {
     ObjTypeSpecFldInfo* ObjTypeSpecFldInfo::CreateFrom(uint id, InlineCache* cache, uint cacheId, EntryPointInfo *entryPoint,

+ 1 - 0
lib/Runtime/Library/JavascriptNumber.inl

@@ -24,6 +24,7 @@ namespace Js
 #endif
     ) : RecyclableObject(type), m_value(value)
     {
+        // for oopjit type will be pointing to address of StaticType on other proc, so don't dereference it
         Assert(oopJIT || type->GetTypeId() == TypeIds_Number);
     }
 #endif

+ 3 - 1
lib/Runtime/Types/RecyclableObject.cpp

@@ -108,7 +108,9 @@ namespace Js
 #endif
 #endif
 #if DBG || defined(PROFILE_TYPES)
-        if (false) // In-proc JIT
+#if ENABLE_NATIVE_CODEGEN
+        if (!JITManager::GetJITManager()->IsOOPJITEnabled())
+#endif
         {
             RecordAllocation(type->GetScriptContext());
         }

+ 0 - 10
test/Miscellaneous/rlexe.xml

@@ -35,16 +35,6 @@
       <tags>exclude_amd64,fail</tags>
     </default>
   </test>
-<!--
-  <test>
-    <default>
-      <files>irviewer.js</files>
-      <baseline>irviewer.baseline</baseline>
-      <compile-flags>-irviewer</compile-flags>
-      <tags>exclude_amd64,exclude_fre,exclude_arm,exclude_nonative,require_backend</tags>
-    </default>
-  </test>
--->
   <test>
     <default>
       <files>SetTimeout.js</files>