[interp] Propagate locals and kill dead ones afterwards (mono/mono#16791)
authorVlad Brezae <brezaevlad@gmail.com>
Fri, 13 Sep 2019 07:35:44 +0000 (10:35 +0300)
committerGitHub <noreply@github.com>
Fri, 13 Sep 2019 07:35:44 +0000 (10:35 +0300)
commitca9627775d78f96371de9d487ec594de67742d66
tree8da3ca5e06237a0fc18e34a0bf20c8b114708f4a
parente542474b5d45d69ce0e1eb596f7b265327bfa172
[interp] Propagate locals and kill dead ones afterwards (mono/mono#16791)

* [interp] Add flag for locals that have their address taken

The previous handling of LDLOCA was broken because if the address was taken before the instructions that would be optimized we would miss any potential changes to the local value. Right now we just skip optimizing locals that have their address taken. This is achieved simply by not pushing LDLOC on the evaluation stack, for those locals.

* [interp] Add separate counters for optimized instructions

To provide more insight.

* [interp] Propagate locals

Whenever we generate a movloc we remember what local was copied. When loading a local we check if it's currently storing the value of another local, in which case we load the original local instead.

* [interp] Kill instructions that write to dead locals

We track the liveness of a local by counting how many times the local is loaded using ldloc. When such instructions are optimized, the ldloc counter is updated accordingly.

* [interp] Don't optimize code if under debugger

Commit migrated from https://github.com/mono/mono/commit/6908a1941b7278fe6711c75976f2434db55136f0
src/mono/mono/mini/interp/interp-internals.h
src/mono/mono/mini/interp/interp.c
src/mono/mono/mini/interp/transform.c