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

[mono][jit] Simplify method_needs_stack_walk (). #98230

Merged
merged 1 commit into from
Feb 10, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static Assembly GetExecutingAssembly()
internal static extern RuntimeAssembly GetExecutingAssembly(ref StackCrawlMark stackMark);

[MethodImplAttribute(MethodImplOptions.InternalCall)]
[System.Security.DynamicSecurityMethod] // Methods doing stack walks has to be marked DynamicSecurityMethod
public static extern Assembly GetCallingAssembly();

[MethodImplAttribute(MethodImplOptions.InternalCall)]
Expand Down
20 changes: 4 additions & 16 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -3547,23 +3547,11 @@ method_needs_stack_walk (MonoCompile *cfg, MonoMethod *cmethod)
}

/*
* In corelib code, methods which need to do a stack walk declare a StackCrawlMark local and pass it as an
* arguments until it reaches an icall. Its hard to detect which methods do that especially with
* StackCrawlMark.LookForMyCallersCaller, so for now, just hardcode the classes which contain the public
* methods whose caller is needed.
* Methods which do stack walks are marked with [System.Security.DynamicSecurityMethod] in the bcl.
* This check won't work for StackCrawlMark.LookForMyCallersCaller, but thats not currently by the
* stack walk code anyway.
*/
if (mono_is_corlib_image (m_class_get_image (cmethod->klass))) {
const char *cname = m_class_get_name (cmethod->klass);
if (!strcmp (cname, "Assembly") ||
!strcmp (cname, "AssemblyLoadContext") ||
(!strcmp (cname, "Activator"))) {
if (!strcmp (cmethod->name, "op_Equality"))
return FALSE;
return TRUE;
}
}

return FALSE;
return (cmethod->flags & METHOD_ATTRIBUTE_REQSECOBJ) != 0;
}

G_GNUC_UNUSED MonoInst*
Expand Down
Loading