Skip to content

Commit d624f76

Browse files
committed
Fixing !ldsym in jd for OOPjit
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.
1 parent f54dfc0 commit d624f76

7 files changed

Lines changed: 50 additions & 29 deletions

File tree

lib/Backend/InterpreterThunkEmitter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ InterpreterThunkEmitter::InterpreterThunkEmitter(Js::ScriptContext* context, Are
244244
{
245245
}
246246

247+
SListBase<ThunkBlock>*
248+
InterpreterThunkEmitter::GetThunkBlocksList()
249+
{
250+
return &thunkBlocks;
251+
}
252+
247253
//
248254
// Returns the next thunk. Batch allocated PageCount pages of thunks and issue them one at a time
249255
//

lib/Backend/InterpreterThunkEmitter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class InterpreterThunkEmitter
132132

133133
InterpreterThunkEmitter(Js::ScriptContext * context, ArenaAllocator* allocator, CustomHeap::InProcCodePageAllocators * codePageAllocators, bool isAsmInterpreterThunk = false);
134134
BYTE* GetNextThunk(PVOID* ppDynamicInterpreterThunk);
135+
SListBase<ThunkBlock>* GetThunkBlocksList();
135136

136137
void Close();
137138
void Release(BYTE* thunkAddress, bool addtoFreeList);

lib/Common/DataStructures/SList.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class SListNode : public SListNodeBase<TData>
6363
{
6464
friend class SListBase<TData, FakeCount>;
6565
friend class SListBase<TData, RealCount>;
66+
public:
67+
TData* GetData()
68+
{
69+
return &data;
70+
}
6671
private:
6772

6873
SListNode() : data() {}

lib/Runtime/Base/ScriptContext.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6045,4 +6045,15 @@ void ScriptContext::RegisterPrototypeChainEnsuredToHaveOnlyWritableDataPropertie
60456045
return (key <= address && (uintptr_t)address < ((uintptr_t)key + value));
60466046
});
60476047
}
6048+
6049+
JITPageAddrToFuncRangeCache::JITPageAddrToFuncRangeMap * JITPageAddrToFuncRangeCache::GetJITPageAddrToFuncRangeMap()
6050+
{
6051+
return jitPageAddrToFuncRangeMap;
6052+
}
6053+
6054+
JITPageAddrToFuncRangeCache::LargeJITFuncAddrToSizeMap * JITPageAddrToFuncRangeCache::GetLargeJITFuncAddrToSizeMap()
6055+
{
6056+
return largeJitFuncToSizeMap;
6057+
}
6058+
60486059
} // End namespace Js

lib/Runtime/Base/ScriptContext.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,12 @@ namespace Js
383383
*/
384384
class JITPageAddrToFuncRangeCache
385385
{
386-
private:
386+
public:
387387
typedef JsUtil::BaseDictionary<void *, uint, HeapAllocator> RangeMap;
388388
typedef JsUtil::BaseDictionary<void *, RangeMap*, HeapAllocator> JITPageAddrToFuncRangeMap;
389389
typedef JsUtil::BaseDictionary<void *, uint, HeapAllocator> LargeJITFuncAddrToSizeMap;
390390

391+
private:
391392
JITPageAddrToFuncRangeMap * jitPageAddrToFuncRangeMap;
392393
LargeJITFuncAddrToSizeMap * largeJitFuncToSizeMap;
393394

@@ -404,6 +405,8 @@ namespace Js
404405
void RemoveFuncRange(void * address);
405406
void * GetPageAddr(void * address);
406407
bool IsNativeAddr(void * address);
408+
JITPageAddrToFuncRangeMap * GetJITPageAddrToFuncRangeMap();
409+
LargeJITFuncAddrToSizeMap * GetLargeJITFuncAddrToSizeMap();
407410
static CriticalSection * GetCriticalSection() { return &cs; }
408411
};
409412

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4080,6 +4080,25 @@ void DumpRecyclerObjectGraph()
40804080
#endif
40814081

40824082
#if ENABLE_NATIVE_CODEGEN
4083+
bool ThreadContext::IsNativeAddressHelper(void * pCodeAddr, Js::ScriptContext* currentScriptContext)
4084+
{
4085+
bool isNativeAddr = false;
4086+
if (currentScriptContext && currentScriptContext->GetJitFuncRangeCache() != nullptr)
4087+
{
4088+
isNativeAddr = currentScriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
4089+
}
4090+
4091+
for (Js::ScriptContext *scriptContext = scriptContextList; scriptContext && !isNativeAddr; scriptContext = scriptContext->next)
4092+
{
4093+
if (scriptContext == currentScriptContext || scriptContext->GetJitFuncRangeCache() == nullptr)
4094+
{
4095+
continue;
4096+
}
4097+
isNativeAddr = scriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
4098+
}
4099+
return isNativeAddr;
4100+
}
4101+
40834102
BOOL ThreadContext::IsNativeAddress(void * pCodeAddr, Js::ScriptContext* currentScriptContext)
40844103
{
40854104
#if ENABLE_OOP_NATIVE_CODEGEN
@@ -4103,24 +4122,9 @@ BOOL ThreadContext::IsNativeAddress(void * pCodeAddr, Js::ScriptContext* current
41034122
HRESULT hr = JITManager::GetJITManager()->IsNativeAddr(this->m_remoteThreadContextInfo, (intptr_t)pCodeAddr, &result);
41044123
JITManager::HandleServerCallResult(hr, RemoteCallType::HeapQuery);
41054124
#endif
4106-
4107-
bool isNativeAddr = false;
4108-
if (currentScriptContext && currentScriptContext->GetJitFuncRangeCache() != nullptr)
4109-
{
4110-
isNativeAddr = currentScriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
4111-
}
4112-
4113-
for (Js::ScriptContext *scriptContext = scriptContextList; scriptContext && !isNativeAddr; scriptContext = scriptContext->next)
4114-
{
4115-
if (scriptContext->GetJitFuncRangeCache() == nullptr || scriptContext == currentScriptContext)
4116-
{
4117-
continue;
4118-
}
4119-
isNativeAddr = scriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
4120-
}
4121-
4125+
bool isNativeAddr = IsNativeAddressHelper(pCodeAddr, currentScriptContext);
41224126
#if DBG
4123-
Assert(result == (isNativeAddr? 1:0));
4127+
Assert(result == (isNativeAddr? TRUE:FALSE));
41244128
#endif
41254129
return isNativeAddr;
41264130
}
@@ -4138,17 +4142,7 @@ BOOL ThreadContext::IsNativeAddress(void * pCodeAddr, Js::ScriptContext* current
41384142
#if DBG
41394143
AutoCriticalSection autoLock(&this->codePageAllocators.cs);
41404144
#endif
4141-
4142-
bool isNativeAddr = false;
4143-
for (Js::ScriptContext *scriptContext = scriptContextList; scriptContext && !isNativeAddr; scriptContext = scriptContext->next)
4144-
{
4145-
if (scriptContext->GetJitFuncRangeCache() == nullptr)
4146-
{
4147-
continue;
4148-
}
4149-
isNativeAddr = scriptContext->GetJitFuncRangeCache()->IsNativeAddr(pCodeAddr);
4150-
}
4151-
4145+
bool isNativeAddr = IsNativeAddressHelper(pCodeAddr, currentScriptContext);
41524146
#if DBG
41534147
Assert(this->codePageAllocators.IsInNonPreReservedPageAllocator(pCodeAddr) == isNativeAddr);
41544148
#endif

lib/Runtime/Base/ThreadContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@ class ThreadContext sealed :
11801180
void RegisterCodeGenRecyclableData(Js::CodeGenRecyclableData *const codeGenRecyclableData);
11811181
void UnregisterCodeGenRecyclableData(Js::CodeGenRecyclableData *const codeGenRecyclableData);
11821182
#if ENABLE_NATIVE_CODEGEN
1183+
bool IsNativeAddressHelper(void * pCodeAddr, Js::ScriptContext* currentScriptContext);
11831184
BOOL IsNativeAddress(void * pCodeAddr, Js::ScriptContext* currentScriptContext = nullptr);
11841185
JsUtil::JobProcessor *GetJobProcessor();
11851186
Js::Var * GetBailOutRegisterSaveSpace() const { return bailOutRegisterSaveSpace; }

0 commit comments

Comments
 (0)