Skip to content

Gather optimization info through the DAC #89534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7407,6 +7407,27 @@ HRESULT DacDbiInterfaceImpl::GetReJitInfo(VMPTR_MethodDesc vmMethod, CORDB_ADDRE
return S_OK;
}

HRESULT DacDbiInterfaceImpl::AreOptimizationsDisabled(VMPTR_Module vmModule, mdMethodDef methodTk, OUT BOOL* pOptimizationsDisabled)
{
DD_ENTER_MAY_THROW;
#ifdef FEATURE_REJIT
PTR_Module pModule = vmModule.GetDacPtr();
if (pModule == NULL || pOptimizationsDisabled == NULL || TypeFromToken(methodTk) != mdtMethodDef)
{
return E_INVALIDARG;
}
{
CodeVersionManager * pCodeVersionManager = pModule->GetCodeVersionManager();
ILCodeVersion activeILVersion = pCodeVersionManager->GetActiveILCodeVersion(pModule, methodTk);
*pOptimizationsDisabled = activeILVersion.IsDeoptimized();
}
#else
pOptimizationsDisabled->SetDacTargetPtr(0);
#endif

return S_OK;
}

HRESULT DacDbiInterfaceImpl::GetNativeCodeVersionNode(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeStartAddress, OUT VMPTR_NativeCodeVersionNode* pVmNativeCodeVersionNode)
{
DD_ENTER_MAY_THROW;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/debug/daccess/dacdbiimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class DacDbiInterfaceImpl :
HRESULT GetReJitInfo(VMPTR_Module vmModule, mdMethodDef methodTk, OUT VMPTR_ReJitInfo* pReJitInfo);
HRESULT GetActiveRejitILCodeVersionNode(VMPTR_Module vmModule, mdMethodDef methodTk, OUT VMPTR_ILCodeVersionNode* pVmILCodeVersionNode);
HRESULT GetReJitInfo(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeStartAddress, OUT VMPTR_ReJitInfo* pReJitInfo);
HRESULT AreOptimizationsDisabled(VMPTR_Module vmModule, mdMethodDef methodTk, OUT BOOL* pOptimizationsDisabled);
HRESULT GetNativeCodeVersionNode(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeStartAddress, OUT VMPTR_NativeCodeVersionNode* pVmNativeCodeVersionNode);
HRESULT GetSharedReJitInfo(VMPTR_ReJitInfo vmReJitInfo, VMPTR_SharedReJitInfo* pSharedReJitInfo);
HRESULT GetILCodeVersionNode(VMPTR_NativeCodeVersionNode vmNativeCodeVersionNode, VMPTR_ILCodeVersionNode* pVmILCodeVersionNode);
Expand Down
27 changes: 6 additions & 21 deletions src/coreclr/debug/di/rsfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,27 +673,12 @@ HRESULT CordbFunction::AreOptimizationsDisabled(BOOL *pOptimizationsDisabled)
{
return E_INVALIDARG;
}

CordbProcess * pProcess = GetProcess();
RSLockHolder lockHolder(pProcess->GetProcessLock());

DebuggerIPCEvent event;
CordbAppDomain * pAppDomain = GetAppDomain();
_ASSERTE (pAppDomain != NULL);

pProcess->InitIPCEvent(&event, DB_IPCE_IS_OPTS_DISABLED, true, pAppDomain->GetADToken());
event.DisableOptData.funcMetadataToken = m_MDToken;
event.DisableOptData.pModule = m_pModule->GetRuntimeModule();

lockHolder.Release();
hr = pProcess->m_cordb->SendIPCEvent(pProcess, &event, sizeof(DebuggerIPCEvent));
lockHolder.Acquire();

_ASSERTE(event.type == DB_IPCE_IS_OPTS_DISABLED_RESULT);

*pOptimizationsDisabled = event.IsOptsDisabledData.value;

return event.hr;;
EX_TRY
{
hr = GetProcess()->GetDAC()->AreOptimizationsDisabled(GetModule()->GetRuntimeModule(), GetMetadataToken(), pOptimizationsDisabled);
}
EX_CATCH_HRESULT(hr);
return hr;
}

// determine whether we have a native-only implementation
Expand Down
28 changes: 0 additions & 28 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10468,34 +10468,6 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
}
break;

case DB_IPCE_IS_OPTS_DISABLED:
{
Module *pModule = pEvent->DisableOptData.pModule.GetRawPtr();
mdToken methodDef = pEvent->DisableOptData.funcMetadataToken;
_ASSERTE(TypeFromToken(methodDef) == mdtMethodDef);

HRESULT hr = E_INVALIDARG;
BOOL deoptimized = FALSE;
EX_TRY
{
hr = IsMethodDeoptimized(pModule, methodDef, &deoptimized);
}
EX_CATCH_HRESULT(hr);

DebuggerIPCEvent * pIPCResult = m_pRCThread->GetIPCEventReceiveBuffer();

InitIPCEvent(pIPCResult,
DB_IPCE_IS_OPTS_DISABLED_RESULT,
g_pEEInterface->GetThread(),
pEvent->vmAppDomain);

pIPCResult->IsOptsDisabledData.value = deoptimized;
pIPCResult->hr = hr;

m_pRCThread->SendIPCReply();
}
break;

case DB_IPCE_BREAKPOINT_ADD:
{

Expand Down
20 changes: 19 additions & 1 deletion src/coreclr/debug/inc/dacdbiinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,25 @@ class IDacDbiInterface
//
virtual
HRESULT GetSharedReJitInfoData(VMPTR_SharedReJitInfo sharedReJitInfo, DacSharedReJitInfo* pData) = 0;


// Retrieves a bool indicating whether or not a method's optimizations have been disabled
// defined in Debugger::IsMethodDeoptimized
//
//
//
// Arguments:
// vmModule - The module for the method in question
// methodTk - The method token for the method in question
// pOptimizationsDisabled - [out] A bool indicating whether or not the optimizations on a function are disabled
//
//
// Returns:
// S_OK if no error
// error HRESULTs are possible
//
virtual
HRESULT AreOptimizationsDisabled(VMPTR_Module vmModule, mdMethodDef methodTk, OUT BOOL* pOptimizationsDisabled) = 0;

// Retrieves a bit field indicating which defines were in use when clr was built. This only includes
// defines that are specified in the Debugger::_Target_Defines enumeration, which is a small subset of
// all defines.
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/debug/inc/dbgipcevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -2019,11 +2019,6 @@ struct MSLAYOUT DebuggerIPCEvent
VMPTR_Module pModule;
} DisableOptData;

struct MSLAYOUT
{
BOOL value;
} IsOptsDisabledData;

struct MSLAYOUT
{
LSPTR_BREAKPOINT breakpointToken;
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/debug/inc/dbgipceventtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ IPC_EVENT_TYPE1(DB_IPCE_DATA_BREAKPOINT ,0x0160)
IPC_EVENT_TYPE1(DB_IPCE_BEFORE_GARBAGE_COLLECTION ,0x0161)
IPC_EVENT_TYPE1(DB_IPCE_AFTER_GARBAGE_COLLECTION ,0x0162)
IPC_EVENT_TYPE1(DB_IPCE_DISABLE_OPTS_RESULT ,0x0163)
IPC_EVENT_TYPE1(DB_IPCE_IS_OPTS_DISABLED_RESULT ,0x0164)
IPC_EVENT_TYPE0(DB_IPCE_RUNTIME_LAST ,0x0165) // The last event from runtime


Expand Down Expand Up @@ -144,6 +143,5 @@ IPC_EVENT_TYPE2(DB_IPCE_GET_GCHANDLE_INFO ,0x0251)
IPC_EVENT_TYPE2(DB_IPCE_RESOLVE_UPDATE_METADATA_1 ,0x0256)
IPC_EVENT_TYPE2(DB_IPCE_RESOLVE_UPDATE_METADATA_2 ,0x0257)
IPC_EVENT_TYPE2(DB_IPCE_DISABLE_OPTS ,0x0258)
IPC_EVENT_TYPE2(DB_IPCE_IS_OPTS_DISABLED ,0x0259)
IPC_EVENT_TYPE0(DB_IPCE_DEBUGGER_LAST ,0x025A) // The last event from the debugger

7 changes: 0 additions & 7 deletions src/coreclr/debug/shared/dbgtransportsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2499,13 +2499,6 @@ DWORD DbgTransportSession::GetEventSize(DebuggerIPCEvent *pEvent)
break;

case DB_IPCE_DISABLE_OPTS:
case DB_IPCE_IS_OPTS_DISABLED:
cbAdditionalSize = sizeof(pEvent->DisableOptData);
break;

case DB_IPCE_IS_OPTS_DISABLED_RESULT:
cbAdditionalSize = sizeof(pEvent->IsOptsDisabledData);
break;

default:
printf("Unknown debugger event type: 0x%x\n", (pEvent->type & DB_IPCE_TYPE_MASK));
Expand Down