method inline optimization

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

anyone know the criteria a method must meet in order for it to be inlined?
and is there a way to force a method to be inlined? it's not one of the
MethodImplOptions.
 
Daniel,

You can not force a method to be inlined by the JIT. You can only force
it to NOT be inlined, either through the function being declared as virtual,
or using the MethodImpl attribute set so that it is not inlined.

Hope this helps.
 
exactly what I figured. it's unfortunate that you can't force a method
to be inlined. back to my other question, anyone have any information
on what criteria a method must meet for it to even be considered for
inlining? I googled on that, and so far only found some information on
how the compact framework handles it.

Daniel,

You can not force a method to be inlined by the JIT. You can only force
it to NOT be inlined, either through the function being declared as virtual,
or using the MethodImpl attribute set so that it is not inlined.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Daniel Jin said:
anyone know the criteria a method must meet in order for it to be inlined?
and is there a way to force a method to be inlined? it's not one of the
MethodImplOptions.
 
Daniel Jin said:
exactly what I figured. it's unfortunate that you can't force a method
to be inlined. back to my other question, anyone have any information
on what criteria a method must meet for it to even be considered for
inlining? I googled on that, and so far only found some information on
how the compact framework handles it.

http://blogs.msdn.com/davidnotario/archive/2004/11/01/250398.aspx has a
fair amount on it, in terms of size etc.
 
Daniel Jin said:
anyone know the criteria a method must meet in order for it to be inlined?
and is there a way to force a method to be inlined? it's not one of the
MethodImplOptions.

Not sure if this is still valid for v2.0 of the JIT, but AFAIK for v1.x the
following are not inlined:
- Methods wth > 32 bytes of IL.
- Virtual calls.
- Valuetypes, and MarshalByRef call targets.
- Complex flowgraphs like loops, methods with exception handling blocks.
- Security checks that need a method frame (compressed stack etc).
-????

Willy.
 
Back
Top