[Mono-dev] Inlining methods with struct parameters/local/return

Rodrigo Kumpera kumpera at gmail.com
Fri Sep 30 19:02:58 EDT 2011

On Fri, Sep 30, 2011 at 7:37 PM, Mehrdad Reshadi <reshadi at gmail.com> wrote:

> Hi,
> I have been searching on the internet but could not find a definitive
> answer to this.
> Is there any limitation in the latest version of Mono (as of 2.10.5) in
> inlining a method in the following cases:
> - a method that only uses "ref" struct parameters
- a method that uses struct parameters
> - a method that has struct local variables
> - a method that returns a struct
> I appreciate if anyone can point me to the part of mini that deals with
> inlining heuristics?
The checks are done here:


The function mono_method_check_inlining does basic checks and the rest are
done while converting method to IR.
Then look for uses of the INLINE_FAILURE macro to see what in the body of a
method aborts inlining.

Take the below example, Foo will be inlined:

using System;

class Driver {
static DateTime Foo (DateTime a, DateTime b, DateTime c) {
return a;

static void Main () {
DateTime a = DateTime.Now;
DateTime b = a.AddDays (1);
DateTime c = a.AddDays (2);

DateTime d = Foo (a, b, c);
Console.WriteLine (d);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110930/20efa01c/attachment.html 

More information about the Mono-devel-list mailing list