Skip to content

Commit

Permalink
Don't inline methods with the DoesNotReturn attribute in interp, it's…
Browse files Browse the repository at this point in the history
… a waste of time to do so (#99550)

Right now the mono interp will attempt to inline methods that have the DoesNotReturn attribute; this is a waste of time and resources, since it's not profitable to inline them and they are virtually always going to be unreachable code anyway.
  • Loading branch information
kg authored Mar 12, 2024
1 parent 6cb660d commit 8d952f7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,14 @@ interp_method_check_inlining (TransformData *td, MonoMethod *method, MonoMethodS
if (td->prof_coverage)
return FALSE;

/*
* doesnotreturn methods are not profitable to inline, since they almost certainly will not
* actually run during normal execution, and if they do they will only run once, so the
* upside to inlining them is effectively zero, and we'd waste time doing the inline
*/
if (has_doesnotreturn_attribute (method))
return FALSE;

if (!is_metadata_update_disabled () && mono_metadata_update_no_inline (td->method, method))
return FALSE;

Expand Down

0 comments on commit 8d952f7

Please sign in to comment.