Skip to content
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

Change ICorProfilerMethodEnum to use the COMPtr #6334

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
37 changes: 37 additions & 0 deletions tracer/src/Datadog.Tracer.Native/clr_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,43 @@ HRESULT IsTypeByRefLike(ICorProfilerInfo4* corProfilerInfo4, const ModuleMetadat

HRESULT IsTypeTokenByRefLike(ICorProfilerInfo4* corProfilerInfo4, const ModuleMetadataBase& module_metadata, mdToken typeDefOrRefOrSpecToken,
bool& isTypeIsByRefLike);

template<class MetaInterface>
class COMPtrHolder {
public:
COMPtrHolder() {
m_ptr = NULL;
}

COMPtrHolder(MetaInterface *ptr) {
if (ptr != NULL) {
ptr->AddRef();
tonyredondo marked this conversation as resolved.
Show resolved Hide resolved
}
m_ptr = ptr;
}

~COMPtrHolder() {
if (m_ptr != NULL) {
m_ptr->Release();
m_ptr = NULL;
}
}

MetaInterface *operator->() {
return m_ptr;
}

MetaInterface **operator&() {
return &m_ptr;
}

operator MetaInterface *() {
return m_ptr;
}

private:
MetaInterface *m_ptr;
};
} // namespace trace

#endif // DD_CLR_PROFILER_CLR_HELPERS_H_
5 changes: 2 additions & 3 deletions tracer/src/Datadog.Tracer.Native/rejit_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool RejitHandlerModuleMethod::RequestRejitForInlinersInModule(ModuleID moduleId
{
// Now we enumerate all methods that inline the current methodDef
BOOL incompleteData = false;
ICorProfilerMethodEnum* methodEnum;
COMPtrHolder<ICorProfilerMethodEnum> methodEnum = NULL;

HRESULT hr = pInfo->EnumNgenModuleMethodsInliningThisMethod(moduleId, currentModuleId, currentMethodDef,
&incompleteData, &methodEnum);
Expand All @@ -82,8 +82,7 @@ bool RejitHandlerModuleMethod::RequestRejitForInlinersInModule(ModuleID moduleId
methods.push_back(method.methodId);
total++;
}
methodEnum->Release();
methodEnum = nullptr;

if (total > 0)
{
handler->EnqueueForRejit(modules, methods);
Expand Down
Loading