[interp] Move from stack based to fully local var based design (#46037)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 8 Jan 2021 11:55:18 +0000 (06:55 -0500)
committerGitHub <noreply@github.com>
Fri, 8 Jan 2021 11:55:18 +0000 (13:55 +0200)
commitc2e098b14a9a352fc9a2afad59060d6097f89418
treecd8a42a92171d06fe1692f175aed0c17759e607b
parent6299cefa0365e84822a53425b1a9af1e5d70917a
[interp] Move from stack based to fully local var based design (#46037)

Instead of having instructions that push and pop from the stack, every instruction has explicit dreg and sregs.

While the purpose of this PR is mainly to make it easier to implement more advanced optimization in the future, it also has noticeable performance implications. The code is simplified because we no longer need to update and save the SP. However, the code for each instruction is bloated due to the addition of explicit source and destination offsets. This is counteracted by the reduction of the total number of instructions, since ldloc/stloc and moves become redundant and they are mostly optimized away, even in this implementation state. Here are the total number of executed opcodes as part of running the corlib test suite with the interp https://gist.github.com/BrzVlad/d62f504930b75cba4b870e6dbd947e90.

Co-authored-by: BrzVlad <BrzVlad@users.noreply.github.com>
src/mono/mono/mini/interp/interp-internals.h
src/mono/mono/mini/interp/interp.c
src/mono/mono/mini/interp/mintops.c
src/mono/mono/mini/interp/mintops.def
src/mono/mono/mini/interp/mintops.h
src/mono/mono/mini/interp/transform.c
src/mono/mono/mini/interp/transform.h
src/mono/mono/mini/interp/whitebox.c