[mono][aot] Optimize constrained calls made from gsharedvt methods. (#79339)
authorZoltan Varga <vargaz@gmail.com>
Wed, 8 Feb 2023 04:01:29 +0000 (23:01 -0500)
committerGitHub <noreply@github.com>
Wed, 8 Feb 2023 04:01:29 +0000 (23:01 -0500)
commit1b788f4dc3e3a8829488e52c032ad6a70671e070
tree0cbd92fe856b8b832f7b3644d276c84a72267e3e
parent8f3a34da468f970e268bd3b17247d77732991b00
[mono][aot] Optimize constrained calls made from gsharedvt methods. (#79339)

The calls are of the form:
.constrained T_GSHAREDVT
callvirt <method>

Whenever T_GSHAREDVT is a reference or value type is only known at runtime.

Previously these were handled by passing the arguments to a JIT icall which
computed the target method and did a runtime invoke.

Added 2 optimizations:
* Precompute the data which depends only on the type and the method,
  store it in an rgctx slot and pass it to the JIT icall.
* Add a fastpath for simpler cases which makes an indirect call
  from generated code.
src/mono/mono/metadata/icall-signatures.h
src/mono/mono/metadata/jit-icall-reg.h
src/mono/mono/mini/jit-icalls.c
src/mono/mono/mini/jit-icalls.h
src/mono/mono/mini/method-to-ir.c
src/mono/mono/mini/mini-generic-sharing.c
src/mono/mono/mini/mini-runtime.c
src/mono/mono/mini/mini.h