summaryrefslogtreecommitdiff
path: root/src/vm/proftoeeinterfaceimpl.cpp
diff options
context:
space:
mode:
authorDavid Mason <davmason@microsoft.com>2019-05-13 21:40:29 -0700
committerGitHub <noreply@github.com>2019-05-13 21:40:29 -0700
commit1fc8b490bc086cce155f374db2805f2ed5e4e6c1 (patch)
tree180432500053cab7739b99262dcdb60b36e0c2e1 /src/vm/proftoeeinterfaceimpl.cpp
parent287d6af711f63149123cb67c5de9ae6684749016 (diff)
downloadcoreclr-1fc8b490bc086cce155f374db2805f2ed5e4e6c1.tar.gz
coreclr-1fc8b490bc086cce155f374db2805f2ed5e4e6c1.tar.bz2
coreclr-1fc8b490bc086cce155f374db2805f2ed5e4e6c1.zip
Profiler API to request ReJIT with inliners (#24461)
This API is necessary for attaching profilers to be able to ReJIT methods and replace everything that uses the old IL.
Diffstat (limited to 'src/vm/proftoeeinterfaceimpl.cpp')
-rw-r--r--src/vm/proftoeeinterfaceimpl.cpp65
1 files changed, 61 insertions, 4 deletions
diff --git a/src/vm/proftoeeinterfaceimpl.cpp b/src/vm/proftoeeinterfaceimpl.cpp
index b5ade592f7..309fb085f5 100644
--- a/src/vm/proftoeeinterfaceimpl.cpp
+++ b/src/vm/proftoeeinterfaceimpl.cpp
@@ -6790,6 +6790,63 @@ HRESULT ProfToEEInterfaceImpl::GetCodeInfo4(UINT_PTR pNativeCodeStartAddress,
codeInfos);
}
+HRESULT ProfToEEInterfaceImpl::RequestReJITWithInliners(
+ DWORD dwRejitFlags,
+ ULONG cFunctions,
+ ModuleID moduleIds[],
+ mdMethodDef methodIds[])
+{
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_TRIGGERS;
+ MODE_ANY;
+ CAN_TAKE_LOCK;
+ PRECONDITION(CheckPointer(moduleIds, NULL_OK));
+ PRECONDITION(CheckPointer(methodIds, NULL_OK));
+ }
+ CONTRACTL_END;
+
+ PROFILER_TO_CLR_ENTRYPOINT_SYNC_EX(
+ kP2EETriggers | kP2EEAllowableAfterAttach,
+ (LF_CORPROF,
+ LL_INFO1000,
+ "**PROF: RequestReJITWithInliners.\n"));
+
+ if (!g_profControlBlock.pProfInterface->IsCallback4Supported())
+ {
+ return CORPROF_E_CALLBACK4_REQUIRED;
+ }
+
+ if (!CORProfilerEnableRejit())
+ {
+ return CORPROF_E_REJIT_NOT_ENABLED;
+ }
+
+ if (!ReJitManager::IsReJITInlineTrackingEnabled())
+ {
+ return CORPROF_E_REJIT_INLINING_DISABLED;
+ }
+
+ // Request at least 1 method to reJIT!
+ if ((cFunctions == 0) || (moduleIds == NULL) || (methodIds == NULL))
+ {
+ return E_INVALIDARG;
+ }
+
+ // We only support disabling inlining currently
+ if ((dwRejitFlags & COR_PRF_REJIT_BLOCK_INLINING) != COR_PRF_REJIT_BLOCK_INLINING)
+ {
+ return E_INVALIDARG;
+ }
+
+ // Remember the profiler is doing this, as that means we must never detach it!
+ g_profControlBlock.pProfInterface->SetUnrevertiblyModifiedILFlag();
+
+ GCX_PREEMP();
+ return ReJitManager::RequestReJIT(cFunctions, moduleIds, methodIds, static_cast<COR_PRF_REJIT_FLAGS>(dwRejitFlags));
+}
+
/*
* GetObjectReferences
*
@@ -8645,7 +8702,7 @@ HRESULT ProfToEEInterfaceImpl::RequestReJIT(ULONG cFunctions, // in
g_profControlBlock.pProfInterface->SetUnrevertiblyModifiedILFlag();
GCX_PREEMP();
- return ReJitManager::RequestReJIT(cFunctions, moduleIds, methodIds);
+ return ReJitManager::RequestReJIT(cFunctions, moduleIds, methodIds, static_cast<COR_PRF_REJIT_FLAGS>(0));
}
HRESULT ProfToEEInterfaceImpl::RequestRevert(ULONG cFunctions, // in
@@ -9650,7 +9707,7 @@ HRESULT ProfToEEInterfaceImpl::EnumNgenModuleMethodsInliningThisMethod(
return CORPROF_E_DATAINCOMPLETE;
}
- if (!inlinersModule->HasInlineTrackingMap())
+ if (!inlinersModule->HasNativeOrReadyToRunInlineTrackingMap())
{
return CORPROF_E_DATAINCOMPLETE;
}
@@ -9663,14 +9720,14 @@ HRESULT ProfToEEInterfaceImpl::EnumNgenModuleMethodsInliningThisMethod(
EX_TRY
{
// Trying to use static buffer
- COUNT_T methodsAvailable = inlinersModule->GetInliners(inlineeOwnerModule, inlineeMethodId, staticBufferSize, staticBuffer, incompleteData);
+ COUNT_T methodsAvailable = inlinersModule->GetNativeOrReadyToRunInliners(inlineeOwnerModule, inlineeMethodId, staticBufferSize, staticBuffer, incompleteData);
// If static buffer is not enough, allocate an array.
if (methodsAvailable > staticBufferSize)
{
DWORD dynamicBufferSize = methodsAvailable;
dynamicBuffer = methodsBuffer = new MethodInModule[dynamicBufferSize];
- methodsAvailable = inlinersModule->GetInliners(inlineeOwnerModule, inlineeMethodId, dynamicBufferSize, dynamicBuffer, incompleteData);
+ methodsAvailable = inlinersModule->GetNativeOrReadyToRunInliners(inlineeOwnerModule, inlineeMethodId, dynamicBufferSize, dynamicBuffer, incompleteData);
if (methodsAvailable > dynamicBufferSize)
{
_ASSERTE(!"Ngen image inlining info changed, this shouldn't be possible.");