[mono][jit] Add an option to use an mrgctx for all gshared methods. (#82981)
authorZoltan Varga <vargaz@gmail.com>
Wed, 26 Apr 2023 15:01:05 +0000 (11:01 -0400)
committerGitHub <noreply@github.com>
Wed, 26 Apr 2023 15:01:05 +0000 (11:01 -0400)
commit184d17dc6b24144f81fae71e1a848698d8097ee4
tree78328b6370c17078e49ad482fdc2a4c16fb36bfa
parent342c4edf28034f035b762ce2665038a9785a6871
[mono][jit] Add an option to use an mrgctx for all gshared methods. (#82981)

Enable it by default on WASM.

In this mode, all gshared methods get an mrgctx, which means they can access
their data using a simple load from the mrgctx instead of having to call
a rgctx fetch trampoline.

Upsides:
- much simpler.
- faster access to gshared data
- smaller code and data size in the AOT case
- if enabled by default on all platforms, large amount of gshared
  code can be removed

Downsides:
- the methods have to initialize their mrgctx in their prolog
- on non-wasm platforms, indirect calls to gshared methods
  (like virtual calls) will need to use rgctx trampolines more often
  to pass the mrgctx.
src/mono/mono/mini/aot-compiler.c
src/mono/mono/mini/method-to-ir.c
src/mono/mono/mini/mini-arm64.c
src/mono/mono/mini/mini-generic-sharing.c
src/mono/mono/mini/mini.c
src/mono/mono/utils/options-def.h