docs/project/updating-jitinterface.md
JitInterface is the binary interface that is used to communicate with the JIT. The bulk of the interface consists of the ICorStaticInfo and ICorDynamicInfo interfaces and enums/structs used by those interfaces.
The JitInterface serves two purposes:
There are several components that consume the JIT outside of the runtime. Since those components don't consume the JIT using the header, changes to the JIT have to be ported manually.
The JitInterface is versioned by a GUID. Any change to JitInterface is required to update the JitInterface GUID located in jiteeversionguid.h (look for JITEEVersionIdentifier). Not doing so has consequences that are sometimes hard to debug.
It's a good idea to choose an existing API that is similar to the one you want to add and use it as a template. The following steps are required to add a new JIT-VM API:
ThunkInput.txt file. This file is used to generate the JIT-VM interface and is located in src/coreclr/tools/Common/JitInterface/ThunkGenerator/. For complex types, you may need to also configure type mapping in the beginning of the file.gen.sh script (or gen.bat on Windows) to update the auto-generated files *_generated.* and update the JIT-EE guid.src/coreclr/inc/corinfo.h and add the new API in ICorStaticInfosrc/coreclr/tools/Common/JitInterface/CorInfoImpl.cs and add the new API in CorInfoImpl class. If the implementation is not shared for NativeAOT and R2R, use CorInfoImpl.RyuJit.cs and CorInfoImpl.ReadyToRun.cs to implement the API.src/coreclr/vm/jitinterface.cpp and add the CoreCLR-specific implementationlwmlist.h and add a definition of "input-args" - "output-args" map. Either use the generic DLD-like structs or create new ones in agnostic.hsrc/coreclr/tools/superpmi/superpmi-shared/methodcontext.h and add the necessary recording, dumping, and replaying methods for the new API and then implement them in methodcontext.cppenum mcPackets in src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h to include an entry for the new API and bump the max value of the enumrec* and rep* methods in src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp and src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp accordinglyadd-new-jit-ee-api.prompt.md contains a prompt that can be used to add a new JIT-VM API through an agent. Example usage in VSCode: