diff --git a/src/Agent/NewRelic/Agent/Core/ProfilerAgentMethodCallCache.cs b/src/Agent/NewRelic/Agent/Core/ProfilerAgentMethodInvoker.cs
similarity index 96%
rename from src/Agent/NewRelic/Agent/Core/ProfilerAgentMethodCallCache.cs
rename to src/Agent/NewRelic/Agent/Core/ProfilerAgentMethodInvoker.cs
index 5dcbcb25f3..f5684b70b6 100644
--- a/src/Agent/NewRelic/Agent/Core/ProfilerAgentMethodCallCache.cs
+++ b/src/Agent/NewRelic/Agent/Core/ProfilerAgentMethodInvoker.cs
@@ -9,9 +9,9 @@
namespace NewRelic.Agent.Core
{
///
- /// Cache of the Agent methods that can be invoked by the byte-code injected by the profiler.
+ /// The class used by the byte-code injected by the profiler to invoke arbitrary methods defined in the managed agent.
///
- public class ProfilerAgentMethodCallCache
+ public class ProfilerAgentMethodInvoker
{
private static readonly ConcurrentDictionary> _invokerCache = new ConcurrentDictionary>();
@@ -24,7 +24,7 @@ public class ProfilerAgentMethodCallCache
/// A reference to the method that is used to invoked the requrested agent method. The result is treated as an object
/// to simplify the type definition injected by the profiler to store this reference.
///
- public static object GetInvokerFromCache()
+ public static object GetInvoker()
{
return (Func)GetAndInvokeMethodFromCache;
}
diff --git a/src/Agent/NewRelic/Profiler/MethodRewriter/ApiFunctionManipulator.h b/src/Agent/NewRelic/Profiler/MethodRewriter/ApiFunctionManipulator.h
index 0b11c9a87a..f70d0f5ec9 100644
--- a/src/Agent/NewRelic/Profiler/MethodRewriter/ApiFunctionManipulator.h
+++ b/src/Agent/NewRelic/Profiler/MethodRewriter/ApiFunctionManipulator.h
@@ -47,19 +47,14 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter
{
if (_agentCallStrategy == AgentCallStyle::Strategy::InAgentCache)
{
- // Ensure that the managed agent is loaded
- _instructions->AppendString(_instrumentationSettings->GetCorePath());
- _instructions->Append(_X("call void [") + _instructions->GetCoreLibAssemblyName() + _X("]System.CannotUnloadAppDomainException::EnsureInitialized(string)"));
-
- // Get the Func holding a reference to the ProfilerAgentMethodCallCache.GetAndInvokeMethodFromCache method
- _instructions->Append(_X("call object [") + _instructions->GetCoreLibAssemblyName() + _X("]System.CannotUnloadAppDomainException::GetMethodCacheLookupMethod()"));
- _instructions->Append(CEE_CASTCLASS, _X("class [") + _instructions->GetCoreLibAssemblyName() + _X("]System.Func`7GetCoreLibAssemblyName() + _X("]System.Type[], class [") + _instructions->GetCoreLibAssemblyName() + _X("]System.Type, object[], object>"));
+ // result = System.CannotUnloadAppDomainException.InvokeAgentMethodInvokerFunc("C:\path\to\NewRelic.Agent.Core", "NewRelic_Delegate_API_", "NewRelic.Core.AgentApi", "", new System.Type[] { }, , new object[] { })
xstring_t className = _X("NewRelic.Agent.Core.AgentApi");
xstring_t methodName = _function->GetFunctionName();
xstring_t keyName = className + _X(".") + methodName + _X("_") + to_xstring((unsigned long)_function->GetFunctionId());
auto argumentTypesLambda = GetArrayOfTypeParametersLamdba();
+ _instructions->AppendString(_instrumentationSettings->GetCorePath());
_instructions->AppendString(keyName);
_instructions->AppendString(className);
_instructions->AppendString(methodName);
@@ -77,7 +72,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter
BuildObjectArrayOfParameters();
- _instructions->Append(CEE_CALLVIRT, _X("instance !6 class [") + _instructions->GetCoreLibAssemblyName() + _X("]System.Func`7GetCoreLibAssemblyName() + _X("]System.Type[], class [") + _instructions->GetCoreLibAssemblyName() + _X("]System.Type, object[], object>::Invoke(!0, !1, !2, !3, !4, !5)"));
+ _instructions->Append(_X("call object [") + _instructions->GetCoreLibAssemblyName() + _X("]System.CannotUnloadAppDomainException::InvokeAgentMethodInvokerFunc(string, string, string, string, class [") + _instructions->GetCoreLibAssemblyName() + _X("]System.Type[], class [") + _instructions->GetCoreLibAssemblyName() + _X("]System.Type, object[])"));
if (_methodSignature->_returnType->_kind == SignatureParser::ReturnType::Kind::VOID_RETURN_TYPE)
{
diff --git a/src/Agent/NewRelic/Profiler/MethodRewriter/HelperFunctionManipulator.h b/src/Agent/NewRelic/Profiler/MethodRewriter/HelperFunctionManipulator.h
index d200b97573..3885492b97 100644
--- a/src/Agent/NewRelic/Profiler/MethodRewriter/HelperFunctionManipulator.h
+++ b/src/Agent/NewRelic/Profiler/MethodRewriter/HelperFunctionManipulator.h
@@ -50,25 +50,25 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter
{
BuildEnsureInitializedMethod();
}
- else if (_function->GetFunctionName() == _X("GetMethodCacheLookupMethod"))
+ else if (_function->GetFunctionName() == _X("GetAgentMethodInvokerObject"))
{
- BuildGetMethodCacheLookupMethodMethod();
+ BuildGetAgentMethodInvokerObject();
}
- else if (_function->GetFunctionName() == _X("GetAgentShimFinishTracerDelegateMethod"))
+ else if (_function->GetFunctionName() == _X("GetAgentShimFinishTracerDelegateFunc"))
{
- BuildGetAgentShimFinishTracerDelegateMethod();
+ BuildGetAgentShimFinishTracerDelegateFunc();
}
- else if (_function->GetFunctionName() == _X("GetMethodInfoFromAgentCache"))
+ else if (_function->GetFunctionName() == _X("InvokeAgentMethodInvokerFunc"))
{
- BuildGetMethodInfoFromAgentCache();
+ BuildInvokeAgentMethodInvokerFunc();
}
- else if (_function->GetFunctionName() == _X("StoreMethodCacheLookupMethod"))
+ else if (_function->GetFunctionName() == _X("StoreAgentMethodInvokerFunc"))
{
- BuildStoreMethodCacheLookupMethod();
+ BuildStoreAgentMethodInvokerFunc();
}
- else if (_function->GetFunctionName() == _X("StoreAgentShimFinishTracerDelegateMethod"))
+ else if (_function->GetFunctionName() == _X("StoreAgentShimFinishTracerDelegateFunc"))
{
- BuildStoreAgentShimFinishTracerDelegateMethod();
+ BuildStoreAgentShimFinishTracerDelegateFunc();
}
else
{
@@ -176,42 +176,45 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter
_instructions->Append(CEE_RET);
}
- void BuildGetMethodInfoFromAgentCache()
+ // resultObject InvokeAgentMethodInvokerFunc(string assemblyPath, string storageKey, string typeName, string methodName, Type[] parameterTypes, Type returnType, object[] methodParameters)
+ void BuildInvokeAgentMethodInvokerFunc()
{
- _instructions->Append(CEE_LDARG_1);
+ _instructions->Append(CEE_LDARG_0);
_instructions->Append(_X("call void System.CannotUnloadAppDomainException::EnsureInitialized(string)"));
- _instructions->Append(_X("call object System.CannotUnloadAppDomainException::GetMethodCacheLookupMethod()"));
+ _instructions->Append(_X("call object System.CannotUnloadAppDomainException::GetAgentMethodInvokerObject()"));
- _instructions->Append(CEE_CASTCLASS, _X("class System.Func`5"));
- _instructions->Append(CEE_LDARG_0);
+ _instructions->Append(CEE_CASTCLASS, _X("class System.Func`7"));
+ _instructions->Append(CEE_LDARG_1);
_instructions->Append(CEE_LDARG_2);
_instructions->Append(CEE_LDARG_3);
_instructions->Append(CEE_LDARG_S, (uint8_t)4);
- _instructions->Append(CEE_CALLVIRT, _X("instance !4 class System.Func`5::Invoke(!0, !1, !2, !3)"));
+ _instructions->Append(CEE_LDARG_S, (uint8_t)5);
+ _instructions->Append(CEE_LDARG_S, (uint8_t)6);
+ _instructions->Append(CEE_CALLVIRT, _X("instance !6 class System.Func`7::Invoke(!0, !1, !2, !3, !4, !5)"));
_instructions->Append(CEE_RET);
}
- void BuildGetMethodCacheLookupMethodMethod()
+ void BuildGetAgentMethodInvokerObject()
{
_instructions->Append(CEE_VOLATILE);
_instructions->Append(CEE_LDSFLD, _X("object __NRInitializer__::_methodCache"));
_instructions->Append(CEE_RET);
}
- void BuildGetAgentShimFinishTracerDelegateMethod()
+ void BuildGetAgentShimFinishTracerDelegateFunc()
{
_instructions->Append(CEE_VOLATILE);
_instructions->Append(CEE_LDSFLD, _X("object __NRInitializer__::_tracerFunc"));
_instructions->Append(CEE_RET);
}
- void BuildStoreMethodCacheLookupMethod()
+ void BuildStoreAgentMethodInvokerFunc()
{
_instructions->Append(CEE_LDARG_0);
- _instructions->AppendString(_X("NewRelic.Agent.Core.ProfilerAgentMethodCallCache"));
- _instructions->AppendString(_X("GetInvokerFromCache"));
+ _instructions->AppendString(_X("NewRelic.Agent.Core.ProfilerAgentMethodInvoker"));
+ _instructions->AppendString(_X("GetInvoker"));
_instructions->Append(CEE_LDNULL);
_instructions->Append(CEE_CALL, _X("class System.Reflection.MethodInfo System.CannotUnloadAppDomainException::GetMethodViaReflectionOrThrow(string,string,string,class System.Type[])"));
@@ -224,7 +227,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter
_instructions->Append(CEE_RET);
}
- void BuildStoreAgentShimFinishTracerDelegateMethod()
+ void BuildStoreAgentShimFinishTracerDelegateFunc()
{
_instructions->Append(CEE_LDARG_0);
_instructions->AppendString(_X("NewRelic.Agent.Core.AgentShim"));
@@ -248,10 +251,10 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter
auto afterInit = _instructions->AppendJump(CEE_BRTRUE);
_instructions->Append(CEE_LDARG_0);
- _instructions->Append(_X("call void System.CannotUnloadAppDomainException::StoreAgentShimFinishTracerDelegateMethod(string)"));
+ _instructions->Append(_X("call void System.CannotUnloadAppDomainException::StoreAgentShimFinishTracerDelegateFunc(string)"));
_instructions->Append(CEE_LDARG_0);
- _instructions->Append(_X("call void System.CannotUnloadAppDomainException::StoreMethodCacheLookupMethod(string)"));
+ _instructions->Append(_X("call void System.CannotUnloadAppDomainException::StoreAgentMethodInvokerFunc(string)"));
_instructions->AppendLabel(afterInit);
diff --git a/src/Agent/NewRelic/Profiler/MethodRewriter/InstrumentFunctionManipulator.h b/src/Agent/NewRelic/Profiler/MethodRewriter/InstrumentFunctionManipulator.h
index 00992edbb6..39d54a081e 100644
--- a/src/Agent/NewRelic/Profiler/MethodRewriter/InstrumentFunctionManipulator.h
+++ b/src/Agent/NewRelic/Profiler/MethodRewriter/InstrumentFunctionManipulator.h
@@ -168,7 +168,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter
_instructions->Append(_X("call void [") + _instructions->GetCoreLibAssemblyName() + _X("]System.CannotUnloadAppDomainException::EnsureInitialized(string)"));
// Get the Func holding a reference to NewRelic.Agent.Core.AgentShim.GetFinishTracerDelegateParameterWrapper
- _instructions->Append(_X("call object [") + _instructions->GetCoreLibAssemblyName() + _X("]System.CannotUnloadAppDomainException::GetAgentShimFinishTracerDelegateMethod()"));
+ _instructions->Append(_X("call object [") + _instructions->GetCoreLibAssemblyName() + _X("]System.CannotUnloadAppDomainException::GetAgentShimFinishTracerDelegateFunc()"));
_instructions->Append(CEE_CASTCLASS, _X("class [") + _instructions->GetCoreLibAssemblyName() + _X("]System.Func`2