Inline Refactoring: set up policy for bad inlinees
authorAndy Ayers <andya@microsoft.com>
Tue, 23 Feb 2016 23:21:22 +0000 (15:21 -0800)
committerAndy Ayers <andya@microsoft.com>
Thu, 25 Feb 2016 17:42:40 +0000 (09:42 -0800)
commit99927794a53ed68b1a55ddba238eff809be79fdc
tree6e61cc8fe0a9a2d36d050884af247cf3488e17f2
parent7a6d8a44c0a2f8d3f431c58aa77b95f15f212756
Inline Refactoring: set up policy for bad inlinees

Move inline policies to their own header and cpp file.

Add a method to the policy class to indicate if the policy wants newly
discovered `Never` inline cases to change the callee method attributes
to Noinline. This is an existing optimization that saves time when the
jit sees calls to this callee elsewhere as a possible inline candidates.

For example, in the trace below, at for the call at offset 31, the jit
determines that `ToInt32` is too large to be inlined and so marks it as
noinline. Then when it sees another call to `ToInt31` at offset 44 it
immediately fails the inline attempt.

```
Inlines into RegistryTimeZoneInformation:.ctor(ref):this
  ...
  [IL=0031 TR=000040] [FAILED: too many il bytes] System.BitConverter:ToInt32(ref,int):int
  [IL=0044 TR=000049] [FAILED: noinline per IL/cached result] System.BitConverter:ToInt32(ref,int):int
  [IL=0057 TR=000058] [FAILED: noinline per IL/cached result] System.BitConverter:ToInt32(ref,int):int
```

Diagnostic and experimental policies may choose to disable this
optimization to make it easier to locally reason about failed inlines.

There were 5 calls to `setMethodAttribs` passing `CORINFO_FLG_BAD_INLINEE`.
This change consolidates 4 of them into the inlining code. The remaining
call is for a method with verification errors. I've left it as is.
src/jit/CMakeLists.txt
src/jit/compiler.cpp
src/jit/importer.cpp
src/jit/inline.cpp
src/jit/inline.h
src/jit/inlinepolicy.cpp [new file with mode: 0644]
src/jit/inlinepolicy.h [new file with mode: 0644]
src/jit/jit.settings.targets
src/jit/morph.cpp