Implement escape analysis and stack allocation of non-box objects without gc fields.
authorEugene Rozenfeld <erozen@microsoft.com>
Tue, 30 Oct 2018 00:34:17 +0000 (17:34 -0700)
committerEugene Rozenfeld <erozen@microsoft.com>
Fri, 9 Nov 2018 06:35:07 +0000 (22:35 -0800)
commit00f5934a3e34977c7a1502da604f2dae90040888
tree1b739c1141eeb5973ae2c1ded9619164ca21a260
parente472fd44778d8322db53284336c2a96e75d70244
Implement escape analysis and stack allocation of non-box objects without gc fields.

This change implements a conservative flow-insensitive escape analysis and stack allocation
of non-box objects without gc fields.

Handling of objects with gc fields, box objects, and fixed-size arrays is future work.

Escape analysis is based on the one described here: https://www.cc.gatech.edu/~harrold/6340/cs6340_fall2009/Readings/choi99escape.pdf

Main limitations of this version of the escape analysis:
1. The analysis is flow-insensitive.
2. The analysis is intra-procedural and only sees the current method and the inlined methods.
3. The analysis assumes that references passed to non-pure-helper calls escape.
4. The analysis assumes that any references assigned to fields of objects escape.

Some of these limitations will be removed in future work.

I started with prior prototypes from @echesakovMSFT and @AndyAyersMS and extended and refactored
parts of them.

I also added tests for cases that are currently handled or will be handled soon.
12 files changed:
src/jit/compiler.h
src/jit/compmemkind.h
src/jit/gcencode.cpp
src/jit/gentree.cpp
src/jit/jitgcinfo.h
src/jit/lclvars.cpp
src/jit/morph.cpp
src/jit/objectalloc.cpp
src/jit/objectalloc.h
tests/issues.targets
tests/src/JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests.cs [new file with mode: 0644]
tests/src/JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests.csproj [new file with mode: 0644]