Skip to content
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
9 changes: 0 additions & 9 deletions tracer/src/Datadog.Trace.ClrProfiler.Native/clr_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ AssemblyInfo GetAssemblyInfo(ICorProfilerInfo4* info, const AssemblyID& assembly

if (FAILED(hr) || assembly_name_len == 0)
{
Logger::Warn("Error loading the assembly info: ", assembly_id, " [",
"AssemblyLength=", assembly_name_len,
", HRESULT=0x", HResultStr(hr),
"]");
return {};
}

Expand All @@ -58,11 +54,6 @@ AssemblyInfo GetAssemblyInfo(ICorProfilerInfo4* info, const AssemblyID& assembly

if (FAILED(hr) || app_domain_name_len == 0)
{
Logger::Warn("Error loading the appdomain for assembly: ", assembly_id, " [AssemblyName=", WSTRING(assembly_name),
", AssemblyLength=", assembly_name_len,
", HRESULT=0x", HResultStr(hr),
", AppDomainId=", app_domain_id,
"]");
return {};
}

Expand Down
5 changes: 0 additions & 5 deletions tracer/src/Datadog.Trace.ClrProfiler.Native/clr_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,6 @@ struct AssemblyMetadata
{
}

AssemblyMetadata(const AssemblyMetadata& value) :
module_id(value.module_id), name(value.name), assembly_token(value.assembly_token), version(value.version)
{
}

bool IsValid() const
{
return module_id != 0;
Expand Down
385 changes: 237 additions & 148 deletions tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.cpp

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions tracer/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ class CorProfiler : public CorProfilerBase
//
std::mutex module_id_to_info_map_lock_;
std::unordered_map<ModuleID, ModuleMetadata*> module_id_to_info_map_;
std::vector<ModuleID> module_ids_;

//
// Helper methods
//
void RewritingPInvokeMaps(const ModuleMetadata& module_metadata, const WSTRING& nativemethods_type_name);
void RewritingPInvokeMaps(ComPtr<IUnknown> metadata_interfaces, ModuleMetadata* module_metadata, WSTRING nativemethods_type_name);
WSTRING GetCLRProfilerPath();
void CheckFilenameDefinitions();
bool GetWrapperMethodRef(ModuleMetadata* module_metadata, ModuleID module_id,
Expand All @@ -92,6 +91,8 @@ class CorProfiler : public CorProfilerBase
//
// CallTarget Methods
//
size_t CallTarget_RequestRejitForModule(ModuleID module_id, ModuleMetadata* module_metadata,
const std::vector<IntegrationMethod>& integrations);
HRESULT CallTarget_RewriterCallback(RejitHandlerModule* moduleHandler, RejitHandlerModuleMethod* methodHandler);

public:
Expand Down
350 changes: 40 additions & 310 deletions tracer/src/Datadog.Trace.ClrProfiler.Native/rejit_handler.cpp

Large diffs are not rendered by default.

26 changes: 7 additions & 19 deletions tracer/src/Datadog.Trace.ClrProfiler.Native/rejit_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@ namespace trace

struct RejitItem
{
int m_type = 0;
//
int m_length = 0;
std::unique_ptr<ModuleID[]> m_modulesId = nullptr;
std::unique_ptr<mdMethodDef[]> m_methodDefs = nullptr;
//
std::unique_ptr<std::vector<IntegrationMethod>> m_integrationMethods = nullptr;

RejitItem();
RejitItem(int length,
std::unique_ptr<ModuleID[]>&& modulesId,
std::unique_ptr<mdMethodDef[]>&& methodDefs,
std::unique_ptr<std::vector<IntegrationMethod>>&& integrationMethods);
std::unique_ptr<ModuleID> m_modulesId = nullptr;
std::unique_ptr<mdMethodDef> m_methodDefs = nullptr;

RejitItem(int length, std::unique_ptr<ModuleID>&& modulesId, std::unique_ptr<mdMethodDef>&& methodDefs);
static std::unique_ptr<RejitItem> CreateEndRejitThread();
};

Expand Down Expand Up @@ -76,7 +68,7 @@ class RejitHandlerModule
{
private:
ModuleID m_moduleId;
std::unique_ptr<ModuleMetadata> m_metadata;
ModuleMetadata* m_metadata;
std::mutex m_methods_lock;
std::unordered_map<mdMethodDef, std::unique_ptr<RejitHandlerModuleMethod>> m_methods;
RejitHandler* m_handler;
Expand Down Expand Up @@ -104,7 +96,6 @@ class RejitHandler
private:
std::mutex m_modules_lock;
std::unordered_map<ModuleID, std::unique_ptr<RejitHandlerModule>> m_modules;
AssemblyProperty* m_pCorAssemblyProperty = nullptr;

ICorProfilerInfo4* m_profilerInfo;
ICorProfilerInfo6* m_profilerInfo6;
Expand Down Expand Up @@ -136,19 +127,16 @@ class RejitHandler

void AddNGenModule(ModuleID moduleId);

void EnqueueForRejit(const std::vector<ModuleID>& modulesVector, const std::vector<mdMethodDef>& modulesMethodDef);
void EnqueueProcessModule(const std::vector<ModuleID>& modulesVector,
const std::vector<IntegrationMethod>& integrations);
void EnqueueForRejit(std::vector<ModuleID>& modulesVector, std::vector<mdMethodDef>& modulesMethodDef);
void Shutdown();

HRESULT NotifyReJITParameters(ModuleID moduleId, mdMethodDef methodId,
ICorProfilerFunctionControl* pFunctionControl);
ICorProfilerFunctionControl* pFunctionControl, ModuleMetadata* metadata);
HRESULT NotifyReJITCompilationStarted(FunctionID functionId, ReJITID rejitId);

ICorProfilerInfo4* GetCorProfilerInfo();
ICorProfilerInfo6* GetCorProfilerInfo6();

void SetCorAssemblyProfiler(AssemblyProperty* pCorAssemblyProfiler);
void RequestRejitForNGenInliners();
};

Expand Down
5 changes: 0 additions & 5 deletions tracer/src/Datadog.Trace.ClrProfiler.Native/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ WSTRING HexStr(const void* dataPtr, int len)
return s;
}

WSTRING HResultStr(const HRESULT value)
{
return HexStr((unsigned char*) &value, sizeof(HRESULT));
}

WSTRING TokenStr(const mdToken* token)
{
const unsigned char* data = (unsigned char*) token;
Expand Down
2 changes: 0 additions & 2 deletions tracer/src/Datadog.Trace.ClrProfiler.Native/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ std::vector<WSTRING> GetEnvironmentValues(const WSTRING& name);
// Convert Hex to string
WSTRING HexStr(const void* data, int len);

WSTRING HResultStr(const HRESULT value);

// Convert Token to string
WSTRING TokenStr(const mdToken* token);

Expand Down