Quellcode durchsuchen

[1.4>master] [MERGE #2531 @satheeshravi] Fixing !ldsym in jd for OOPjit

Merge pull request #2531 from satheeshravi:release1.4_ChakraDiag

We don't register the native addresses and interpreter thunk addresses for OOPjit scenarios - since the allocations linked list is not populated by the runtime process.

Fix:
Used the cache that we now populate on the script context to register the address.
For interpreter thunk emitter - we use the thunkBlocks linked list.
Satheesh Ravindranath vor 9 Jahren
Ursprung
Commit
a8768d36eb

+ 6 - 0
lib/Backend/InterpreterThunkEmitter.cpp

@@ -244,6 +244,12 @@ InterpreterThunkEmitter::InterpreterThunkEmitter(Js::ScriptContext* context, Are
 {
 }
 
+SListBase<ThunkBlock>* 
+InterpreterThunkEmitter::GetThunkBlocksList()
+{
+    return &thunkBlocks;
+}
+
 //
 // Returns the next thunk. Batch allocated PageCount pages of thunks and issue them one at a time
 //

+ 1 - 0
lib/Backend/InterpreterThunkEmitter.h

@@ -132,6 +132,7 @@ public:
 
     InterpreterThunkEmitter(Js::ScriptContext * context, ArenaAllocator* allocator, CustomHeap::InProcCodePageAllocators * codePageAllocators, bool isAsmInterpreterThunk = false);
     BYTE* GetNextThunk(PVOID* ppDynamicInterpreterThunk);
+    SListBase<ThunkBlock>* GetThunkBlocksList();
 
     void Close();
     void Release(BYTE* thunkAddress, bool addtoFreeList);

+ 5 - 1
lib/Common/DataStructures/SList.h

@@ -60,7 +60,11 @@ class SListNode : public SListNodeBase<TAllocator>
 {
     friend class SListBase<TData, TAllocator, FakeCount>;
     friend class SListBase<TData, TAllocator, RealCount>;
-
+public:
+    TData* GetData()
+    {
+        return &data;
+    }
 private:
     SListNode() : data() {}
 

+ 11 - 0
lib/Runtime/Base/ScriptContext.cpp

@@ -6133,4 +6133,15 @@ void ScriptContext::RegisterPrototypeChainEnsuredToHaveOnlyWritableDataPropertie
             return (key <= address && (uintptr_t)address < ((uintptr_t)key + value));
         });
     }
+
+    JITPageAddrToFuncRangeCache::JITPageAddrToFuncRangeMap * JITPageAddrToFuncRangeCache::GetJITPageAddrToFuncRangeMap()
+    {
+        return jitPageAddrToFuncRangeMap;
+    }
+    
+    JITPageAddrToFuncRangeCache::LargeJITFuncAddrToSizeMap * JITPageAddrToFuncRangeCache::GetLargeJITFuncAddrToSizeMap()
+    {
+        return largeJitFuncToSizeMap;
+    }
+
 } // End namespace Js

+ 4 - 1
lib/Runtime/Base/ScriptContext.h

@@ -420,11 +420,12 @@ namespace Js
     */
     class JITPageAddrToFuncRangeCache
     {
-    private:
+    public:
         typedef JsUtil::BaseDictionary<void *, uint, HeapAllocator> RangeMap;
         typedef JsUtil::BaseDictionary<void *, RangeMap*, HeapAllocator> JITPageAddrToFuncRangeMap;
         typedef JsUtil::BaseDictionary<void *, uint, HeapAllocator> LargeJITFuncAddrToSizeMap;
 
+    private:
         JITPageAddrToFuncRangeMap * jitPageAddrToFuncRangeMap;
         LargeJITFuncAddrToSizeMap * largeJitFuncToSizeMap;
 
@@ -441,6 +442,8 @@ namespace Js
         void RemoveFuncRange(void * address);
         void * GetPageAddr(void * address);
         bool IsNativeAddr(void * address);
+        JITPageAddrToFuncRangeMap * GetJITPageAddrToFuncRangeMap();
+        LargeJITFuncAddrToSizeMap * GetLargeJITFuncAddrToSizeMap();
         static CriticalSection * GetCriticalSection() { return &cs; }
     };
 

+ 22 - 28
lib/Runtime/Base/ThreadContext.cpp

@@ -4081,6 +4081,25 @@ void DumpRecyclerObjectGraph()
 #endif
 
 #if ENABLE_NATIVE_CODEGEN
+bool ThreadContext::IsNativeAddressHelper(void * pCodeAddr, Js::ScriptContext* currentScriptContext)
+{
+    bool isNativeAddr = false;
+    if (currentScriptContext && currentScriptContext->GetJitFuncRangeCache() != nullptr)
+    {
+        isNativeAddr = currentScriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
+    }
+
+    for (Js::ScriptContext *scriptContext = scriptContextList; scriptContext && !isNativeAddr; scriptContext = scriptContext->next)
+    {
+        if (scriptContext == currentScriptContext || scriptContext->GetJitFuncRangeCache() == nullptr)
+        {
+            continue;
+        }
+        isNativeAddr = scriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
+    }
+    return isNativeAddr;
+}
+
 BOOL ThreadContext::IsNativeAddress(void * pCodeAddr, Js::ScriptContext* currentScriptContext)
 {
 #if ENABLE_OOP_NATIVE_CODEGEN
@@ -4104,24 +4123,9 @@ BOOL ThreadContext::IsNativeAddress(void * pCodeAddr, Js::ScriptContext* current
         HRESULT hr = JITManager::GetJITManager()->IsNativeAddr(this->m_remoteThreadContextInfo, (intptr_t)pCodeAddr, &result);
         JITManager::HandleServerCallResult(hr, RemoteCallType::HeapQuery);
 #endif
-
-        bool isNativeAddr = false;
-        if (currentScriptContext && currentScriptContext->GetJitFuncRangeCache() != nullptr)
-        {
-            isNativeAddr = currentScriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
-        }
-
-        for (Js::ScriptContext *scriptContext = scriptContextList; scriptContext && !isNativeAddr; scriptContext = scriptContext->next)
-        {
-            if (scriptContext->GetJitFuncRangeCache() == nullptr || scriptContext == currentScriptContext)
-            {
-                continue;
-            }
-            isNativeAddr = scriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
-        }
-
+        bool isNativeAddr = IsNativeAddressHelper(pCodeAddr, currentScriptContext);
 #if DBG
-        Assert(result == (isNativeAddr? 1:0));
+        Assert(result == (isNativeAddr? TRUE:FALSE));
 #endif
         return isNativeAddr;
     }
@@ -4139,17 +4143,7 @@ BOOL ThreadContext::IsNativeAddress(void * pCodeAddr, Js::ScriptContext* current
 #if DBG
             AutoCriticalSection autoLock(&this->codePageAllocators.cs);
 #endif
-            
-            bool isNativeAddr = false;
-            for (Js::ScriptContext *scriptContext = scriptContextList; scriptContext && !isNativeAddr; scriptContext = scriptContext->next)
-            {
-                if (scriptContext->GetJitFuncRangeCache() == nullptr)
-                {
-                    continue;
-                }
-                isNativeAddr = scriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
-            }
-
+            bool isNativeAddr = IsNativeAddressHelper(pCodeAddr, currentScriptContext);
 #if DBG
             Assert(this->codePageAllocators.IsInNonPreReservedPageAllocator(pCodeAddr) == isNativeAddr);
 #endif

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

@@ -1181,6 +1181,7 @@ public:
     void RegisterCodeGenRecyclableData(Js::CodeGenRecyclableData *const codeGenRecyclableData);
     void UnregisterCodeGenRecyclableData(Js::CodeGenRecyclableData *const codeGenRecyclableData);
 #if ENABLE_NATIVE_CODEGEN
+    bool IsNativeAddressHelper(void * pCodeAddr, Js::ScriptContext* currentScriptContext);
     BOOL IsNativeAddress(void * pCodeAddr, Js::ScriptContext* currentScriptContext = nullptr);
     JsUtil::JobProcessor *GetJobProcessor();
     Js::Var * GetBailOutRegisterSaveSpace() const { return bailOutRegisterSaveSpace; }