1//
2// Copyright (c) Microsoft. All rights reserved.
3// Licensed under the MIT license. See LICENSE file in the project root for full license information.
4//
5
6#ifndef _ICorJitCompilerImpl
7#define _ICorJitCompilerImpl
8
9// ICorJitCompilerImpl: declare for implementation all the members of the ICorJitCompiler interface (which are
10// specified as pure virtual methods). This is done once, here, and all implementations share it,
11// to avoid duplicated declarations. This file is #include'd within all the ICorJitCompiler implementation
12// classes.
13//
14// NOTE: this file is in exactly the same order, with exactly the same whitespace, as the ICorJitCompiler
15// interface declaration (with the "virtual" and "= 0" syntax removed). This is to make it easy to compare
16// against the interface declaration.
17
18public:
19// compileMethod is the main routine to ask the JIT Compiler to create native code for a method. The
20// method to be compiled is passed in the 'info' parameter, and the code:ICorJitInfo is used to allow the
21// JIT to resolve tokens, and make any other callbacks needed to create the code. nativeEntry, and
22// nativeSizeOfCode are just for convenience because the JIT asks the EE for the memory to emit code into
23// (see code:ICorJitInfo.allocMem), so really the EE already knows where the method starts and how big
24// it is (in fact, it could be in more than one chunk).
25//
26// * In the 32 bit jit this is implemented by code:CILJit.compileMethod
27// * For the 64 bit jit this is implemented by code:PreJit.compileMethod
28//
29// Note: Obfuscators that are hacking the JIT depend on this method having __stdcall calling convention
30CorJitResult __stdcall compileMethod(ICorJitInfo* comp, /* IN */
31 struct CORINFO_METHOD_INFO* info, /* IN */
32 unsigned /* code:CorJitFlag */ flags, /* IN */
33 BYTE** nativeEntry, /* OUT */
34 ULONG* nativeSizeOfCode /* OUT */
35 );
36
37// Some JIT compilers (most notably Phoenix), cache information about EE structures from one invocation
38// of the compiler to the next. This can be a problem when appdomains are unloaded, as some of this
39// cached information becomes stale. The code:ICorJitCompiler.isCacheCleanupRequired is called by the EE
40// early first to see if jit needs these notifications, and if so, the EE will call ClearCache is called
41// whenever the compiler should abandon its cache (eg on appdomain unload)
42void clearCache();
43BOOL isCacheCleanupRequired();
44
45// Do any appropriate work at process shutdown. Default impl is to do nothing.
46void ProcessShutdownWork(ICorStaticInfo* info); /* {}; */
47
48// The EE asks the JIT for a "version identifier". This represents the version of the JIT/EE interface.
49// If the JIT doesn't implement the same JIT/EE interface expected by the EE (because the JIT doesn't
50// return the version identifier that the EE expects), then the EE fails to load the JIT.
51//
52void getVersionIdentifier(GUID* versionIdentifier /* OUT */
53 );
54
55// When the EE loads the System.Numerics.Vectors assembly, it asks the JIT what length (in bytes) of
56// SIMD vector it supports as an intrinsic type. Zero means that the JIT does not support SIMD
57// intrinsics, so the EE should use the default size (i.e. the size of the IL implementation).
58unsigned getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags); /* { return 0; } */
59
60// IL obfuscators sometimes interpose on the EE-JIT interface. This function allows the VM to
61// tell the JIT to use a particular ICorJitCompiler to implement the methods of this interface,
62// and not to implement those methods itself. The JIT must not return this method when getJit()
63// is called. Instead, it must pass along all calls to this interface from within its own
64// ICorJitCompiler implementation. If 'realJitCompiler' is nullptr, then the JIT should resume
65// executing all the functions itself.
66void setRealJit(ICorJitCompiler* realJitCompiler); /* { } */
67
68#endif
69