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

Convert GetCurrentMethod to QCALL #99852

Merged
merged 3 commits into from
Mar 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -844,11 +844,13 @@ internal static partial Interop.BOOL IsCAVisibleFromDecoratedType(
QCallTypeHandle sourceTypeHandle,
QCallModule sourceModule);

[MethodImpl(MethodImplOptions.InternalCall)]
private static extern IRuntimeMethodInfo? _GetCurrentMethod(ref StackCrawlMark stackMark);
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeMethodHandle_GetCurrentMethod")]
private static partial void _GetCurrentMethod(StackCrawlMarkHandle stackMark, ObjectHandleOnStack retMethod);
internal static IRuntimeMethodInfo? GetCurrentMethod(ref StackCrawlMark stackMark)
{
return _GetCurrentMethod(ref stackMark);
object? retMethod = null;
_GetCurrentMethod(new StackCrawlMarkHandle(ref stackMark), ObjectHandleOnStack.Create(ref retMethod));
return (IRuntimeMethodInfo?)retMethod;
AustinWise marked this conversation as resolved.
Show resolved Hide resolved
}

[MethodImpl(MethodImplOptions.InternalCall)]
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/ecalllist.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ FCFuncStart(gSignatureNative)
FCFuncEnd()

FCFuncStart(gRuntimeMethodHandle)
FCFuncElement("_GetCurrentMethod", RuntimeMethodHandle::GetCurrentMethod)
FCFuncElement("InvokeMethod", RuntimeMethodHandle::InvokeMethod)
FCFuncElement("ReboxFromNullable", RuntimeMethodHandle::ReboxFromNullable)
FCFuncElement("ReboxToNullable", RuntimeMethodHandle::ReboxToNullable)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/qcallentrypoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ static const Entry s_QCall[] =
DllImportEntry(RuntimeTypeHandle_AllocateTypeAssociatedMemory)
DllImportEntry(RuntimeTypeHandle_RegisterCollectibleTypeDependency)
DllImportEntry(RuntimeMethodHandle_ConstructInstantiation)
DllImportEntry(RuntimeMethodHandle_GetCurrentMethod)
DllImportEntry(RuntimeMethodHandle_GetFunctionPointer)
DllImportEntry(RuntimeMethodHandle_GetIsCollectible)
DllImportEntry(RuntimeMethodHandle_GetMethodInstantiation)
Expand Down
16 changes: 10 additions & 6 deletions src/coreclr/vm/reflectioninvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,11 +890,16 @@ static StackWalkAction SkipMethods(CrawlFrame* frame, VOID* data) {
}

// Return the MethodInfo that represents the current method (two above this one)
FCIMPL1(ReflectMethodObject*, RuntimeMethodHandle::GetCurrentMethod, StackCrawlMark* stackMark) {
FCALL_CONTRACT;
extern "C" void QCALLTYPE RuntimeMethodHandle_GetCurrentMethod(QCall::StackCrawlMarkHandle stackMark, QCall::ObjectHandleOnStack retMethod) {

QCALL_CONTRACT;

BEGIN_QCALL;

GCX_COOP();

REFLECTMETHODREF pRet = NULL;

HELPER_METHOD_FRAME_BEGIN_RET_0();
SkipStruct skip;
skip.pStackMark = stackMark;
skip.pMeth = 0;
Expand All @@ -909,11 +914,10 @@ FCIMPL1(ReflectMethodObject*, RuntimeMethodHandle::GetCurrentMethod, StackCrawlM
else
pRet = NULL;

HELPER_METHOD_FRAME_END();
retMethod.Set(pRet);

return (ReflectMethodObject*)OBJECTREFToObject(pRet);
END_QCALL;
}
FCIMPLEND

static OBJECTREF DirectObjectFieldGet(FieldDesc *pField, TypeHandle fieldType, TypeHandle enclosingType, TypedByRef *pTarget, CLR_BOOL *pIsClassInitialized) {
CONTRACTL
Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/vm/runtimehandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ extern "C" void QCALLTYPE RuntimeTypeHandle_RegisterCollectibleTypeDependency(QC
class RuntimeMethodHandle {

public:
static FCDECL1(ReflectMethodObject*, GetCurrentMethod, StackCrawlMark* stackMark);

static FCDECL4(Object*, InvokeMethod, Object *target, PVOID* args, SignatureNative* pSig, CLR_BOOL fConstructor);

static FCDECL2(Object*, ReboxToNullable, Object *pBoxedValUNSAFE, ReflectClassBaseObject *pDestUNSAFE);
Expand Down Expand Up @@ -275,6 +273,9 @@ class RuntimeMethodHandle {
static FCDECL1(Object*, GetLoaderAllocator, MethodDesc *pMethod);
};


extern "C" void QCALLTYPE RuntimeMethodHandle_GetCurrentMethod(QCall::StackCrawlMarkHandle stackMark, QCall::ObjectHandleOnStack retMethod);

extern "C" BOOL QCALLTYPE RuntimeMethodHandle_IsCAVisibleFromDecoratedType(
QCall::TypeHandle targetTypeHandle,
MethodDesc * pTargetCtor,
Expand Down
Loading