compiler: Escape analysis

Programming / Compilers / GCC - ian [138bc75d-0d04-0410-961f-82ee72b054a4] - 17 April 2015 12:10 UTC

By Chris Manghane.

Comprises three changes to gofrontend repository:

compiler: Add escape information to export data.

compiler: Stack-allocate non-escaping variables.

This change allows variables initialized through make or new to be allocated on the stack via a temporary variable if they do not escape their function. It also improves the analysis to consider situations where variables escape in the standard library and go testsuite such as:

*nested composite literals and composite literal arguments
*method receivers always escaping
*escape via statements in closures referring to enclosing variables
*escape via calls with multiple return results

compiler: Basic escape analysis for the go frontend.

This is an implementation of the algorithm described in "Escape Analysis in Java" by Choi et. al.

It relies on dataflow information to discover variable references to one another. Handles assignments to closures and association between closures variables and the variables of the enclosing scope.

Dataflow analysis does not discover references through range statements e.g. for _, v := range a will not recognize that all values of v are references to a.

- Make-lang.in (GO_OBJS): Add go/escape.o.

da244e5 compiler: Escape analysis.
gcc/go/ChangeLog | 4 +
gcc/go/Make-lang.in | 1 +
gcc/go/gofrontend/dataflow.cc | 27 +-
gcc/go/gofrontend/escape.cc | 1481 ++++++++++++++++++++++++++++++++++++++
gcc/go/gofrontend/escape.h | 310 ++++++++
gcc/go/gofrontend/export.cc | 11 +
gcc/go/gofrontend/export.h | 5 +
gcc/go/gofrontend/expressions.cc | 786 +++-----------------
gcc/go/gofrontend/expressions.h | 786 ++++++++++++++++++++
gcc/go/gofrontend/go.cc | 4 +
gcc/go/gofrontend/gogo.cc | 179 ++++-
gcc/go/gofrontend/gogo.h | 139 +++-
gcc/go/gofrontend/import.cc | 29 +-
gcc/go/gofrontend/import.h | 5 +
gcc/go/gofrontend/statements.cc | 105 +--
gcc/go/gofrontend/statements.h | 137 ++++
gcc/go/gofrontend/types.h | 40 +-
17 files changed, 3283 insertions(+), 766 deletions(-)

Upstream: gcc.gnu.org


  • Share