9c2e08b3732d0ce9deaa59bdc4a508638567f453
[platform/upstream/dotnet/runtime.git] / src / coreclr / src / inc / corinfo.h
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 // 
6
7 /*****************************************************************************\
8 *                                                                             *
9 * CorInfo.h -    EE / Code generator interface                                *
10 *                                                                             *
11 *******************************************************************************
12 *
13 * This file exposes CLR runtime functionality. It can be used by compilers,
14 * both Just-in-time and ahead-of-time, to generate native code which
15 * executes in the runtime environment.
16 *******************************************************************************
17
18 //////////////////////////////////////////////////////////////////////////////////////////////////////////
19 //
20 // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
21 //
22 // The JIT/EE interface is versioned. By "interface", we mean mean any and all communication between the
23 // JIT and the EE. Any time a change is made to the interface, the JIT/EE interface version identifier
24 // must be updated. See code:JITEEVersionIdentifier for more information.
25 // 
26 // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
27 //
28 //////////////////////////////////////////////////////////////////////////////////////////////////////////
29
30 #EEJitContractDetails
31
32 The semantic contract between the EE and the JIT should be documented here It is incomplete, but as time goes
33 on, that hopefully will change
34
35 See file:../../doc/BookOfTheRuntime/JIT/JIT%20Design.doc for details on the JIT compiler. See
36 code:EEStartup#TableOfContents for information on the runtime as a whole.
37
38 -------------------------------------------------------------------------------
39 #Tokens
40
41 The tokens in IL stream needs to be resolved to EE handles (CORINFO_CLASS/METHOD/FIELD_HANDLE) that 
42 the runtime operates with. ICorStaticInfo::resolveToken is the method that resolves the found in IL stream 
43 to set of EE handles (CORINFO_RESOLVED_TOKEN). All other APIs take resolved token as input. This design 
44 avoids redundant token resolutions.
45
46 The token validation is done as part of token resolution. The JIT is not required to do explicit upfront
47 token validation.
48
49 -------------------------------------------------------------------------------
50 #ClassConstruction
51
52 First of all class contruction comes in two flavors precise and 'beforeFieldInit'. In C# you get the former
53 if you declare an explicit class constructor method and the later if you declaratively initialize static
54 fields. Precise class construction guarentees that the .cctor is run precisely before the first access to any
55 method or field of the class. 'beforeFieldInit' semantics guarentees only that the .cctor will be run some
56 time before the first static field access (note that calling methods (static or insance) or accessing
57 instance fields does not cause .cctors to be run).
58
59 Next you need to know that there are two kinds of code generation that can happen in the JIT: appdomain
60 neutral and appdomain specialized. The difference between these two kinds of code is how statics are handled.
61 For appdomain specific code, the address of a particular static variable is embeded in the code. This makes
62 it usable only for one appdomain (since every appdomain gets a own copy of its statics). Appdomain neutral
63 code calls a helper that looks up static variables off of a thread local variable. Thus the same code can be
64 used by mulitple appdomains in the same process.  
65
66 Generics also introduce a similar issue. Code for generic classes might be specialised for a particular set
67 of type arguments, or it could use helpers to access data that depends on type parameters and thus be shared
68 across several instantiations of the generic type.
69
70 Thus there four cases
71
72     * BeforeFieldInitCCtor - Unshared code. Cctors are only called when static fields are fetched. At the
73         time the method that touches the static field is JITed (or fixed up in the case of NGENed code), the
74         .cctor is called.
75     * BeforeFieldInitCCtor - Shared code. Since the same code is used for multiple classes, the act of JITing
76         the code can not be used as a hook. However, it is also the case that since the code is shared, it
77         can not wire in a particular address for the static and thus needs to use a helper that looks up the
78         correct address based on the thread ID. This helper does the .cctor check, and thus no additional
79         cctor logic is needed.
80     * PreciseCCtor - Unshared code. Any time a method is JITTed (or fixed up in the case of NGEN), a cctor
81         check for the class of the method being JITTed is done. In addition the JIT inserts explicit checks
82         before any static field accesses. Instance methods and fields do NOT have hooks because a .ctor
83         method must be called before the instance can be created.
84     * PreciseCctor - Shared code .cctor checks are placed in the prolog of every .ctor and static method. All
85         methods that access static fields have an explicit .cctor check before use. Again instance methods
86         don't have hooks because a .ctor would have to be called first.
87
88 Technically speaking, however the optimization of avoiding checks on instance methods is flawed. It requires
89 that a .ctor always preceed a call to an instance methods. This break down when
90
91     * A NULL is passed to an instance method.
92     * A .ctor does not call its superclasses .ctor. This allows an instance to be created without necessarily
93         calling all the .cctors of all the superclasses. A virtual call can then be made to a instance of a
94         superclass without necessarily calling the superclass's .cctor.
95     * The class is a value class (which exists without a .ctor being called)
96
97 Nevertheless, the cost of plugging these holes is considered to high and the benefit is low.
98
99 ----------------------------------------------------------------------
100
101 #ClassConstructionFlags 
102
103 Thus the JIT's cctor responsibilities require it to check with the EE on every static field access using
104 initClass and before jitting any method to see if a .cctor check must be placed in the prolog.
105
106     * CORINFO_FLG_BEFOREFIELDINIT indicate the class has beforeFieldInit semantics. The jit does not strictly
107         need this information however, it is valuable in optimizing static field fetch helper calls. Helper
108         call for classes with BeforeFieldInit semantics can be hoisted before other side effects where
109         classes with precise .cctor semantics do not allow this optimization.
110
111 Inlining also complicates things. Because the class could have precise semantics it is also required that the
112 inlining of any constructor or static method must also do the initClass check. The inliner has the option of 
113 inserting any required runtime check or simply not inlining the function.
114
115 -------------------------------------------------------------------------------
116
117 #StaticFields
118
119 The first 4 options are mutially exclusive 
120
121     * CORINFO_FLG_HELPER If the field has this set, then the JIT must call getFieldHelper and call the
122         returned helper with the object ref (for an instance field) and a fieldDesc. Note that this should be
123         able to handle ANY field so to get a JIT up quickly, it has the option of using helper calls for all
124         field access (and skip the complexity below). Note that for statics it is assumed that you will
125         alwasy ask for the ADDRESSS helper and to the fetch in the JIT.
126
127     * CORINFO_FLG_SHARED_HELPER This is currently only used for static fields. If this bit is set it means
128         that the field is feched by a helper call that takes a module identifier (see getModuleDomainID) and
129         a class identifier (see getClassDomainID) as arguments. The exact helper to call is determined by
130         getSharedStaticBaseHelper. The return value is of this function is the base of all statics in the
131         module. The offset from getFieldOffset must be added to this value to get the address of the field
132         itself. (see also CORINFO_FLG_STATIC_IN_HEAP).
133
134
135     * CORINFO_FLG_GENERICS_STATIC This is currently only used for static fields (of generic type). This
136         function is intended to be called with a Generic handle as a argument (from embedGenericHandle). The
137         exact helper to call is determined by getSharedStaticBaseHelper. The returned value is the base of
138         all statics in the class. The offset from getFieldOffset must be added to this value to get the
139         address of the (see also CORINFO_FLG_STATIC_IN_HEAP).
140
141     * CORINFO_FLG_TLS This indicate that the static field is a Windows style Thread Local Static. (We also
142         have managed thread local statics, which work through the HELPER. Support for this is considered
143         legacy, and going forward, the EE should
144
145     * <NONE> This is a normal static field. Its address in in memory is determined by getFieldAddress. (see
146         also CORINFO_FLG_STATIC_IN_HEAP).
147
148
149 This last field can modify any of the cases above except CORINFO_FLG_HELPER
150
151 CORINFO_FLG_STATIC_IN_HEAP This is currently only used for static fields of value classes. If the field has
152 this set then after computing what would normally be the field, what you actually get is a object pointer
153 (that must be reported to the GC) to a boxed version of the value. Thus the actual field address is computed
154 by addr = (*addr+sizeof(OBJECTREF))
155
156 Instance fields
157
158     * CORINFO_FLG_HELPER This is used if the class is MarshalByRef, which means that the object might be a
159         proxyt to the real object in some other appdomain or process. If the field has this set, then the JIT
160         must call getFieldHelper and call the returned helper with the object ref. If the helper returned is
161         helpers that are for structures the args are as follows
162
163     * CORINFO_HELP_GETFIELDSTRUCT - args are: retBuff, object, fieldDesc 
164     * CORINFO_HELP_SETFIELDSTRUCT - args are object fieldDesc value
165
166 The other GET helpers take an object fieldDesc and return the value The other SET helpers take an object
167 fieldDesc and value
168
169     Note that unlike static fields there is no helper to take the address of a field because in general there
170     is no address for proxies (LDFLDA is illegal on proxies).
171
172     CORINFO_FLG_EnC This is to support adding new field for edit and continue. This field also indicates that
173     a helper is needed to access this field. However this helper is always CORINFO_HELP_GETFIELDADDR, and
174     this helper always takes the object and field handle and returns the address of the field. It is the
175                             JIT's responcibility to do the fetch or set. 
176
177 -------------------------------------------------------------------------------
178
179 TODO: Talk about initializing strutures before use 
180
181
182 *******************************************************************************
183 */
184
185 #ifndef _COR_INFO_H_
186 #define _COR_INFO_H_
187
188 #include <corhdr.h>
189 #include <specstrings.h>
190
191 //////////////////////////////////////////////////////////////////////////////////////////////////////////
192 //
193 // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
194 //
195 // #JITEEVersionIdentifier
196 //
197 // This GUID represents the version of the JIT/EE interface. Any time the interface between the JIT and
198 // the EE changes (by adding or removing methods to any interface shared between them), this GUID should
199 // be changed. This is the identifier verified by ICorJitCompiler::getVersionIdentifier().
200 //
201 // You can use "uuidgen.exe -s" to generate this value.
202 //
203 // **** NOTE TO INTEGRATORS:
204 //
205 // If there is a merge conflict here, because the version changed in two different places, you must
206 // create a **NEW** GUID, not simply choose one or the other!
207 //
208 // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
209 //
210 //////////////////////////////////////////////////////////////////////////////////////////////////////////
211
212 #if !defined(SELECTANY)
213     #define SELECTANY extern __declspec(selectany)
214 #endif
215
216 SELECTANY const GUID JITEEVersionIdentifier = { /* 28eb875f-b6a9-4a04-9ba7-69ba59deed46 */
217     0x28eb875f,
218     0xb6a9,
219     0x4a04,
220     { 0x9b, 0xa7, 0x69, 0xba, 0x59, 0xde, 0xed, 0x46 }
221 };
222
223 //////////////////////////////////////////////////////////////////////////////////////////////////////////
224 //
225 // END JITEEVersionIdentifier
226 //
227 //////////////////////////////////////////////////////////////////////////////////////////////////////////
228
229 // For System V on the CLR type system number of registers to pass in and return a struct is the same.
230 // The CLR type system allows only up to 2 eightbytes to be passed in registers. There is no SSEUP classification types.
231 #define CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS   2 
232 #define CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_RETURN_IN_REGISTERS 2
233 #define CLR_SYSTEMV_MAX_STRUCT_BYTES_TO_PASS_IN_REGISTERS       16
234
235 // System V struct passing
236 // The Classification types are described in the ABI spec at http://www.x86-64.org/documentation/abi.pdf
237 enum SystemVClassificationType : unsigned __int8
238 {
239     SystemVClassificationTypeUnknown            = 0,
240     SystemVClassificationTypeStruct             = 1,
241     SystemVClassificationTypeNoClass            = 2,
242     SystemVClassificationTypeMemory             = 3,
243     SystemVClassificationTypeInteger            = 4,
244     SystemVClassificationTypeIntegerReference   = 5,
245     SystemVClassificationTypeIntegerByRef       = 6,
246     SystemVClassificationTypeSSE                = 7,
247     // SystemVClassificationTypeSSEUp           = Unused, // Not supported by the CLR.
248     // SystemVClassificationTypeX87             = Unused, // Not supported by the CLR.
249     // SystemVClassificationTypeX87Up           = Unused, // Not supported by the CLR.
250     // SystemVClassificationTypeComplexX87      = Unused, // Not supported by the CLR.
251
252     // Internal flags - never returned outside of the classification implementation.
253
254     // This value represents a very special type with two eightbytes. 
255     // First ByRef, second Integer (platform int).
256     // The VM has a special Elem type for this type - ELEMENT_TYPE_TYPEDBYREF.
257     // This is the classification counterpart for that element type. It is used to detect 
258     // the special TypedReference type and specialize its classification.
259     // This type is represented as a struct with two fields. The classification needs to do
260     // special handling of it since the source/methadata type of the fieds is IntPtr. 
261     // The VM changes the first to ByRef. The second is left as IntPtr (TYP_I_IMPL really). The classification needs to match this and
262     // special handling is warranted (similar thing is done in the getGCLayout function for this type).
263     SystemVClassificationTypeTypedReference     = 8,
264     SystemVClassificationTypeMAX                = 9,
265 };
266
267 // Represents classification information for a struct.
268 struct SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR
269 {
270     SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR()
271     {
272         Initialize();
273     }
274
275     bool                        passedInRegisters; // Whether the struct is passable/passed (this includes struct returning) in registers.
276     unsigned __int8             eightByteCount;    // Number of eightbytes for this struct.
277     SystemVClassificationType   eightByteClassifications[CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS]; // The eightbytes type classification.
278     unsigned __int8             eightByteSizes[CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS];           // The size of the eightbytes (an eightbyte could include padding. This represents the no padding size of the eightbyte).
279     unsigned __int8             eightByteOffsets[CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS];         // The start offset of the eightbytes (in bytes).
280
281     // Members
282
283     //------------------------------------------------------------------------
284     // CopyFrom: Copies a struct classification into this one.
285     //
286     // Arguments:
287     //    'copyFrom' the struct classification to copy from.
288     //
289     void CopyFrom(const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR& copyFrom)
290     {
291         passedInRegisters = copyFrom.passedInRegisters;
292         eightByteCount = copyFrom.eightByteCount;
293
294         for (int i = 0; i < CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS; i++)
295         {
296             eightByteClassifications[i] = copyFrom.eightByteClassifications[i];
297             eightByteSizes[i] = copyFrom.eightByteSizes[i];
298             eightByteOffsets[i] = copyFrom.eightByteOffsets[i];
299         }
300     }
301
302     //------------------------------------------------------------------------
303     // IsIntegralSlot: Returns whether the eightbyte at slotIndex is of integral type.
304     //
305     // Arguments:
306     //    'slotIndex' the slot number we are determining if it is of integral type.
307     //
308     // Return value:
309     //     returns true if we the eightbyte at index slotIndex is of integral type.
310     // 
311
312     bool IsIntegralSlot(unsigned slotIndex) const
313     {
314         return ((eightByteClassifications[slotIndex] == SystemVClassificationTypeInteger) ||
315                 (eightByteClassifications[slotIndex] == SystemVClassificationTypeIntegerReference) ||
316                 (eightByteClassifications[slotIndex] == SystemVClassificationTypeIntegerByRef));
317     }
318
319     //------------------------------------------------------------------------
320     // IsSseSlot: Returns whether the eightbyte at slotIndex is SSE type.
321     //
322     // Arguments:
323     //    'slotIndex' the slot number we are determining if it is of SSE type.
324     //
325     // Return value:
326     //     returns true if we the eightbyte at index slotIndex is of SSE type.
327     // 
328     // Follows the rules of the AMD64 System V ABI specification at www.x86-64.org/documentation/abi.pdf.
329     // Please reffer to it for definitions/examples.
330     //
331     bool IsSseSlot(unsigned slotIndex) const
332     {
333         return (eightByteClassifications[slotIndex] == SystemVClassificationTypeSSE);
334     }
335
336 private:
337     void Initialize()
338     {
339         passedInRegisters = false;
340         eightByteCount = 0;
341
342         for (int i = 0; i < CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS; i++)
343         {
344             eightByteClassifications[i] = SystemVClassificationTypeUnknown;
345             eightByteSizes[i] = 0;
346             eightByteOffsets[i] = 0;
347         }
348     }
349 };
350
351 // CorInfoHelpFunc defines the set of helpers (accessed via the ICorDynamicInfo::getHelperFtn())
352 // These helpers can be called by native code which executes in the runtime.
353 // Compilers can emit calls to these helpers.
354 //
355 // The signatures of the helpers are below (see RuntimeHelperArgumentCheck)
356
357 enum CorInfoHelpFunc
358 {
359     CORINFO_HELP_UNDEF,         // invalid value. This should never be used
360
361     /* Arithmetic helpers */
362
363     CORINFO_HELP_DIV,           // For the ARM 32-bit integer divide uses a helper call :-(
364     CORINFO_HELP_MOD,
365     CORINFO_HELP_UDIV,
366     CORINFO_HELP_UMOD,
367
368     CORINFO_HELP_LLSH,
369     CORINFO_HELP_LRSH,
370     CORINFO_HELP_LRSZ,
371     CORINFO_HELP_LMUL,
372     CORINFO_HELP_LMUL_OVF,
373     CORINFO_HELP_ULMUL_OVF,
374     CORINFO_HELP_LDIV,
375     CORINFO_HELP_LMOD,
376     CORINFO_HELP_ULDIV,
377     CORINFO_HELP_ULMOD,
378     CORINFO_HELP_LNG2DBL,               // Convert a signed int64 to a double
379     CORINFO_HELP_ULNG2DBL,              // Convert a unsigned int64 to a double
380     CORINFO_HELP_DBL2INT,
381     CORINFO_HELP_DBL2INT_OVF,
382     CORINFO_HELP_DBL2LNG,
383     CORINFO_HELP_DBL2LNG_OVF,
384     CORINFO_HELP_DBL2UINT,
385     CORINFO_HELP_DBL2UINT_OVF,
386     CORINFO_HELP_DBL2ULNG,
387     CORINFO_HELP_DBL2ULNG_OVF,
388     CORINFO_HELP_FLTREM,
389     CORINFO_HELP_DBLREM,
390     CORINFO_HELP_FLTROUND,
391     CORINFO_HELP_DBLROUND,
392
393     /* Allocating a new object. Always use ICorClassInfo::getNewHelper() to decide 
394        which is the right helper to use to allocate an object of a given type. */
395
396     CORINFO_HELP_NEW_CROSSCONTEXT,  // cross context new object
397     CORINFO_HELP_NEWFAST,
398     CORINFO_HELP_NEWSFAST,          // allocator for small, non-finalizer, non-array object
399     CORINFO_HELP_NEWSFAST_ALIGN8,   // allocator for small, non-finalizer, non-array object, 8 byte aligned
400     CORINFO_HELP_NEW_MDARR,         // multi-dim array helper (with or without lower bounds - dimensions passed in as vararg)
401     CORINFO_HELP_NEW_MDARR_NONVARARG,// multi-dim array helper (with or without lower bounds - dimensions passed in as unmanaged array)
402     CORINFO_HELP_NEWARR_1_DIRECT,   // helper for any one dimensional array creation
403     CORINFO_HELP_NEWARR_1_R2R_DIRECT, // wrapper for R2R direct call, which extracts method table from ArrayTypeDesc
404     CORINFO_HELP_NEWARR_1_OBJ,      // optimized 1-D object arrays
405     CORINFO_HELP_NEWARR_1_VC,       // optimized 1-D value class arrays
406     CORINFO_HELP_NEWARR_1_ALIGN8,   // like VC, but aligns the array start
407
408     CORINFO_HELP_STRCNS,            // create a new string literal
409     CORINFO_HELP_STRCNS_CURRENT_MODULE, // create a new string literal from the current module (used by NGen code)
410
411     /* Object model */
412
413     CORINFO_HELP_INITCLASS,         // Initialize class if not already initialized
414     CORINFO_HELP_INITINSTCLASS,     // Initialize class for instantiated type
415
416     // Use ICorClassInfo::getCastingHelper to determine
417     // the right helper to use
418
419     CORINFO_HELP_ISINSTANCEOFINTERFACE, // Optimized helper for interfaces
420     CORINFO_HELP_ISINSTANCEOFARRAY,  // Optimized helper for arrays
421     CORINFO_HELP_ISINSTANCEOFCLASS, // Optimized helper for classes
422     CORINFO_HELP_ISINSTANCEOFANY,   // Slow helper for any type
423
424     CORINFO_HELP_CHKCASTINTERFACE,
425     CORINFO_HELP_CHKCASTARRAY,
426     CORINFO_HELP_CHKCASTCLASS,
427     CORINFO_HELP_CHKCASTANY,
428     CORINFO_HELP_CHKCASTCLASS_SPECIAL, // Optimized helper for classes. Assumes that the trivial cases 
429                                     // has been taken care of by the inlined check
430
431     CORINFO_HELP_BOX,
432     CORINFO_HELP_BOX_NULLABLE,      // special form of boxing for Nullable<T>
433     CORINFO_HELP_UNBOX,
434     CORINFO_HELP_UNBOX_NULLABLE,    // special form of unboxing for Nullable<T>
435     CORINFO_HELP_GETREFANY,         // Extract the byref from a TypedReference, checking that it is the expected type
436
437     CORINFO_HELP_ARRADDR_ST,        // assign to element of object array with type-checking
438     CORINFO_HELP_LDELEMA_REF,       // does a precise type comparision and returns address
439
440     /* Exceptions */
441
442     CORINFO_HELP_THROW,             // Throw an exception object
443     CORINFO_HELP_RETHROW,           // Rethrow the currently active exception
444     CORINFO_HELP_USER_BREAKPOINT,   // For a user program to break to the debugger
445     CORINFO_HELP_RNGCHKFAIL,        // array bounds check failed
446     CORINFO_HELP_OVERFLOW,          // throw an overflow exception
447     CORINFO_HELP_THROWDIVZERO,      // throw a divide by zero exception
448     CORINFO_HELP_THROWNULLREF,      // throw a null reference exception
449
450     CORINFO_HELP_INTERNALTHROW,     // Support for really fast jit
451     CORINFO_HELP_VERIFICATION,      // Throw a VerificationException
452     CORINFO_HELP_SEC_UNMGDCODE_EXCPT, // throw a security unmanaged code exception
453     CORINFO_HELP_FAIL_FAST,         // Kill the process avoiding any exceptions or stack and data dependencies (use for GuardStack unsafe buffer checks)
454
455     CORINFO_HELP_METHOD_ACCESS_EXCEPTION,//Throw an access exception due to a failed member/class access check.
456     CORINFO_HELP_FIELD_ACCESS_EXCEPTION,
457     CORINFO_HELP_CLASS_ACCESS_EXCEPTION,
458
459     CORINFO_HELP_ENDCATCH,          // call back into the EE at the end of a catch block
460
461     /* Synchronization */
462
463     CORINFO_HELP_MON_ENTER,
464     CORINFO_HELP_MON_EXIT,
465     CORINFO_HELP_MON_ENTER_STATIC,
466     CORINFO_HELP_MON_EXIT_STATIC,
467
468     CORINFO_HELP_GETCLASSFROMMETHODPARAM, // Given a generics method handle, returns a class handle
469     CORINFO_HELP_GETSYNCFROMCLASSHANDLE,  // Given a generics class handle, returns the sync monitor 
470                                           // in its ManagedClassObject
471
472     /* Security callout support */
473     
474     CORINFO_HELP_SECURITY_PROLOG,   // Required if CORINFO_FLG_SECURITYCHECK is set, or CORINFO_FLG_NOSECURITYWRAP is not set
475     CORINFO_HELP_SECURITY_PROLOG_FRAMED, // Slow version of CORINFO_HELP_SECURITY_PROLOG. Used for instrumentation.
476
477     CORINFO_HELP_METHOD_ACCESS_CHECK, // Callouts to runtime security access checks
478     CORINFO_HELP_FIELD_ACCESS_CHECK,
479     CORINFO_HELP_CLASS_ACCESS_CHECK,
480
481     CORINFO_HELP_DELEGATE_SECURITY_CHECK, // Callout to delegate security transparency check
482
483      /* Verification runtime callout support */
484
485     CORINFO_HELP_VERIFICATION_RUNTIME_CHECK, // Do a Demand for UnmanagedCode permission at runtime
486
487     /* GC support */
488
489     CORINFO_HELP_STOP_FOR_GC,       // Call GC (force a GC)
490     CORINFO_HELP_POLL_GC,           // Ask GC if it wants to collect
491
492     CORINFO_HELP_STRESS_GC,         // Force a GC, but then update the JITTED code to be a noop call
493     CORINFO_HELP_CHECK_OBJ,         // confirm that ECX is a valid object pointer (debugging only)
494
495     /* GC Write barrier support */
496
497     CORINFO_HELP_ASSIGN_REF,        // universal helpers with F_CALL_CONV calling convention
498     CORINFO_HELP_CHECKED_ASSIGN_REF,
499     CORINFO_HELP_ASSIGN_REF_ENSURE_NONHEAP,  // Do the store, and ensure that the target was not in the heap.
500
501     CORINFO_HELP_ASSIGN_BYREF,
502     CORINFO_HELP_ASSIGN_STRUCT,
503
504
505     /* Accessing fields */
506
507     // For COM object support (using COM get/set routines to update object)
508     // and EnC and cross-context support
509     CORINFO_HELP_GETFIELD8,
510     CORINFO_HELP_SETFIELD8,
511     CORINFO_HELP_GETFIELD16,
512     CORINFO_HELP_SETFIELD16,
513     CORINFO_HELP_GETFIELD32,
514     CORINFO_HELP_SETFIELD32,
515     CORINFO_HELP_GETFIELD64,
516     CORINFO_HELP_SETFIELD64,
517     CORINFO_HELP_GETFIELDOBJ,
518     CORINFO_HELP_SETFIELDOBJ,
519     CORINFO_HELP_GETFIELDSTRUCT,
520     CORINFO_HELP_SETFIELDSTRUCT,
521     CORINFO_HELP_GETFIELDFLOAT,
522     CORINFO_HELP_SETFIELDFLOAT,
523     CORINFO_HELP_GETFIELDDOUBLE,
524     CORINFO_HELP_SETFIELDDOUBLE,
525
526     CORINFO_HELP_GETFIELDADDR,
527
528     CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT,    // Helper for context-static fields
529     CORINFO_HELP_GETSTATICFIELDADDR_TLS,        // Helper for PE TLS fields
530
531     // There are a variety of specialized helpers for accessing static fields. The JIT should use 
532     // ICorClassInfo::getSharedStaticsOrCCtorHelper to determine which helper to use
533
534     // Helpers for regular statics
535     CORINFO_HELP_GETGENERICS_GCSTATIC_BASE,
536     CORINFO_HELP_GETGENERICS_NONGCSTATIC_BASE,
537     CORINFO_HELP_GETSHARED_GCSTATIC_BASE,
538     CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE,
539     CORINFO_HELP_GETSHARED_GCSTATIC_BASE_NOCTOR,
540     CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_NOCTOR,
541     CORINFO_HELP_GETSHARED_GCSTATIC_BASE_DYNAMICCLASS,
542     CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_DYNAMICCLASS,
543     // Helper to class initialize shared generic with dynamicclass, but not get static field address
544     CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS,
545
546     // Helpers for thread statics
547     CORINFO_HELP_GETGENERICS_GCTHREADSTATIC_BASE,
548     CORINFO_HELP_GETGENERICS_NONGCTHREADSTATIC_BASE,
549     CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE,
550     CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE,
551     CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR,
552     CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR,
553     CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS,
554     CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS,
555
556     /* Debugger */
557
558     CORINFO_HELP_DBG_IS_JUST_MY_CODE,    // Check if this is "JustMyCode" and needs to be stepped through.
559
560     /* Profiling enter/leave probe addresses */
561     CORINFO_HELP_PROF_FCN_ENTER,        // record the entry to a method (caller)
562     CORINFO_HELP_PROF_FCN_LEAVE,        // record the completion of current method (caller)
563     CORINFO_HELP_PROF_FCN_TAILCALL,     // record the completionof current method through tailcall (caller)
564
565     /* Miscellaneous */
566
567     CORINFO_HELP_BBT_FCN_ENTER,         // record the entry to a method for collecting Tuning data
568
569     CORINFO_HELP_PINVOKE_CALLI,         // Indirect pinvoke call
570     CORINFO_HELP_TAILCALL,              // Perform a tail call
571     
572     CORINFO_HELP_GETCURRENTMANAGEDTHREADID,
573
574     CORINFO_HELP_INIT_PINVOKE_FRAME,   // initialize an inlined PInvoke Frame for the JIT-compiler
575
576     CORINFO_HELP_MEMSET,                // Init block of memory
577     CORINFO_HELP_MEMCPY,                // Copy block of memory
578
579     CORINFO_HELP_RUNTIMEHANDLE_METHOD,          // determine a type/field/method handle at run-time
580     CORINFO_HELP_RUNTIMEHANDLE_METHOD_LOG,      // determine a type/field/method handle at run-time, with IBC logging
581     CORINFO_HELP_RUNTIMEHANDLE_CLASS,           // determine a type/field/method handle at run-time
582     CORINFO_HELP_RUNTIMEHANDLE_CLASS_LOG,       // determine a type/field/method handle at run-time, with IBC logging
583
584     // These helpers are required for MDIL backward compatibility only. They are not used by current JITed code.
585     CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_OBSOLETE, // Convert from a TypeHandle (native structure pointer) to RuntimeTypeHandle at run-time
586     CORINFO_HELP_METHODDESC_TO_RUNTIMEMETHODHANDLE_OBSOLETE, // Convert from a MethodDesc (native structure pointer) to RuntimeMethodHandle at run-time
587     CORINFO_HELP_FIELDDESC_TO_RUNTIMEFIELDHANDLE_OBSOLETE, // Convert from a FieldDesc (native structure pointer) to RuntimeFieldHandle at run-time
588
589     CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE, // Convert from a TypeHandle (native structure pointer) to RuntimeType at run-time
590     CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL, // Convert from a TypeHandle (native structure pointer) to RuntimeType at run-time, the type may be null
591     CORINFO_HELP_METHODDESC_TO_STUBRUNTIMEMETHOD, // Convert from a MethodDesc (native structure pointer) to RuntimeMethodHandle at run-time
592     CORINFO_HELP_FIELDDESC_TO_STUBRUNTIMEFIELD, // Convert from a FieldDesc (native structure pointer) to RuntimeFieldHandle at run-time
593
594     CORINFO_HELP_VIRTUAL_FUNC_PTR,      // look up a virtual method at run-time
595     //CORINFO_HELP_VIRTUAL_FUNC_PTR_LOG,  // look up a virtual method at run-time, with IBC logging
596
597     // Not a real helpers. Instead of taking handle arguments, these helpers point to a small stub that loads the handle argument and calls the static helper.
598     CORINFO_HELP_READYTORUN_NEW,
599     CORINFO_HELP_READYTORUN_NEWARR_1,
600     CORINFO_HELP_READYTORUN_ISINSTANCEOF,
601     CORINFO_HELP_READYTORUN_CHKCAST,
602     CORINFO_HELP_READYTORUN_STATIC_BASE,
603     CORINFO_HELP_READYTORUN_VIRTUAL_FUNC_PTR,
604     CORINFO_HELP_READYTORUN_GENERIC_HANDLE,
605     CORINFO_HELP_READYTORUN_DELEGATE_CTOR,
606     CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE,
607
608     CORINFO_HELP_EE_PRESTUB,            // Not real JIT helper. Used in native images.
609
610     CORINFO_HELP_EE_PRECODE_FIXUP,      // Not real JIT helper. Used for Precode fixup in native images.
611     CORINFO_HELP_EE_PINVOKE_FIXUP,      // Not real JIT helper. Used for PInvoke target fixup in native images.
612     CORINFO_HELP_EE_VSD_FIXUP,          // Not real JIT helper. Used for VSD cell fixup in native images.
613     CORINFO_HELP_EE_EXTERNAL_FIXUP,     // Not real JIT helper. Used for to fixup external method thunks in native images.
614     CORINFO_HELP_EE_VTABLE_FIXUP,       // Not real JIT helper. Used for inherited vtable slot fixup in native images.
615
616     CORINFO_HELP_EE_REMOTING_THUNK,     // Not real JIT helper. Used for remoting precode in native images.
617
618     CORINFO_HELP_EE_PERSONALITY_ROUTINE,// Not real JIT helper. Used in native images.
619     CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET,// Not real JIT helper. Used in native images to detect filter funclets.
620
621     // ASSIGN_REF_EAX - CHECKED_ASSIGN_REF_EBP: NOGC_WRITE_BARRIERS JIT helper calls
622     //
623     // For unchecked versions EDX is required to point into GC heap.
624     //
625     // NOTE: these helpers are only used for x86.
626     CORINFO_HELP_ASSIGN_REF_EAX,    // EAX holds GC ptr, do a 'mov [EDX], EAX' and inform GC
627     CORINFO_HELP_ASSIGN_REF_EBX,    // EBX holds GC ptr, do a 'mov [EDX], EBX' and inform GC
628     CORINFO_HELP_ASSIGN_REF_ECX,    // ECX holds GC ptr, do a 'mov [EDX], ECX' and inform GC
629     CORINFO_HELP_ASSIGN_REF_ESI,    // ESI holds GC ptr, do a 'mov [EDX], ESI' and inform GC
630     CORINFO_HELP_ASSIGN_REF_EDI,    // EDI holds GC ptr, do a 'mov [EDX], EDI' and inform GC
631     CORINFO_HELP_ASSIGN_REF_EBP,    // EBP holds GC ptr, do a 'mov [EDX], EBP' and inform GC
632
633     CORINFO_HELP_CHECKED_ASSIGN_REF_EAX,  // These are the same as ASSIGN_REF above ...
634     CORINFO_HELP_CHECKED_ASSIGN_REF_EBX,  // ... but also check if EDX points into heap.
635     CORINFO_HELP_CHECKED_ASSIGN_REF_ECX,
636     CORINFO_HELP_CHECKED_ASSIGN_REF_ESI,
637     CORINFO_HELP_CHECKED_ASSIGN_REF_EDI,
638     CORINFO_HELP_CHECKED_ASSIGN_REF_EBP,
639
640     CORINFO_HELP_LOOP_CLONE_CHOICE_ADDR, // Return the reference to a counter to decide to take cloned path in debug stress.
641     CORINFO_HELP_DEBUG_LOG_LOOP_CLONING, // Print a message that a loop cloning optimization has occurred in debug mode.
642
643     CORINFO_HELP_THROW_ARGUMENTEXCEPTION,           // throw ArgumentException
644     CORINFO_HELP_THROW_ARGUMENTOUTOFRANGEEXCEPTION, // throw ArgumentOutOfRangeException
645
646     CORINFO_HELP_JIT_PINVOKE_BEGIN, // Transition to preemptive mode before a P/Invoke, frame is the first argument
647     CORINFO_HELP_JIT_PINVOKE_END,   // Transition to cooperative mode after a P/Invoke, frame is the first argument
648
649     CORINFO_HELP_JIT_REVERSE_PINVOKE_ENTER, // Transition to cooperative mode in reverse P/Invoke prolog, frame is the first argument
650     CORINFO_HELP_JIT_REVERSE_PINVOKE_EXIT,  // Transition to preemptive mode in reverse P/Invoke epilog, frame is the first argument
651
652     CORINFO_HELP_GVMLOOKUP_FOR_SLOT,        // Resolve a generic virtual method target from this pointer and runtime method handle 
653
654     CORINFO_HELP_COUNT,
655 };
656
657 #define CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE 0x40000000
658
659 //This describes the signature for a helper method.
660 enum CorInfoHelpSig
661 {
662     CORINFO_HELP_SIG_UNDEF,
663     CORINFO_HELP_SIG_NO_ALIGN_STUB,
664     CORINFO_HELP_SIG_NO_UNWIND_STUB,
665     CORINFO_HELP_SIG_REG_ONLY,
666     CORINFO_HELP_SIG_4_STACK,
667     CORINFO_HELP_SIG_8_STACK,
668     CORINFO_HELP_SIG_12_STACK,
669     CORINFO_HELP_SIG_16_STACK,
670     CORINFO_HELP_SIG_8_VA, //2 arguments plus varargs
671
672     CORINFO_HELP_SIG_EBPCALL, //special calling convention that uses EDX and
673                               //EBP as arguments
674
675     CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB,
676
677     CORINFO_HELP_SIG_COUNT
678 };
679
680 // The enumeration is returned in 'getSig','getType', getArgType methods
681 enum CorInfoType
682 {
683     CORINFO_TYPE_UNDEF           = 0x0,
684     CORINFO_TYPE_VOID            = 0x1,
685     CORINFO_TYPE_BOOL            = 0x2,
686     CORINFO_TYPE_CHAR            = 0x3,
687     CORINFO_TYPE_BYTE            = 0x4,
688     CORINFO_TYPE_UBYTE           = 0x5,
689     CORINFO_TYPE_SHORT           = 0x6,
690     CORINFO_TYPE_USHORT          = 0x7,
691     CORINFO_TYPE_INT             = 0x8,
692     CORINFO_TYPE_UINT            = 0x9,
693     CORINFO_TYPE_LONG            = 0xa,
694     CORINFO_TYPE_ULONG           = 0xb,
695     CORINFO_TYPE_NATIVEINT       = 0xc,
696     CORINFO_TYPE_NATIVEUINT      = 0xd,
697     CORINFO_TYPE_FLOAT           = 0xe,
698     CORINFO_TYPE_DOUBLE          = 0xf,
699     CORINFO_TYPE_STRING          = 0x10,         // Not used, should remove
700     CORINFO_TYPE_PTR             = 0x11,
701     CORINFO_TYPE_BYREF           = 0x12,
702     CORINFO_TYPE_VALUECLASS      = 0x13,
703     CORINFO_TYPE_CLASS           = 0x14,
704     CORINFO_TYPE_REFANY          = 0x15,
705
706     // CORINFO_TYPE_VAR is for a generic type variable.
707     // Generic type variables only appear when the JIT is doing
708     // verification (not NOT compilation) of generic code
709     // for the EE, in which case we're running
710     // the JIT in "import only" mode.
711
712     CORINFO_TYPE_VAR             = 0x16,
713     CORINFO_TYPE_COUNT,                         // number of jit types
714 };
715
716 enum CorInfoTypeWithMod
717 {
718     CORINFO_TYPE_MASK            = 0x3F,        // lower 6 bits are type mask
719     CORINFO_TYPE_MOD_PINNED      = 0x40,        // can be applied to CLASS, or BYREF to indiate pinned
720 };
721
722 inline CorInfoType strip(CorInfoTypeWithMod val) {
723     return CorInfoType(val & CORINFO_TYPE_MASK);
724 }
725
726 // The enumeration is returned in 'getSig'
727
728 enum CorInfoCallConv
729 {
730     // These correspond to CorCallingConvention
731
732     CORINFO_CALLCONV_DEFAULT    = 0x0,
733     CORINFO_CALLCONV_C          = 0x1,
734     CORINFO_CALLCONV_STDCALL    = 0x2,
735     CORINFO_CALLCONV_THISCALL   = 0x3,
736     CORINFO_CALLCONV_FASTCALL   = 0x4,
737     CORINFO_CALLCONV_VARARG     = 0x5,
738     CORINFO_CALLCONV_FIELD      = 0x6,
739     CORINFO_CALLCONV_LOCAL_SIG  = 0x7,
740     CORINFO_CALLCONV_PROPERTY   = 0x8,
741     CORINFO_CALLCONV_NATIVEVARARG = 0xb,    // used ONLY for IL stub PInvoke vararg calls
742
743     CORINFO_CALLCONV_MASK       = 0x0f,     // Calling convention is bottom 4 bits
744     CORINFO_CALLCONV_GENERIC    = 0x10,
745     CORINFO_CALLCONV_HASTHIS    = 0x20,
746     CORINFO_CALLCONV_EXPLICITTHIS=0x40,
747     CORINFO_CALLCONV_PARAMTYPE  = 0x80,     // Passed last. Same as CORINFO_GENERICS_CTXT_FROM_PARAMTYPEARG
748 };
749
750 #ifdef UNIX_X86_ABI
751 inline bool IsCallerPop(CorInfoCallConv callConv)
752 {
753     unsigned int umask = CORINFO_CALLCONV_STDCALL
754                        | CORINFO_CALLCONV_THISCALL
755                        | CORINFO_CALLCONV_FASTCALL;
756
757     return !(callConv & umask);
758 }
759 #endif // UNIX_X86_ABI
760
761 enum CorInfoUnmanagedCallConv
762 {
763     // These correspond to CorUnmanagedCallingConvention
764
765     CORINFO_UNMANAGED_CALLCONV_UNKNOWN,
766     CORINFO_UNMANAGED_CALLCONV_C,
767     CORINFO_UNMANAGED_CALLCONV_STDCALL,
768     CORINFO_UNMANAGED_CALLCONV_THISCALL,
769     CORINFO_UNMANAGED_CALLCONV_FASTCALL
770 };
771
772 // These are returned from getMethodOptions
773 enum CorInfoOptions
774 {
775     CORINFO_OPT_INIT_LOCALS                 = 0x00000010, // zero initialize all variables
776
777     CORINFO_GENERICS_CTXT_FROM_THIS         = 0x00000020, // is this shared generic code that access the generic context from the this pointer?  If so, then if the method has SEH then the 'this' pointer must always be reported and kept alive.
778     CORINFO_GENERICS_CTXT_FROM_METHODDESC   = 0x00000040, // is this shared generic code that access the generic context from the ParamTypeArg(that is a MethodDesc)?  If so, then if the method has SEH then the 'ParamTypeArg' must always be reported and kept alive. Same as CORINFO_CALLCONV_PARAMTYPE
779     CORINFO_GENERICS_CTXT_FROM_METHODTABLE  = 0x00000080, // is this shared generic code that access the generic context from the ParamTypeArg(that is a MethodTable)?  If so, then if the method has SEH then the 'ParamTypeArg' must always be reported and kept alive. Same as CORINFO_CALLCONV_PARAMTYPE
780     CORINFO_GENERICS_CTXT_MASK              = (CORINFO_GENERICS_CTXT_FROM_THIS |
781                                                CORINFO_GENERICS_CTXT_FROM_METHODDESC |
782                                                CORINFO_GENERICS_CTXT_FROM_METHODTABLE),
783     CORINFO_GENERICS_CTXT_KEEP_ALIVE        = 0x00000100, // Keep the generics context alive throughout the method even if there is no explicit use, and report its location to the CLR
784
785 };
786
787 //
788 // what type of code region we are in
789 //
790 enum CorInfoRegionKind
791 {
792     CORINFO_REGION_NONE,
793     CORINFO_REGION_HOT,
794     CORINFO_REGION_COLD,
795     CORINFO_REGION_JIT,
796 };
797
798
799 // these are the attribute flags for fields and methods (getMethodAttribs)
800 enum CorInfoFlag
801 {
802 //  CORINFO_FLG_UNUSED                = 0x00000001,
803 //  CORINFO_FLG_UNUSED                = 0x00000002,
804     CORINFO_FLG_PROTECTED             = 0x00000004,
805     CORINFO_FLG_STATIC                = 0x00000008,
806     CORINFO_FLG_FINAL                 = 0x00000010,
807     CORINFO_FLG_SYNCH                 = 0x00000020,
808     CORINFO_FLG_VIRTUAL               = 0x00000040,
809 //  CORINFO_FLG_UNUSED                = 0x00000080,
810     CORINFO_FLG_NATIVE                = 0x00000100,
811 //  CORINFO_FLG_UNUSED                = 0x00000200,
812     CORINFO_FLG_ABSTRACT              = 0x00000400,
813
814     CORINFO_FLG_EnC                   = 0x00000800, // member was added by Edit'n'Continue
815
816     // These are internal flags that can only be on methods
817     CORINFO_FLG_FORCEINLINE           = 0x00010000, // The method should be inlined if possible.
818     CORINFO_FLG_SHAREDINST            = 0x00020000, // the code for this method is shared between different generic instantiations (also set on classes/types)
819     CORINFO_FLG_DELEGATE_INVOKE       = 0x00040000, // "Delegate
820     CORINFO_FLG_PINVOKE               = 0x00080000, // Is a P/Invoke call
821     CORINFO_FLG_SECURITYCHECK         = 0x00100000, // Is one of the security routines that does a stackwalk (e.g. Assert, Demand)
822     CORINFO_FLG_NOGCCHECK             = 0x00200000, // This method is FCALL that has no GC check.  Don't put alone in loops
823     CORINFO_FLG_INTRINSIC             = 0x00400000, // This method MAY have an intrinsic ID
824     CORINFO_FLG_CONSTRUCTOR           = 0x00800000, // This method is an instance or type initializer
825 //  CORINFO_FLG_UNUSED                = 0x01000000,
826 //  CORINFO_FLG_UNUSED                = 0x02000000,
827     CORINFO_FLG_NOSECURITYWRAP        = 0x04000000, // The method requires no security checks
828     CORINFO_FLG_DONT_INLINE           = 0x10000000, // The method should not be inlined
829     CORINFO_FLG_DONT_INLINE_CALLER    = 0x20000000, // The method should not be inlined, nor should its callers. It cannot be tail called.
830 //  CORINFO_FLG_UNUSED                = 0x40000000,
831
832     // These are internal flags that can only be on Classes
833     CORINFO_FLG_VALUECLASS            = 0x00010000, // is the class a value class
834 //  This flag is define din the Methods section, but is also valid on classes.
835 //  CORINFO_FLG_SHAREDINST            = 0x00020000, // This class is satisfies TypeHandle::IsCanonicalSubtype
836     CORINFO_FLG_VAROBJSIZE            = 0x00040000, // the object size varies depending of constructor args
837     CORINFO_FLG_ARRAY                 = 0x00080000, // class is an array class (initialized differently)
838     CORINFO_FLG_OVERLAPPING_FIELDS    = 0x00100000, // struct or class has fields that overlap (aka union)
839     CORINFO_FLG_INTERFACE             = 0x00200000, // it is an interface
840     CORINFO_FLG_CONTEXTFUL            = 0x00400000, // is this a contextful class?
841     CORINFO_FLG_CUSTOMLAYOUT          = 0x00800000, // does this struct have custom layout?
842     CORINFO_FLG_CONTAINS_GC_PTR       = 0x01000000, // does the class contain a gc ptr ?
843     CORINFO_FLG_DELEGATE              = 0x02000000, // is this a subclass of delegate or multicast delegate ?
844     CORINFO_FLG_MARSHAL_BYREF         = 0x04000000, // is this a subclass of MarshalByRef ?
845     CORINFO_FLG_CONTAINS_STACK_PTR    = 0x08000000, // This class has a stack pointer inside it
846     CORINFO_FLG_VARIANCE              = 0x10000000, // MethodTable::HasVariance (sealed does *not* mean uncast-able)
847     CORINFO_FLG_BEFOREFIELDINIT       = 0x20000000, // Additional flexibility for when to run .cctor (see code:#ClassConstructionFlags)
848     CORINFO_FLG_GENERIC_TYPE_VARIABLE = 0x40000000, // This is really a handle for a variable type
849     CORINFO_FLG_UNSAFE_VALUECLASS     = 0x80000000, // Unsafe (C++'s /GS) value type
850 };
851
852 // Flags computed by a runtime compiler
853 enum CorInfoMethodRuntimeFlags
854 {
855     CORINFO_FLG_BAD_INLINEE         = 0x00000001, // The method is not suitable for inlining
856     CORINFO_FLG_VERIFIABLE          = 0x00000002, // The method has verifiable code
857     CORINFO_FLG_UNVERIFIABLE        = 0x00000004, // The method has unverifiable code
858 };
859
860
861 enum CORINFO_ACCESS_FLAGS
862 {
863     CORINFO_ACCESS_ANY        = 0x0000, // Normal access
864     CORINFO_ACCESS_THIS       = 0x0001, // Accessed via the this reference
865     CORINFO_ACCESS_UNWRAP     = 0x0002, // Accessed via an unwrap reference
866
867     CORINFO_ACCESS_NONNULL    = 0x0004, // Instance is guaranteed non-null
868
869     CORINFO_ACCESS_LDFTN      = 0x0010, // Accessed via ldftn
870
871     // Field access flags
872     CORINFO_ACCESS_GET        = 0x0100, // Field get (ldfld)
873     CORINFO_ACCESS_SET        = 0x0200, // Field set (stfld)
874     CORINFO_ACCESS_ADDRESS    = 0x0400, // Field address (ldflda)
875     CORINFO_ACCESS_INIT_ARRAY = 0x0800, // Field use for InitializeArray
876     CORINFO_ACCESS_ATYPICAL_CALLSITE = 0x4000, // Atypical callsite that cannot be disassembled by delay loading helper
877     CORINFO_ACCESS_INLINECHECK= 0x8000, // Return fieldFlags and fieldAccessor only. Used by JIT64 during inlining.
878 };
879
880 // These are the flags set on an CORINFO_EH_CLAUSE
881 enum CORINFO_EH_CLAUSE_FLAGS
882 {
883     CORINFO_EH_CLAUSE_NONE      = 0,
884     CORINFO_EH_CLAUSE_FILTER    = 0x0001, // If this bit is on, then this EH entry is for a filter
885     CORINFO_EH_CLAUSE_FINALLY   = 0x0002, // This clause is a finally clause
886     CORINFO_EH_CLAUSE_FAULT     = 0x0004, // This clause is a fault clause
887     CORINFO_EH_CLAUSE_DUPLICATE = 0x0008, // Duplicated clause. This clause was duplicated to a funclet which was pulled out of line
888     CORINFO_EH_CLAUSE_SAMETRY   = 0x0010, // This clause covers same try block as the previous one. (Used by CoreRT ABI.)
889 };
890
891 // This enumeration is passed to InternalThrow
892 enum CorInfoException
893 {
894     CORINFO_NullReferenceException,
895     CORINFO_DivideByZeroException,
896     CORINFO_InvalidCastException,
897     CORINFO_IndexOutOfRangeException,
898     CORINFO_OverflowException,
899     CORINFO_SynchronizationLockException,
900     CORINFO_ArrayTypeMismatchException,
901     CORINFO_RankException,
902     CORINFO_ArgumentNullException,
903     CORINFO_ArgumentException,
904     CORINFO_Exception_Count,
905 };
906
907
908 // This enumeration is returned by getIntrinsicID. Methods corresponding to
909 // these values will have "well-known" specified behavior. Calls to these
910 // methods could be replaced with inlined code corresponding to the
911 // specified behavior (without having to examine the IL beforehand).
912
913 enum CorInfoIntrinsics
914 {
915     CORINFO_INTRINSIC_Sin,
916     CORINFO_INTRINSIC_Cos,
917     CORINFO_INTRINSIC_Sqrt,
918     CORINFO_INTRINSIC_Abs,
919     CORINFO_INTRINSIC_Round,
920     CORINFO_INTRINSIC_Cosh,
921     CORINFO_INTRINSIC_Sinh,
922     CORINFO_INTRINSIC_Tan,
923     CORINFO_INTRINSIC_Tanh,
924     CORINFO_INTRINSIC_Asin,
925     CORINFO_INTRINSIC_Acos,
926     CORINFO_INTRINSIC_Atan,
927     CORINFO_INTRINSIC_Atan2,
928     CORINFO_INTRINSIC_Log10,
929     CORINFO_INTRINSIC_Pow,
930     CORINFO_INTRINSIC_Exp,
931     CORINFO_INTRINSIC_Ceiling,
932     CORINFO_INTRINSIC_Floor,
933     CORINFO_INTRINSIC_GetChar,              // fetch character out of string
934     CORINFO_INTRINSIC_Array_GetDimLength,   // Get number of elements in a given dimension of an array
935     CORINFO_INTRINSIC_Array_Get,            // Get the value of an element in an array
936     CORINFO_INTRINSIC_Array_Address,        // Get the address of an element in an array
937     CORINFO_INTRINSIC_Array_Set,            // Set the value of an element in an array
938     CORINFO_INTRINSIC_StringGetChar,        // fetch character out of string
939     CORINFO_INTRINSIC_StringLength,         // get the length
940     CORINFO_INTRINSIC_InitializeArray,      // initialize an array from static data
941     CORINFO_INTRINSIC_GetTypeFromHandle,
942     CORINFO_INTRINSIC_RTH_GetValueInternal,
943     CORINFO_INTRINSIC_TypeEQ,
944     CORINFO_INTRINSIC_TypeNEQ,
945     CORINFO_INTRINSIC_Object_GetType,
946     CORINFO_INTRINSIC_StubHelpers_GetStubContext,
947     CORINFO_INTRINSIC_StubHelpers_GetStubContextAddr,
948     CORINFO_INTRINSIC_StubHelpers_GetNDirectTarget,
949     CORINFO_INTRINSIC_InterlockedAdd32,
950     CORINFO_INTRINSIC_InterlockedAdd64,
951     CORINFO_INTRINSIC_InterlockedXAdd32,
952     CORINFO_INTRINSIC_InterlockedXAdd64,
953     CORINFO_INTRINSIC_InterlockedXchg32,
954     CORINFO_INTRINSIC_InterlockedXchg64,
955     CORINFO_INTRINSIC_InterlockedCmpXchg32,
956     CORINFO_INTRINSIC_InterlockedCmpXchg64,
957     CORINFO_INTRINSIC_MemoryBarrier,
958     CORINFO_INTRINSIC_GetCurrentManagedThread,
959     CORINFO_INTRINSIC_GetManagedThreadId,
960     CORINFO_INTRINSIC_ByReference_Ctor,
961     CORINFO_INTRINSIC_ByReference_Value,
962     CORINFO_INTRINSIC_Span_GetItem,
963     CORINFO_INTRINSIC_ReadOnlySpan_GetItem,
964     CORINFO_INTRINSIC_GetRawHandle,
965
966     CORINFO_INTRINSIC_Count,
967     CORINFO_INTRINSIC_Illegal = -1,         // Not a true intrinsic,
968 };
969
970 // Can a value be accessed directly from JITed code.
971 enum InfoAccessType
972 {
973     IAT_VALUE,      // The info value is directly available
974     IAT_PVALUE,     // The value needs to be accessed via an       indirection
975     IAT_PPVALUE     // The value needs to be accessed via a double indirection
976 };
977
978 enum CorInfoGCType
979 {
980     TYPE_GC_NONE,   // no embedded objectrefs
981     TYPE_GC_REF,    // Is an object ref
982     TYPE_GC_BYREF,  // Is an interior pointer - promote it but don't scan it
983     TYPE_GC_OTHER   // requires type-specific treatment
984 };
985
986 enum CorInfoClassId
987 {
988     CLASSID_SYSTEM_OBJECT,
989     CLASSID_TYPED_BYREF,
990     CLASSID_TYPE_HANDLE,
991     CLASSID_FIELD_HANDLE,
992     CLASSID_METHOD_HANDLE,
993     CLASSID_STRING,
994     CLASSID_ARGUMENT_HANDLE,
995     CLASSID_RUNTIME_TYPE,
996 };
997
998 enum CorInfoInline
999 {
1000     INLINE_PASS                 = 0,    // Inlining OK
1001
1002     // failures are negative
1003     INLINE_FAIL                 = -1,   // Inlining not OK for this case only
1004     INLINE_NEVER                = -2,   // This method should never be inlined, regardless of context
1005 };
1006
1007 enum CorInfoInlineRestrictions
1008 {
1009     INLINE_RESPECT_BOUNDARY = 0x00000001, // You can inline if there are no calls from the method being inlined
1010     INLINE_NO_CALLEE_LDSTR  = 0x00000002, // You can inline only if you guarantee that if inlinee does an ldstr
1011                                           // inlinee's module will never see that string (by any means).
1012                                           // This is due to how we implement the NoStringInterningAttribute
1013                                           // (by reusing the fixup table).
1014     INLINE_SAME_THIS        = 0x00000004, // You can inline only if the callee is on the same this reference as caller
1015 };
1016
1017
1018 // If you add more values here, keep it in sync with TailCallTypeMap in ..\vm\ClrEtwAll.man
1019 // and the string enum in CEEInfo::reportTailCallDecision in ..\vm\JITInterface.cpp
1020 enum CorInfoTailCall
1021 {
1022     TAILCALL_OPTIMIZED      = 0,    // Optimized tail call (epilog + jmp)
1023     TAILCALL_RECURSIVE      = 1,    // Optimized into a loop (only when a method tail calls itself)
1024     TAILCALL_HELPER         = 2,    // Helper assisted tail call (call to JIT_TailCall)
1025
1026     // failures are negative
1027     TAILCALL_FAIL           = -1,   // Couldn't do a tail call
1028 };
1029
1030 enum CorInfoCanSkipVerificationResult
1031 {
1032     CORINFO_VERIFICATION_CANNOT_SKIP    = 0,    // Cannot skip verification during jit time.
1033     CORINFO_VERIFICATION_CAN_SKIP       = 1,    // Can skip verification during jit time.
1034     CORINFO_VERIFICATION_RUNTIME_CHECK  = 2,    // Cannot skip verification during jit time,
1035                                                 //     but need to insert a callout to the VM to ask during runtime 
1036                                                 //     whether to raise a verification or not (if the method is unverifiable).
1037     CORINFO_VERIFICATION_DONT_JIT       = 3,    // Cannot skip verification during jit time,
1038                                                 //     but do not jit the method if is is unverifiable.
1039 };
1040
1041 enum CorInfoInitClassResult
1042 {
1043     CORINFO_INITCLASS_NOT_REQUIRED  = 0x00, // No class initialization required, but the class is not actually initialized yet 
1044                                             // (e.g. we are guaranteed to run the static constructor in method prolog)
1045     CORINFO_INITCLASS_INITIALIZED   = 0x01, // Class initialized
1046     CORINFO_INITCLASS_SPECULATIVE   = 0x02, // Class may be initialized speculatively
1047     CORINFO_INITCLASS_USE_HELPER    = 0x04, // The JIT must insert class initialization helper call.
1048     CORINFO_INITCLASS_DONT_INLINE   = 0x08, // The JIT should not inline the method requesting the class initialization. The class 
1049                                             // initialization requires helper class now, but will not require initialization 
1050                                             // if the method is compiled standalone. Or the method cannot be inlined due to some
1051                                             // requirement around class initialization such as shared generics.
1052 };
1053
1054 // Reason codes for making indirect calls
1055 #define INDIRECT_CALL_REASONS() \
1056     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_UNKNOWN) \
1057     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_EXOTIC) \
1058     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_PINVOKE) \
1059     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_GENERIC) \
1060     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_NO_CODE) \
1061     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_FIXUPS) \
1062     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_STUB) \
1063     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_REMOTING) \
1064     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_CER) \
1065     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_RESTORE_METHOD) \
1066     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_RESTORE_FIRST_CALL) \
1067     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_RESTORE_VALUE_TYPE) \
1068     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_RESTORE) \
1069     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_CANT_PATCH) \
1070     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_PROFILING) \
1071     INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_OTHER_LOADER_MODULE) \
1072
1073 enum CorInfoIndirectCallReason
1074 {
1075     #undef INDIRECT_CALL_REASON_FUNC
1076     #define INDIRECT_CALL_REASON_FUNC(x) x,
1077     INDIRECT_CALL_REASONS()
1078
1079     #undef INDIRECT_CALL_REASON_FUNC
1080
1081     CORINFO_INDIRECT_CALL_COUNT
1082 };
1083
1084 // This is for use when the JIT is compiling an instantiation
1085 // of generic code.  The JIT needs to know if the generic code itself
1086 // (which can be verified once and for all independently of the
1087 // instantiations) passed verification.
1088 enum CorInfoInstantiationVerification
1089 {
1090     // The method is NOT a concrete instantiation (eg. List<int>.Add()) of a method 
1091     // in a generic class or a generic method. It is either the typical instantiation 
1092     // (eg. List<T>.Add()) or entirely non-generic.
1093     INSTVER_NOT_INSTANTIATION           = 0,
1094
1095     // The method is an instantiation of a method in a generic class or a generic method, 
1096     // and the generic class was successfully verified
1097     INSTVER_GENERIC_PASSED_VERIFICATION = 1,
1098
1099     // The method is an instantiation of a method in a generic class or a generic method, 
1100     // and the generic class failed verification
1101     INSTVER_GENERIC_FAILED_VERIFICATION = 2,
1102 };
1103
1104 // When using CORINFO_HELPER_TAILCALL, the JIT needs to pass certain special
1105 // calling convention/argument passing/handling details to the helper
1106 enum CorInfoHelperTailCallSpecialHandling
1107 {
1108     CORINFO_TAILCALL_NORMAL =               0x00000000,
1109     CORINFO_TAILCALL_STUB_DISPATCH_ARG =    0x00000001,
1110 };
1111
1112
1113 inline bool dontInline(CorInfoInline val) {
1114     return(val < 0);
1115 }
1116
1117 // Cookie types consumed by the code generator (these are opaque values
1118 // not inspected by the code generator):
1119
1120 typedef struct CORINFO_ASSEMBLY_STRUCT_*    CORINFO_ASSEMBLY_HANDLE;
1121 typedef struct CORINFO_MODULE_STRUCT_*      CORINFO_MODULE_HANDLE;
1122 typedef struct CORINFO_DEPENDENCY_STRUCT_*  CORINFO_DEPENDENCY_HANDLE;
1123 typedef struct CORINFO_CLASS_STRUCT_*       CORINFO_CLASS_HANDLE;
1124 typedef struct CORINFO_METHOD_STRUCT_*      CORINFO_METHOD_HANDLE;
1125 typedef struct CORINFO_FIELD_STRUCT_*       CORINFO_FIELD_HANDLE;
1126 typedef struct CORINFO_ARG_LIST_STRUCT_*    CORINFO_ARG_LIST_HANDLE;    // represents a list of argument types
1127 typedef struct CORINFO_JUST_MY_CODE_HANDLE_*CORINFO_JUST_MY_CODE_HANDLE;
1128 typedef struct CORINFO_PROFILING_STRUCT_*   CORINFO_PROFILING_HANDLE;   // a handle guaranteed to be unique per process
1129 typedef struct CORINFO_GENERIC_STRUCT_*     CORINFO_GENERIC_HANDLE;     // a generic handle (could be any of the above)
1130
1131 // what is actually passed on the varargs call
1132 typedef struct CORINFO_VarArgInfo *         CORINFO_VARARGS_HANDLE;
1133
1134 // Generic tokens are resolved with respect to a context, which is usually the method
1135 // being compiled. The CORINFO_CONTEXT_HANDLE indicates which exact instantiation
1136 // (or the open instantiation) is being referred to.
1137 // CORINFO_CONTEXT_HANDLE is more tightly scoped than CORINFO_MODULE_HANDLE. For cases 
1138 // where the exact instantiation does not matter, CORINFO_MODULE_HANDLE is used.
1139 typedef CORINFO_METHOD_HANDLE               CORINFO_CONTEXT_HANDLE;
1140
1141 typedef struct CORINFO_DEPENDENCY_STRUCT_
1142 {
1143     CORINFO_MODULE_HANDLE moduleFrom;
1144     CORINFO_MODULE_HANDLE moduleTo; 
1145 } CORINFO_DEPENDENCY;
1146
1147 // Bit-twiddling of contexts assumes word-alignment of method handles and type handles
1148 // If this ever changes, some other encoding will be needed
1149 enum CorInfoContextFlags
1150 {
1151     CORINFO_CONTEXTFLAGS_METHOD = 0x00, // CORINFO_CONTEXT_HANDLE is really a CORINFO_METHOD_HANDLE
1152     CORINFO_CONTEXTFLAGS_CLASS  = 0x01, // CORINFO_CONTEXT_HANDLE is really a CORINFO_CLASS_HANDLE
1153     CORINFO_CONTEXTFLAGS_MASK   = 0x01
1154 };
1155
1156 #define MAKE_CLASSCONTEXT(c)  (CORINFO_CONTEXT_HANDLE((size_t) (c) | CORINFO_CONTEXTFLAGS_CLASS))
1157 #define MAKE_METHODCONTEXT(m) (CORINFO_CONTEXT_HANDLE((size_t) (m) | CORINFO_CONTEXTFLAGS_METHOD))
1158
1159 enum CorInfoSigInfoFlags
1160 {
1161     CORINFO_SIGFLAG_IS_LOCAL_SIG = 0x01,
1162     CORINFO_SIGFLAG_IL_STUB      = 0x02,
1163 };
1164
1165 struct CORINFO_SIG_INST
1166 {
1167     unsigned                classInstCount;
1168     CORINFO_CLASS_HANDLE *  classInst; // (representative, not exact) instantiation for class type variables in signature
1169     unsigned                methInstCount;
1170     CORINFO_CLASS_HANDLE *  methInst; // (representative, not exact) instantiation for method type variables in signature
1171 };
1172
1173 struct CORINFO_SIG_INFO
1174 {
1175     CorInfoCallConv         callConv;
1176     CORINFO_CLASS_HANDLE    retTypeClass;   // if the return type is a value class, this is its handle (enums are normalized)
1177     CORINFO_CLASS_HANDLE    retTypeSigClass;// returns the value class as it is in the sig (enums are not converted to primitives)
1178     CorInfoType             retType : 8;
1179     unsigned                flags   : 8;    // used by IL stubs code
1180     unsigned                numArgs : 16;
1181     struct CORINFO_SIG_INST sigInst;  // information about how type variables are being instantiated in generic code
1182     CORINFO_ARG_LIST_HANDLE args;
1183     PCCOR_SIGNATURE         pSig;
1184     unsigned                cbSig;
1185     CORINFO_MODULE_HANDLE   scope;          // passed to getArgClass
1186     mdToken                 token;
1187
1188     CorInfoCallConv     getCallConv()       { return CorInfoCallConv((callConv & CORINFO_CALLCONV_MASK)); }
1189     bool                hasThis()           { return ((callConv & CORINFO_CALLCONV_HASTHIS) != 0); }
1190     bool                hasExplicitThis()   { return ((callConv & CORINFO_CALLCONV_EXPLICITTHIS) != 0); }
1191     unsigned            totalILArgs()       { return (numArgs + hasThis()); }
1192     bool                isVarArg()          { return ((getCallConv() == CORINFO_CALLCONV_VARARG) || (getCallConv() == CORINFO_CALLCONV_NATIVEVARARG)); }
1193     bool                hasTypeArg()        { return ((callConv & CORINFO_CALLCONV_PARAMTYPE) != 0); }
1194 };
1195
1196 struct CORINFO_METHOD_INFO
1197 {
1198     CORINFO_METHOD_HANDLE       ftn;
1199     CORINFO_MODULE_HANDLE       scope;
1200     BYTE *                      ILCode;
1201     unsigned                    ILCodeSize;
1202     unsigned                    maxStack;
1203     unsigned                    EHcount;
1204     CorInfoOptions              options;
1205     CorInfoRegionKind           regionKind;
1206     CORINFO_SIG_INFO            args;
1207     CORINFO_SIG_INFO            locals;
1208 };
1209
1210 //----------------------------------------------------------------------------
1211 // Looking up handles and addresses.
1212 //
1213 // When the JIT requests a handle, the EE may direct the JIT that it must
1214 // access the handle in a variety of ways.  These are packed as
1215 //    CORINFO_CONST_LOOKUP
1216 // or CORINFO_LOOKUP (contains either a CORINFO_CONST_LOOKUP or a CORINFO_RUNTIME_LOOKUP)
1217 //
1218 // Constant Lookups v. Runtime Lookups (i.e. when will Runtime Lookups be generated?)
1219 // -----------------------------------------------------------------------------------
1220 //
1221 // CORINFO_LOOKUP_KIND is part of the result type of embedGenericHandle,
1222 // getVirtualCallInfo and any other functions that may require a
1223 // runtime lookup when compiling shared generic code.
1224 //
1225 // CORINFO_LOOKUP_KIND indicates whether a particular token in the instruction stream can be:
1226 // (a) Mapped to a handle (type, field or method) at compile-time (!needsRuntimeLookup)
1227 // (b) Must be looked up at run-time, and if so which runtime lookup technique should be used (see below)
1228 //
1229 // If the JIT or EE does not support code sharing for generic code, then
1230 // all CORINFO_LOOKUP results will be "constant lookups", i.e.
1231 // the needsRuntimeLookup of CORINFO_LOOKUP.lookupKind.needsRuntimeLookup
1232 // will be false.
1233 //
1234 // Constant Lookups
1235 // ----------------
1236 //
1237 // Constant Lookups are either:
1238 //     IAT_VALUE: immediate (relocatable) values,
1239 //     IAT_PVALUE: immediate values access via an indirection through an immediate (relocatable) address
1240 //     IAT_PPVALUE: immediate values access via a double indirection through an immediate (relocatable) address
1241 //
1242 // Runtime Lookups
1243 // ---------------
1244 //
1245 // CORINFO_LOOKUP_KIND is part of the result type of embedGenericHandle,
1246 // getVirtualCallInfo and any other functions that may require a
1247 // runtime lookup when compiling shared generic code.
1248 //
1249 // CORINFO_LOOKUP_KIND indicates whether a particular token in the instruction stream can be:
1250 // (a) Mapped to a handle (type, field or method) at compile-time (!needsRuntimeLookup)
1251 // (b) Must be looked up at run-time using the class dictionary
1252 //     stored in the vtable of the this pointer (needsRuntimeLookup && THISOBJ)
1253 // (c) Must be looked up at run-time using the method dictionary
1254 //     stored in the method descriptor parameter passed to a generic
1255 //     method (needsRuntimeLookup && METHODPARAM)
1256 // (d) Must be looked up at run-time using the class dictionary stored
1257 //     in the vtable parameter passed to a method in a generic
1258 //     struct (needsRuntimeLookup && CLASSPARAM)
1259
1260 struct CORINFO_CONST_LOOKUP
1261 {
1262     // If the handle is obtained at compile-time, then this handle is the "exact" handle (class, method, or field)
1263     // Otherwise, it's a representative... 
1264     // If accessType is
1265     //     IAT_VALUE   --> "handle" stores the real handle or "addr " stores the computed address
1266     //     IAT_PVALUE  --> "addr" stores a pointer to a location which will hold the real handle
1267     //     IAT_PPVALUE --> "addr" stores a double indirection to a location which will hold the real handle
1268
1269     InfoAccessType              accessType;
1270     union
1271     {
1272         CORINFO_GENERIC_HANDLE  handle;
1273         void *                  addr;
1274     };
1275 };
1276
1277 enum CORINFO_RUNTIME_LOOKUP_KIND
1278 {
1279     CORINFO_LOOKUP_THISOBJ,
1280     CORINFO_LOOKUP_METHODPARAM,
1281     CORINFO_LOOKUP_CLASSPARAM,
1282 };
1283
1284 struct CORINFO_LOOKUP_KIND
1285 {
1286     bool                        needsRuntimeLookup;
1287     CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind;
1288
1289     // The 'runtimeLookupFlags' and 'runtimeLookupArgs' fields
1290     // are just for internal VM / ZAP communication, not to be used by the JIT.
1291     WORD                        runtimeLookupFlags;
1292     void *                      runtimeLookupArgs;
1293 } ;
1294
1295
1296 // CORINFO_RUNTIME_LOOKUP indicates the details of the runtime lookup
1297 // operation to be performed.
1298 //
1299 // CORINFO_MAXINDIRECTIONS is the maximum number of
1300 // indirections used by runtime lookups.
1301 // This accounts for up to 2 indirections to get at a dictionary followed by a possible spill slot
1302 //
1303 #define CORINFO_MAXINDIRECTIONS 4
1304 #define CORINFO_USEHELPER ((WORD) 0xffff)
1305
1306 struct CORINFO_RUNTIME_LOOKUP
1307 {
1308     // This is signature you must pass back to the runtime lookup helper
1309     LPVOID                  signature;
1310
1311     // Here is the helper you must call. It is one of CORINFO_HELP_RUNTIMEHANDLE_* helpers.
1312     CorInfoHelpFunc         helper;
1313
1314     // Number of indirections to get there
1315     // CORINFO_USEHELPER = don't know how to get it, so use helper function at run-time instead
1316     // 0 = use the this pointer itself (e.g. token is C<!0> inside code in sealed class C)
1317     //     or method desc itself (e.g. token is method void M::mymeth<!!0>() inside code in M::mymeth)
1318     // Otherwise, follow each byte-offset stored in the "offsets[]" array (may be negative)
1319     WORD                    indirections;
1320
1321     // If set, test for null and branch to helper if null
1322     bool                    testForNull;
1323
1324     // If set, test the lowest bit and dereference if set (see code:FixupPointer)
1325     bool                    testForFixup;
1326
1327     SIZE_T                  offsets[CORINFO_MAXINDIRECTIONS];
1328
1329     // If set, first offset is indirect.
1330     // 0 means that value stored at first offset (offsets[0]) from pointer is next pointer, to which the next offset
1331     // (offsets[1]) is added and so on.
1332     // 1 means that value stored at first offset (offsets[0]) from pointer is offset1, and the next pointer is
1333     // stored at pointer+offsets[0]+offset1.
1334     bool                indirectFirstOffset;
1335
1336     // If set, second offset is indirect.
1337     // 0 means that value stored at second offset (offsets[1]) from pointer is next pointer, to which the next offset
1338     // (offsets[2]) is added and so on.
1339     // 1 means that value stored at second offset (offsets[1]) from pointer is offset2, and the next pointer is
1340     // stored at pointer+offsets[1]+offset2.
1341     bool                indirectSecondOffset;
1342 } ;
1343
1344 // Result of calling embedGenericHandle
1345 struct CORINFO_LOOKUP
1346 {
1347     CORINFO_LOOKUP_KIND     lookupKind;
1348
1349     union
1350     {
1351         // If kind.needsRuntimeLookup then this indicates how to do the lookup
1352         CORINFO_RUNTIME_LOOKUP  runtimeLookup;
1353
1354         // If the handle is obtained at compile-time, then this handle is the "exact" handle (class, method, or field)
1355         // Otherwise, it's a representative...  If accessType is
1356         //     IAT_VALUE --> "handle" stores the real handle or "addr " stores the computed address
1357         //     IAT_PVALUE --> "addr" stores a pointer to a location which will hold the real handle
1358         //     IAT_PPVALUE --> "addr" stores a double indirection to a location which will hold the real handle
1359         CORINFO_CONST_LOOKUP    constLookup;
1360     };
1361 };
1362
1363 enum CorInfoGenericHandleType
1364 {
1365     CORINFO_HANDLETYPE_UNKNOWN,
1366     CORINFO_HANDLETYPE_CLASS,
1367     CORINFO_HANDLETYPE_METHOD,
1368     CORINFO_HANDLETYPE_FIELD
1369 };
1370
1371 //----------------------------------------------------------------------------
1372 // Embedding type, method and field handles (for "ldtoken" or to pass back to helpers)
1373
1374 // Result of calling embedGenericHandle
1375 struct CORINFO_GENERICHANDLE_RESULT
1376 {
1377     CORINFO_LOOKUP          lookup;
1378
1379     // compileTimeHandle is guaranteed to be either NULL or a handle that is usable during compile time.
1380     // It must not be embedded in the code because it might not be valid at run-time.
1381     CORINFO_GENERIC_HANDLE  compileTimeHandle;
1382
1383     // Type of the result
1384     CorInfoGenericHandleType handleType;
1385 };
1386
1387 #define CORINFO_ACCESS_ALLOWED_MAX_ARGS 4
1388
1389 enum CorInfoAccessAllowedHelperArgType
1390 {
1391     CORINFO_HELPER_ARG_TYPE_Invalid = 0,
1392     CORINFO_HELPER_ARG_TYPE_Field   = 1,
1393     CORINFO_HELPER_ARG_TYPE_Method  = 2,
1394     CORINFO_HELPER_ARG_TYPE_Class   = 3,
1395     CORINFO_HELPER_ARG_TYPE_Module  = 4,
1396     CORINFO_HELPER_ARG_TYPE_Const   = 5,
1397 };
1398 struct CORINFO_HELPER_ARG
1399 {
1400     union
1401     {
1402         CORINFO_FIELD_HANDLE fieldHandle;
1403         CORINFO_METHOD_HANDLE methodHandle;
1404         CORINFO_CLASS_HANDLE classHandle;
1405         CORINFO_MODULE_HANDLE moduleHandle;
1406         size_t constant;
1407     };
1408     CorInfoAccessAllowedHelperArgType argType;
1409
1410     void Set(CORINFO_METHOD_HANDLE handle)
1411     {
1412         argType = CORINFO_HELPER_ARG_TYPE_Method;
1413         methodHandle = handle;
1414     }
1415
1416     void Set(CORINFO_FIELD_HANDLE handle)
1417     {
1418         argType = CORINFO_HELPER_ARG_TYPE_Field;
1419         fieldHandle = handle;
1420     }
1421
1422     void Set(CORINFO_CLASS_HANDLE handle)
1423     {
1424         argType = CORINFO_HELPER_ARG_TYPE_Class;
1425         classHandle = handle;
1426     }
1427
1428     void Set(size_t value)
1429     {
1430         argType = CORINFO_HELPER_ARG_TYPE_Const;
1431         constant = value;
1432     }
1433 };
1434
1435 struct CORINFO_HELPER_DESC
1436 {
1437     CorInfoHelpFunc helperNum;
1438     unsigned numArgs;
1439     CORINFO_HELPER_ARG args[CORINFO_ACCESS_ALLOWED_MAX_ARGS];
1440 };
1441
1442 //----------------------------------------------------------------------------
1443 // getCallInfo and CORINFO_CALL_INFO: The EE instructs the JIT about how to make a call
1444 //
1445 // callKind
1446 // --------
1447 //
1448 // CORINFO_CALL :
1449 //   Indicates that the JIT can use getFunctionEntryPoint to make a call,
1450 //   i.e. there is nothing abnormal about the call.  The JITs know what to do if they get this.
1451 //   Except in the case of constraint calls (see below), [targetMethodHandle] will hold
1452 //   the CORINFO_METHOD_HANDLE that a call to findMethod would
1453 //   have returned.
1454 //   This flag may be combined with nullInstanceCheck=TRUE for uses of callvirt on methods that can
1455 //   be resolved at compile-time (non-virtual, final or sealed).
1456 //
1457 // CORINFO_CALL_CODE_POINTER (shared generic code only) :
1458 //   Indicates that the JIT should do an indirect call to the entrypoint given by address, which may be specified
1459 //   as a runtime lookup by CORINFO_CALL_INFO::codePointerLookup.
1460 //   [targetMethodHandle] will not hold a valid value.
1461 //   This flag may be combined with nullInstanceCheck=TRUE for uses of callvirt on methods whose target method can
1462 //   be resolved at compile-time but whose instantiation can be resolved only through runtime lookup.
1463 //
1464 // CORINFO_VIRTUALCALL_STUB (interface calls) :
1465 //   Indicates that the EE supports "stub dispatch" and request the JIT to make a
1466 //   "stub dispatch" call (an indirect call through CORINFO_CALL_INFO::stubLookup,
1467 //   similar to CORINFO_CALL_CODE_POINTER).
1468 //   "Stub dispatch" is a specialized calling sequence (that may require use of NOPs)
1469 //   which allow the runtime to determine the call-site after the call has been dispatched.
1470 //   If the call is too complex for the JIT (e.g. because
1471 //   fetching the dispatch stub requires a runtime lookup, i.e. lookupKind.needsRuntimeLookup
1472 //   is set) then the JIT is allowed to implement the call as if it were CORINFO_VIRTUALCALL_LDVIRTFTN
1473 //   [targetMethodHandle] will hold the CORINFO_METHOD_HANDLE that a call to findMethod would
1474 //   have returned.
1475 //   This flag is always accompanied by nullInstanceCheck=TRUE.
1476 //
1477 // CORINFO_VIRTUALCALL_LDVIRTFTN (virtual generic methods) :
1478 //   Indicates that the EE provides no way to implement the call directly and
1479 //   that the JIT should use a LDVIRTFTN sequence (as implemented by CORINFO_HELP_VIRTUAL_FUNC_PTR)
1480 //   followed by an indirect call.
1481 //   [targetMethodHandle] will hold the CORINFO_METHOD_HANDLE that a call to findMethod would
1482 //   have returned.
1483 //   This flag is always accompanied by nullInstanceCheck=TRUE though typically the null check will
1484 //   be implicit in the access through the instance pointer.
1485 //
1486 //  CORINFO_VIRTUALCALL_VTABLE (regular virtual methods) :
1487 //   Indicates that the EE supports vtable dispatch and that the JIT should use getVTableOffset etc.
1488 //   to implement the call.
1489 //   [targetMethodHandle] will hold the CORINFO_METHOD_HANDLE that a call to findMethod would
1490 //   have returned.
1491 //   This flag is always accompanied by nullInstanceCheck=TRUE though typically the null check will
1492 //   be implicit in the access through the instance pointer.
1493 //
1494 // thisTransform and constraint calls
1495 // ----------------------------------
1496 //
1497 // For evertyhing besides "constrained." calls "thisTransform" is set to
1498 // CORINFO_NO_THIS_TRANSFORM.
1499 //
1500 // For "constrained." calls the EE attempts to resolve the call at compile
1501 // time to a more specific method, or (shared generic code only) to a runtime lookup
1502 // for a code pointer for the more specific method.
1503 //
1504 // In order to permit this, the "this" pointer supplied for a "constrained." call
1505 // is a byref to an arbitrary type (see the IL spec). The "thisTransform" field
1506 // will indicate how the JIT must transform the "this" pointer in order
1507 // to be able to call the resolved method:
1508 //
1509 //  CORINFO_NO_THIS_TRANSFORM --> Leave it as a byref to an unboxed value type
1510 //  CORINFO_BOX_THIS          --> Box it to produce an object
1511 //  CORINFO_DEREF_THIS        --> Deref the byref to get an object reference
1512 //
1513 // In addition, the "kind" field will be set as follows for constraint calls:
1514
1515 //    CORINFO_CALL              --> the call was resolved at compile time, and
1516 //                                  can be compiled like a normal call.
1517 //    CORINFO_CALL_CODE_POINTER --> the call was resolved, but the target address will be
1518 //                                  computed at runtime.  Only returned for shared generic code.
1519 //    CORINFO_VIRTUALCALL_STUB,
1520 //    CORINFO_VIRTUALCALL_LDVIRTFTN,
1521 //    CORINFO_VIRTUALCALL_VTABLE   --> usual values indicating that a virtual call must be made
1522
1523 enum CORINFO_CALL_KIND
1524 {
1525     CORINFO_CALL,
1526     CORINFO_CALL_CODE_POINTER,
1527     CORINFO_VIRTUALCALL_STUB,
1528     CORINFO_VIRTUALCALL_LDVIRTFTN,
1529     CORINFO_VIRTUALCALL_VTABLE
1530 };
1531
1532 // Indicates that the CORINFO_VIRTUALCALL_VTABLE lookup needn't do a chunk indirection
1533 #define CORINFO_VIRTUALCALL_NO_CHUNK 0xFFFFFFFF
1534
1535 enum CORINFO_THIS_TRANSFORM
1536 {
1537     CORINFO_NO_THIS_TRANSFORM,
1538     CORINFO_BOX_THIS,
1539     CORINFO_DEREF_THIS
1540 };
1541
1542 enum CORINFO_CALLINFO_FLAGS
1543 {
1544     CORINFO_CALLINFO_NONE           = 0x0000,
1545     CORINFO_CALLINFO_ALLOWINSTPARAM = 0x0001,   // Can the compiler generate code to pass an instantiation parameters? Simple compilers should not use this flag
1546     CORINFO_CALLINFO_CALLVIRT       = 0x0002,   // Is it a virtual call?
1547     CORINFO_CALLINFO_KINDONLY       = 0x0004,   // This is set to only query the kind of call to perform, without getting any other information
1548     CORINFO_CALLINFO_VERIFICATION   = 0x0008,   // Gets extra verification information.
1549     CORINFO_CALLINFO_SECURITYCHECKS = 0x0010,   // Perform security checks.
1550     CORINFO_CALLINFO_LDFTN          = 0x0020,   // Resolving target of LDFTN
1551     CORINFO_CALLINFO_ATYPICAL_CALLSITE = 0x0040, // Atypical callsite that cannot be disassembled by delay loading helper
1552 };
1553
1554 enum CorInfoIsAccessAllowedResult
1555 {
1556     CORINFO_ACCESS_ALLOWED = 0,           // Call allowed
1557     CORINFO_ACCESS_ILLEGAL = 1,           // Call not allowed
1558     CORINFO_ACCESS_RUNTIME_CHECK = 2,     // Ask at runtime whether to allow the call or not
1559 };
1560
1561
1562 // This enum is used for JIT to tell EE where this token comes from.
1563 // E.g. Depending on different opcodes, we might allow/disallow certain types of tokens or 
1564 // return different types of handles (e.g. boxed vs. regular entrypoints)
1565 enum CorInfoTokenKind
1566 {
1567     CORINFO_TOKENKIND_Class     = 0x01,
1568     CORINFO_TOKENKIND_Method    = 0x02,
1569     CORINFO_TOKENKIND_Field     = 0x04,
1570     CORINFO_TOKENKIND_Mask      = 0x07,
1571
1572     // token comes from CEE_LDTOKEN
1573     CORINFO_TOKENKIND_Ldtoken   = 0x10 | CORINFO_TOKENKIND_Class | CORINFO_TOKENKIND_Method | CORINFO_TOKENKIND_Field,
1574
1575     // token comes from CEE_CASTCLASS or CEE_ISINST
1576     CORINFO_TOKENKIND_Casting   = 0x20 | CORINFO_TOKENKIND_Class,
1577
1578     // token comes from CEE_NEWARR
1579     CORINFO_TOKENKIND_Newarr    = 0x40 | CORINFO_TOKENKIND_Class,
1580
1581     // token comes from CEE_BOX
1582     CORINFO_TOKENKIND_Box       = 0x80 | CORINFO_TOKENKIND_Class,
1583
1584     // token comes from CEE_CONSTRAINED
1585     CORINFO_TOKENKIND_Constrained = 0x100 | CORINFO_TOKENKIND_Class,
1586
1587     // token comes from CEE_NEWOBJ
1588     CORINFO_TOKENKIND_NewObj    = 0x200 | CORINFO_TOKENKIND_Method,
1589
1590     // token comes from CEE_LDVIRTFTN
1591     CORINFO_TOKENKIND_Ldvirtftn = 0x400 | CORINFO_TOKENKIND_Method,
1592 };
1593
1594 struct CORINFO_RESOLVED_TOKEN
1595 {
1596     //
1597     // [In] arguments of resolveToken
1598     //
1599     CORINFO_CONTEXT_HANDLE  tokenContext;       //Context for resolution of generic arguments
1600     CORINFO_MODULE_HANDLE   tokenScope;
1601     mdToken                 token;              //The source token
1602     CorInfoTokenKind        tokenType;
1603
1604     //
1605     // [Out] arguments of resolveToken. 
1606     // - Type handle is always non-NULL.
1607     // - At most one of method and field handles is non-NULL (according to the token type).
1608     // - Method handle is an instantiating stub only for generic methods. Type handle 
1609     //   is required to provide the full context for methods in generic types.
1610     //
1611     CORINFO_CLASS_HANDLE    hClass;
1612     CORINFO_METHOD_HANDLE   hMethod;
1613     CORINFO_FIELD_HANDLE    hField;
1614
1615     //
1616     // [Out] TypeSpec and MethodSpec signatures for generics. NULL otherwise.
1617     //
1618     PCCOR_SIGNATURE         pTypeSpec;
1619     ULONG                   cbTypeSpec;
1620     PCCOR_SIGNATURE         pMethodSpec;
1621     ULONG                   cbMethodSpec;
1622 };
1623
1624 struct CORINFO_CALL_INFO
1625 {
1626     CORINFO_METHOD_HANDLE   hMethod;            //target method handle
1627     unsigned                methodFlags;        //flags for the target method
1628
1629     unsigned                classFlags;         //flags for CORINFO_RESOLVED_TOKEN::hClass
1630
1631     CORINFO_SIG_INFO       sig;
1632
1633     //Verification information
1634     unsigned                verMethodFlags;     // flags for CORINFO_RESOLVED_TOKEN::hMethod
1635     CORINFO_SIG_INFO        verSig;
1636     //All of the regular method data is the same... hMethod might not be the same as CORINFO_RESOLVED_TOKEN::hMethod
1637
1638
1639     //If set to:
1640     //  - CORINFO_ACCESS_ALLOWED - The access is allowed.
1641     //  - CORINFO_ACCESS_ILLEGAL - This access cannot be allowed (i.e. it is public calling private).  The
1642     //      JIT may either insert the callsiteCalloutHelper into the code (as per a verification error) or
1643     //      call throwExceptionFromHelper on the callsiteCalloutHelper.  In this case callsiteCalloutHelper
1644     //      is guaranteed not to return.
1645     //  - CORINFO_ACCESS_RUNTIME_CHECK - The jit must insert the callsiteCalloutHelper at the call site.
1646     //      the helper may return
1647     CorInfoIsAccessAllowedResult accessAllowed;
1648     CORINFO_HELPER_DESC     callsiteCalloutHelper;
1649
1650     // See above section on constraintCalls to understand when these are set to unusual values.
1651     CORINFO_THIS_TRANSFORM  thisTransform;
1652
1653     CORINFO_CALL_KIND       kind;
1654     BOOL                    nullInstanceCheck;
1655
1656     // Context for inlining and hidden arg
1657     CORINFO_CONTEXT_HANDLE  contextHandle;
1658     BOOL                    exactContextNeedsRuntimeLookup; // Set if contextHandle is approx handle. Runtime lookup is required to get the exact handle.
1659
1660     // If kind.CORINFO_VIRTUALCALL_STUB then stubLookup will be set.
1661     // If kind.CORINFO_CALL_CODE_POINTER then entryPointLookup will be set.
1662     union
1663     {
1664         CORINFO_LOOKUP      stubLookup;
1665
1666         CORINFO_LOOKUP      codePointerLookup;
1667     };
1668
1669     CORINFO_CONST_LOOKUP    instParamLookup;    // Used by Ready-to-Run
1670
1671     BOOL                    secureDelegateInvoke;
1672 };
1673
1674 //----------------------------------------------------------------------------
1675 // getFieldInfo and CORINFO_FIELD_INFO: The EE instructs the JIT about how to access a field
1676
1677 enum CORINFO_FIELD_ACCESSOR
1678 {
1679     CORINFO_FIELD_INSTANCE,                 // regular instance field at given offset from this-ptr
1680     CORINFO_FIELD_INSTANCE_WITH_BASE,       // instance field with base offset (used by Ready-to-Run)
1681     CORINFO_FIELD_INSTANCE_HELPER,          // instance field accessed using helper (arguments are this, FieldDesc * and the value)
1682     CORINFO_FIELD_INSTANCE_ADDR_HELPER,     // instance field accessed using address-of helper (arguments are this and FieldDesc *)
1683
1684     CORINFO_FIELD_STATIC_ADDRESS,           // field at given address
1685     CORINFO_FIELD_STATIC_RVA_ADDRESS,       // RVA field at given address
1686     CORINFO_FIELD_STATIC_SHARED_STATIC_HELPER, // static field accessed using the "shared static" helper (arguments are ModuleID + ClassID)
1687     CORINFO_FIELD_STATIC_GENERICS_STATIC_HELPER, // static field access using the "generic static" helper (argument is MethodTable *)
1688     CORINFO_FIELD_STATIC_ADDR_HELPER,       // static field accessed using address-of helper (argument is FieldDesc *)
1689     CORINFO_FIELD_STATIC_TLS,               // unmanaged TLS access
1690     CORINFO_FIELD_STATIC_READYTORUN_HELPER, // static field access using a runtime lookup helper
1691
1692     CORINFO_FIELD_INTRINSIC_ZERO,           // intrinsic zero (IntPtr.Zero, UIntPtr.Zero)
1693     CORINFO_FIELD_INTRINSIC_EMPTY_STRING,   // intrinsic emptry string (String.Empty)
1694     CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN, // intrinsic BitConverter.IsLittleEndian
1695 };
1696
1697 // Set of flags returned in CORINFO_FIELD_INFO::fieldFlags
1698 enum CORINFO_FIELD_FLAGS
1699 {
1700     CORINFO_FLG_FIELD_STATIC                    = 0x00000001,
1701     CORINFO_FLG_FIELD_UNMANAGED                 = 0x00000002, // RVA field
1702     CORINFO_FLG_FIELD_FINAL                     = 0x00000004,
1703     CORINFO_FLG_FIELD_STATIC_IN_HEAP            = 0x00000008, // See code:#StaticFields. This static field is in the GC heap as a boxed object
1704     CORINFO_FLG_FIELD_SAFESTATIC_BYREF_RETURN   = 0x00000010, // Field can be returned safely (has GC heap lifetime)
1705     CORINFO_FLG_FIELD_INITCLASS                 = 0x00000020, // initClass has to be called before accessing the field
1706     CORINFO_FLG_FIELD_PROTECTED                 = 0x00000040,
1707 };
1708
1709 struct CORINFO_FIELD_INFO
1710 {
1711     CORINFO_FIELD_ACCESSOR  fieldAccessor;
1712     unsigned                fieldFlags;
1713
1714     // Helper to use if the field access requires it
1715     CorInfoHelpFunc         helper;
1716
1717     // Field offset if there is one
1718     DWORD                   offset;
1719
1720     CorInfoType             fieldType;
1721     CORINFO_CLASS_HANDLE    structType; //possibly null
1722
1723     //See CORINFO_CALL_INFO.accessAllowed
1724     CorInfoIsAccessAllowedResult accessAllowed;
1725     CORINFO_HELPER_DESC     accessCalloutHelper;
1726
1727     CORINFO_CONST_LOOKUP    fieldLookup;        // Used by Ready-to-Run
1728 };
1729
1730 //----------------------------------------------------------------------------
1731 // Exception handling
1732
1733 struct CORINFO_EH_CLAUSE
1734 {
1735     CORINFO_EH_CLAUSE_FLAGS     Flags;
1736     DWORD                       TryOffset;
1737     DWORD                       TryLength;
1738     DWORD                       HandlerOffset;
1739     DWORD                       HandlerLength;
1740     union
1741     {
1742         DWORD                   ClassToken;       // use for type-based exception handlers
1743         DWORD                   FilterOffset;     // use for filter-based exception handlers (COR_ILEXCEPTION_FILTER is set)
1744     };
1745 };
1746
1747 enum CORINFO_OS
1748 {
1749     CORINFO_WINNT,
1750     CORINFO_PAL,
1751 };
1752
1753 struct CORINFO_CPU
1754 {
1755     DWORD           dwCPUType;
1756     DWORD           dwFeatures;
1757     DWORD           dwExtendedFeatures;
1758 };
1759
1760 enum CORINFO_RUNTIME_ABI
1761 {
1762     CORINFO_DESKTOP_ABI = 0x100,
1763     CORINFO_CORECLR_ABI = 0x200,
1764     CORINFO_CORERT_ABI = 0x300,
1765 };
1766
1767 // For some highly optimized paths, the JIT must generate code that directly
1768 // manipulates internal EE data structures. The getEEInfo() helper returns
1769 // this structure containing the needed offsets and values.
1770 struct CORINFO_EE_INFO
1771 {
1772     // Information about the InlinedCallFrame structure layout
1773     struct InlinedCallFrameInfo
1774     {
1775         // Size of the Frame structure
1776         unsigned    size;
1777
1778         unsigned    offsetOfGSCookie;
1779         unsigned    offsetOfFrameVptr;
1780         unsigned    offsetOfFrameLink;
1781         unsigned    offsetOfCallSiteSP;
1782         unsigned    offsetOfCalleeSavedFP;
1783         unsigned    offsetOfCallTarget;
1784         unsigned    offsetOfReturnAddress;
1785     }
1786     inlinedCallFrameInfo;
1787
1788     // Offsets into the Thread structure
1789     unsigned    offsetOfThreadFrame;            // offset of the current Frame
1790     unsigned    offsetOfGCState;                // offset of the preemptive/cooperative state of the Thread
1791
1792     // Delegate offsets
1793     unsigned    offsetOfDelegateInstance;
1794     unsigned    offsetOfDelegateFirstTarget;
1795
1796     // Secure delegate offsets
1797     unsigned    offsetOfSecureDelegateIndirectCell;
1798
1799     // Remoting offsets
1800     unsigned    offsetOfTransparentProxyRP;
1801     unsigned    offsetOfRealProxyServer;
1802
1803     // Array offsets
1804     unsigned    offsetOfObjArrayData;
1805
1806     // Reverse PInvoke offsets
1807     unsigned    sizeOfReversePInvokeFrame;
1808
1809     // OS Page size
1810     size_t      osPageSize;
1811
1812     // Null object offset
1813     size_t      maxUncheckedOffsetForNullObject;
1814
1815     // Target ABI. Combined with target architecture and OS to determine
1816     // GC, EH, and unwind styles.
1817     CORINFO_RUNTIME_ABI targetAbi;
1818
1819     CORINFO_OS  osType;
1820     unsigned    osMajor;
1821     unsigned    osMinor;
1822     unsigned    osBuild;
1823 };
1824
1825 // This is used to indicate that a finally has been called 
1826 // "locally" by the try block
1827 enum { LCL_FINALLY_MARK = 0xFC }; // FC = "Finally Call"
1828
1829 /**********************************************************************************
1830  * The following is the internal structure of an object that the compiler knows about
1831  * when it generates code
1832  **********************************************************************************/
1833
1834 #include <pshpack4.h>
1835
1836 typedef void* CORINFO_MethodPtr;            // a generic method pointer
1837
1838 struct CORINFO_Object
1839 {
1840     CORINFO_MethodPtr      *methTable;      // the vtable for the object
1841 };
1842
1843 struct CORINFO_String : public CORINFO_Object
1844 {
1845     unsigned                stringLen;
1846     wchar_t                 chars[1];       // actually of variable size
1847 };
1848
1849 struct CORINFO_Array : public CORINFO_Object
1850 {
1851     unsigned                length;
1852 #ifdef _WIN64
1853     unsigned                alignpad;
1854 #endif // _WIN64
1855
1856 #if 0
1857     /* Multi-dimensional arrays have the lengths and bounds here */
1858     unsigned                dimLength[length];
1859     unsigned                dimBound[length];
1860 #endif
1861
1862     union
1863     {
1864         __int8              i1Elems[1];    // actually of variable size
1865         unsigned __int8     u1Elems[1];
1866         __int16             i2Elems[1];
1867         unsigned __int16    u2Elems[1];
1868         __int32             i4Elems[1];
1869         unsigned __int32    u4Elems[1];
1870         float               r4Elems[1];
1871     };
1872 };
1873
1874 #include <pshpack4.h>
1875 struct CORINFO_Array8 : public CORINFO_Object
1876 {
1877     unsigned                length;
1878 #ifdef _WIN64
1879     unsigned                alignpad;
1880 #endif // _WIN64
1881
1882     union
1883     {
1884         double              r8Elems[1];
1885         __int64             i8Elems[1];
1886         unsigned __int64    u8Elems[1];
1887     };
1888 };
1889
1890 #include <poppack.h>
1891
1892 struct CORINFO_RefArray : public CORINFO_Object
1893 {
1894     unsigned                length;
1895 #ifdef _WIN64
1896     unsigned                alignpad;
1897 #endif // _WIN64
1898
1899 #if 0
1900     /* Multi-dimensional arrays have the lengths and bounds here */
1901     unsigned                dimLength[length];
1902     unsigned                dimBound[length];
1903 #endif
1904
1905     CORINFO_Object*         refElems[1];    // actually of variable size;
1906 };
1907
1908 struct CORINFO_RefAny
1909 {
1910     void                      * dataPtr;
1911     CORINFO_CLASS_HANDLE        type;
1912 };
1913
1914 // The jit assumes the CORINFO_VARARGS_HANDLE is a pointer to a subclass of this
1915 struct CORINFO_VarArgInfo
1916 {
1917     unsigned                argBytes;       // number of bytes the arguments take up.
1918                                             // (The CORINFO_VARARGS_HANDLE counts as an arg)
1919 };
1920
1921 #include <poppack.h>
1922
1923 enum CorInfoSecurityRuntimeChecks
1924 {
1925     CORINFO_ACCESS_SECURITY_NONE                          = 0,
1926     CORINFO_ACCESS_SECURITY_TRANSPARENCY                  = 0x0001  // check that transparency rules are enforced between the caller and callee
1927 };
1928
1929
1930 /* data to optimize delegate construction */
1931 struct DelegateCtorArgs
1932 {
1933     void * pMethod;
1934     void * pArg3;
1935     void * pArg4;
1936     void * pArg5;
1937 };
1938
1939 // use offsetof to get the offset of the fields above
1940 #include <stddef.h> // offsetof
1941 #ifndef offsetof
1942 #define offsetof(s,m)   ((size_t)&(((s *)0)->m))
1943 #endif
1944
1945 // Guard-stack cookie for preventing against stack buffer overruns
1946 typedef SIZE_T GSCookie;
1947
1948 #include "cordebuginfo.h"
1949
1950 /**********************************************************************************/
1951 // Some compilers cannot arbitrarily allow the handler nesting level to grow
1952 // arbitrarily during Edit'n'Continue.
1953 // This is the maximum nesting level that a compiler needs to support for EnC
1954
1955 const int MAX_EnC_HANDLER_NESTING_LEVEL = 6;
1956
1957 //
1958 // This interface is logically split into sections for each class of information 
1959 // (ICorMethodInfo, ICorModuleInfo, etc.). This split used to exist physically as well
1960 // using virtual inheritance, but was eliminated to improve efficiency of the JIT-EE 
1961 // interface calls.
1962 //
1963 class ICorStaticInfo
1964 {
1965 public:
1966     /**********************************************************************************/
1967     //
1968     // ICorMethodInfo
1969     //
1970     /**********************************************************************************/
1971
1972     // return flags (defined above, CORINFO_FLG_PUBLIC ...)
1973     virtual DWORD getMethodAttribs (
1974             CORINFO_METHOD_HANDLE       ftn         /* IN */
1975             ) = 0;
1976
1977     // sets private JIT flags, which can be, retrieved using getAttrib.
1978     virtual void setMethodAttribs (
1979             CORINFO_METHOD_HANDLE       ftn,        /* IN */
1980             CorInfoMethodRuntimeFlags   attribs     /* IN */
1981             ) = 0;
1982
1983     // Given a method descriptor ftnHnd, extract signature information into sigInfo
1984     //
1985     // 'memberParent' is typically only set when verifying.  It should be the
1986     // result of calling getMemberParent.
1987     virtual void getMethodSig (
1988              CORINFO_METHOD_HANDLE      ftn,        /* IN  */
1989              CORINFO_SIG_INFO          *sig,        /* OUT */
1990              CORINFO_CLASS_HANDLE      memberParent = NULL /* IN */
1991              ) = 0;
1992
1993     /*********************************************************************
1994      * Note the following methods can only be used on functions known
1995      * to be IL.  This includes the method being compiled and any method
1996      * that 'getMethodInfo' returns true for
1997      *********************************************************************/
1998
1999     // return information about a method private to the implementation
2000     //      returns false if method is not IL, or is otherwise unavailable.
2001     //      This method is used to fetch data needed to inline functions
2002     virtual bool getMethodInfo (
2003             CORINFO_METHOD_HANDLE   ftn,            /* IN  */
2004             CORINFO_METHOD_INFO*    info            /* OUT */
2005             ) = 0;
2006
2007     // Decides if you have any limitations for inlining. If everything's OK, it will return
2008     // INLINE_PASS and will fill out pRestrictions with a mask of restrictions the caller of this
2009     // function must respect. If caller passes pRestrictions = NULL, if there are any restrictions
2010     // INLINE_FAIL will be returned
2011     //
2012     // The callerHnd must be the immediate caller (i.e. when we have a chain of inlined calls)
2013     //
2014     // The inlined method need not be verified
2015
2016     virtual CorInfoInline canInline (
2017             CORINFO_METHOD_HANDLE       callerHnd,                  /* IN  */
2018             CORINFO_METHOD_HANDLE       calleeHnd,                  /* IN  */
2019             DWORD*                      pRestrictions               /* OUT */
2020             ) = 0;
2021
2022     // Reports whether or not a method can be inlined, and why.  canInline is responsible for reporting all
2023     // inlining results when it returns INLINE_FAIL and INLINE_NEVER.  All other results are reported by the
2024     // JIT.
2025     virtual void reportInliningDecision (CORINFO_METHOD_HANDLE inlinerHnd,
2026                                                    CORINFO_METHOD_HANDLE inlineeHnd,
2027                                                    CorInfoInline inlineResult,
2028                                                    const char * reason) = 0;
2029
2030
2031     // Returns false if the call is across security boundaries thus we cannot tailcall
2032     //
2033     // The callerHnd must be the immediate caller (i.e. when we have a chain of inlined calls)
2034     virtual bool canTailCall (
2035             CORINFO_METHOD_HANDLE   callerHnd,          /* IN */
2036             CORINFO_METHOD_HANDLE   declaredCalleeHnd,  /* IN */
2037             CORINFO_METHOD_HANDLE   exactCalleeHnd,     /* IN */
2038             bool fIsTailPrefix                          /* IN */
2039             ) = 0;
2040
2041     // Reports whether or not a method can be tail called, and why.
2042     // canTailCall is responsible for reporting all results when it returns
2043     // false.  All other results are reported by the JIT.
2044     virtual void reportTailCallDecision (CORINFO_METHOD_HANDLE callerHnd,
2045                                                    CORINFO_METHOD_HANDLE calleeHnd,
2046                                                    bool fIsTailPrefix,
2047                                                    CorInfoTailCall tailCallResult,
2048                                                    const char * reason) = 0;
2049
2050     // get individual exception handler
2051     virtual void getEHinfo(
2052             CORINFO_METHOD_HANDLE ftn,              /* IN  */
2053             unsigned          EHnumber,             /* IN */
2054             CORINFO_EH_CLAUSE* clause               /* OUT */
2055             ) = 0;
2056
2057     // return class it belongs to
2058     virtual CORINFO_CLASS_HANDLE getMethodClass (
2059             CORINFO_METHOD_HANDLE       method
2060             ) = 0;
2061
2062     // return module it belongs to
2063     virtual CORINFO_MODULE_HANDLE getMethodModule (
2064             CORINFO_METHOD_HANDLE       method
2065             ) = 0;
2066
2067     // This function returns the offset of the specified method in the
2068     // vtable of it's owning class or interface.
2069     virtual void getMethodVTableOffset (
2070             CORINFO_METHOD_HANDLE       method,                 /* IN */
2071             unsigned*                   offsetOfIndirection,    /* OUT */
2072             unsigned*                   offsetAfterIndirection  /* OUT */
2073             ) = 0;
2074
2075     // Find the virtual method in implementingClass that overrides virtualMethod,
2076     // or the method in implementingClass that implements the interface method
2077     // represented by virtualMethod.
2078     //
2079     // Return null if devirtualization is not possible. Owner type is optional
2080     // and provides additional context for shared interface devirtualization.
2081     virtual CORINFO_METHOD_HANDLE resolveVirtualMethod(
2082             CORINFO_METHOD_HANDLE       virtualMethod,          /* IN */
2083             CORINFO_CLASS_HANDLE        implementingClass,      /* IN */
2084             CORINFO_CONTEXT_HANDLE      ownerType = NULL        /* IN */
2085             ) = 0;
2086
2087     // Given resolved token that corresponds to an intrinsic classified as
2088     // a CORINFO_INTRINSIC_GetRawHandle intrinsic, fetch the handle associated
2089     // with the token. If this is not possible at compile-time (because the current method's 
2090     // code is shared and the token contains generic parameters) then indicate 
2091     // how the handle should be looked up at runtime.
2092     virtual void expandRawHandleIntrinsic(
2093         CORINFO_RESOLVED_TOKEN *        pResolvedToken,
2094         CORINFO_GENERICHANDLE_RESULT *  pResult) = 0;
2095
2096     // If a method's attributes have (getMethodAttribs) CORINFO_FLG_INTRINSIC set,
2097     // getIntrinsicID() returns the intrinsic ID.
2098     // *pMustExpand tells whether or not JIT must expand the intrinsic.
2099     virtual CorInfoIntrinsics getIntrinsicID(
2100             CORINFO_METHOD_HANDLE       method,
2101             bool*                       pMustExpand = NULL      /* OUT */
2102             ) = 0;
2103
2104     // Is the given module the System.Numerics.Vectors module?
2105     // This defaults to false.
2106     virtual bool isInSIMDModule(
2107             CORINFO_CLASS_HANDLE        classHnd
2108             ) { return false; }
2109
2110     // return the unmanaged calling convention for a PInvoke
2111     virtual CorInfoUnmanagedCallConv getUnmanagedCallConv(
2112             CORINFO_METHOD_HANDLE       method
2113             ) = 0;
2114
2115     // return if any marshaling is required for PInvoke methods.  Note that
2116     // method == 0 => calli.  The call site sig is only needed for the varargs or calli case
2117     virtual BOOL pInvokeMarshalingRequired(
2118             CORINFO_METHOD_HANDLE       method,
2119             CORINFO_SIG_INFO*           callSiteSig
2120             ) = 0;
2121
2122     // Check constraints on method type arguments (only).
2123     // The parent class should be checked separately using satisfiesClassConstraints(parent).
2124     virtual BOOL satisfiesMethodConstraints(
2125             CORINFO_CLASS_HANDLE        parent, // the exact parent of the method
2126             CORINFO_METHOD_HANDLE       method
2127             ) = 0;
2128
2129     // Given a delegate target class, a target method parent class,  a  target method,
2130     // a delegate class, check if the method signature is compatible with the Invoke method of the delegate
2131     // (under the typical instantiation of any free type variables in the memberref signatures).
2132     virtual BOOL isCompatibleDelegate(
2133             CORINFO_CLASS_HANDLE        objCls,           /* type of the delegate target, if any */
2134             CORINFO_CLASS_HANDLE        methodParentCls,  /* exact parent of the target method, if any */
2135             CORINFO_METHOD_HANDLE       method,           /* (representative) target method, if any */
2136             CORINFO_CLASS_HANDLE        delegateCls,      /* exact type of the delegate */
2137             BOOL                        *pfIsOpenDelegate /* is the delegate open */
2138             ) = 0;
2139
2140     // Indicates if the method is an instance of the generic
2141     // method that passes (or has passed) verification
2142     virtual CorInfoInstantiationVerification isInstantiationOfVerifiedGeneric (
2143             CORINFO_METHOD_HANDLE   method /* IN  */
2144             ) = 0;
2145
2146     // Loads the constraints on a typical method definition, detecting cycles;
2147     // for use in verification.
2148     virtual void initConstraintsForVerification(
2149             CORINFO_METHOD_HANDLE   method, /* IN */
2150             BOOL *pfHasCircularClassConstraints, /* OUT */
2151             BOOL *pfHasCircularMethodConstraint /* OUT */
2152             ) = 0;
2153
2154     // Returns enum whether the method does not require verification
2155     // Also see ICorModuleInfo::canSkipVerification
2156     virtual CorInfoCanSkipVerificationResult canSkipMethodVerification (
2157             CORINFO_METHOD_HANDLE       ftnHandle
2158             ) = 0;
2159
2160     // load and restore the method
2161     virtual void methodMustBeLoadedBeforeCodeIsRun(
2162             CORINFO_METHOD_HANDLE       method
2163             ) = 0;
2164
2165     virtual CORINFO_METHOD_HANDLE mapMethodDeclToMethodImpl(
2166             CORINFO_METHOD_HANDLE       method
2167             ) = 0;
2168
2169     // Returns the global cookie for the /GS unsafe buffer checks
2170     // The cookie might be a constant value (JIT), or a handle to memory location (Ngen)
2171     virtual void getGSCookie(
2172             GSCookie * pCookieVal,                     // OUT
2173             GSCookie ** ppCookieVal                    // OUT
2174             ) = 0;
2175
2176     /**********************************************************************************/
2177     //
2178     // ICorModuleInfo
2179     //
2180     /**********************************************************************************/
2181
2182     // Resolve metadata token into runtime method handles. This function may not
2183     // return normally (e.g. it may throw) if it encounters invalid metadata or other
2184     // failures during token resolution.
2185     virtual void resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken) = 0;
2186
2187     // Attempt to resolve a metadata token into a runtime method handle. Returns true
2188     // if resolution succeeded and false otherwise (e.g. if it encounters invalid metadata
2189     // during token reoslution). This method should be used instead of `resolveToken` in
2190     // situations that need to be resilient to invalid metadata.
2191     virtual bool tryResolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken) = 0;
2192
2193     // Signature information about the call sig
2194     virtual void findSig (
2195             CORINFO_MODULE_HANDLE       module,     /* IN */
2196             unsigned                    sigTOK,     /* IN */
2197             CORINFO_CONTEXT_HANDLE      context,    /* IN */
2198             CORINFO_SIG_INFO           *sig         /* OUT */
2199             ) = 0;
2200
2201     // for Varargs, the signature at the call site may differ from
2202     // the signature at the definition.  Thus we need a way of
2203     // fetching the call site information
2204     virtual void findCallSiteSig (
2205             CORINFO_MODULE_HANDLE       module,     /* IN */
2206             unsigned                    methTOK,    /* IN */
2207             CORINFO_CONTEXT_HANDLE      context,    /* IN */
2208             CORINFO_SIG_INFO           *sig         /* OUT */
2209             ) = 0;
2210
2211     virtual CORINFO_CLASS_HANDLE getTokenTypeAsHandle (
2212             CORINFO_RESOLVED_TOKEN *    pResolvedToken /* IN  */) = 0;
2213
2214     // Returns true if the module does not require verification
2215     //
2216     // If fQuickCheckOnlyWithoutCommit=TRUE, the function only checks that the
2217     // module does not currently require verification in the current AppDomain.
2218     // This decision could change in the future, and so should not be cached.
2219     // If it is cached, it should only be used as a hint.
2220     // This is only used by ngen for calculating certain hints.
2221     //
2222    
2223     // Returns enum whether the module does not require verification
2224     // Also see ICorMethodInfo::canSkipMethodVerification();
2225     virtual CorInfoCanSkipVerificationResult canSkipVerification (
2226             CORINFO_MODULE_HANDLE       module     /* IN  */
2227             ) = 0;
2228
2229     // Checks if the given metadata token is valid
2230     virtual BOOL isValidToken (
2231             CORINFO_MODULE_HANDLE       module,     /* IN  */
2232             unsigned                    metaTOK     /* IN  */
2233             ) = 0;
2234
2235     // Checks if the given metadata token is valid StringRef
2236     virtual BOOL isValidStringRef (
2237             CORINFO_MODULE_HANDLE       module,     /* IN  */
2238             unsigned                    metaTOK     /* IN  */
2239             ) = 0;
2240
2241     virtual BOOL shouldEnforceCallvirtRestriction(
2242             CORINFO_MODULE_HANDLE   scope
2243             ) = 0;
2244
2245     /**********************************************************************************/
2246     //
2247     // ICorClassInfo
2248     //
2249     /**********************************************************************************/
2250
2251     // If the value class 'cls' is isomorphic to a primitive type it will
2252     // return that type, otherwise it will return CORINFO_TYPE_VALUECLASS
2253     virtual CorInfoType asCorInfoType (
2254             CORINFO_CLASS_HANDLE    cls
2255             ) = 0;
2256
2257     // for completeness
2258     virtual const char* getClassName (
2259             CORINFO_CLASS_HANDLE    cls
2260             ) = 0;
2261
2262
2263     // Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
2264     // If fNamespace=TRUE, include the namespace/enclosing classes
2265     // If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters
2266     // If fAssembly=TRUE, suffix with a comma and the full assembly qualification
2267     // return size of representation
2268     virtual int appendClassName(
2269             __deref_inout_ecount(*pnBufLen) WCHAR** ppBuf, 
2270             int* pnBufLen,
2271             CORINFO_CLASS_HANDLE    cls,
2272             BOOL fNamespace,
2273             BOOL fFullInst,
2274             BOOL fAssembly
2275             ) = 0;
2276
2277     // Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & CORINFO_FLG_VALUECLASS, except faster.
2278     virtual BOOL isValueClass(CORINFO_CLASS_HANDLE cls) = 0;
2279
2280     // If this method returns true, JIT will do optimization to inline the check for
2281     //     GetTypeFromHandle(handle) == obj.GetType()
2282     virtual BOOL canInlineTypeCheckWithObjectVTable(CORINFO_CLASS_HANDLE cls) = 0;
2283
2284     // return flags (defined above, CORINFO_FLG_PUBLIC ...)
2285     virtual DWORD getClassAttribs (
2286             CORINFO_CLASS_HANDLE    cls
2287             ) = 0;
2288
2289     // Returns "TRUE" iff "cls" is a struct type such that return buffers used for returning a value
2290     // of this type must be stack-allocated.  This will generally be true only if the struct 
2291     // contains GC pointers, and does not exceed some size limit.  Maintaining this as an invariant allows
2292     // an optimization: the JIT may assume that return buffer pointers for return types for which this predicate
2293     // returns TRUE are always stack allocated, and thus, that stores to the GC-pointer fields of such return
2294     // buffers do not require GC write barriers.
2295     virtual BOOL isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls) = 0;
2296
2297     virtual CORINFO_MODULE_HANDLE getClassModule (
2298             CORINFO_CLASS_HANDLE    cls
2299             ) = 0;
2300
2301     // Returns the assembly that contains the module "mod".
2302     virtual CORINFO_ASSEMBLY_HANDLE getModuleAssembly (
2303             CORINFO_MODULE_HANDLE   mod
2304             ) = 0;
2305
2306     // Returns the name of the assembly "assem".
2307     virtual const char* getAssemblyName (
2308             CORINFO_ASSEMBLY_HANDLE assem
2309             ) = 0;
2310
2311     // Allocate and delete process-lifetime objects.  Should only be
2312     // referred to from static fields, lest a leak occur.
2313     // Note that "LongLifetimeFree" does not execute destructors, if "obj"
2314     // is an array of a struct type with a destructor.
2315     virtual void* LongLifetimeMalloc(size_t sz) = 0;
2316     virtual void LongLifetimeFree(void* obj) = 0;
2317
2318     virtual size_t getClassModuleIdForStatics (
2319             CORINFO_CLASS_HANDLE    cls, 
2320             CORINFO_MODULE_HANDLE *pModule, 
2321             void **ppIndirection
2322             ) = 0;
2323
2324     // return the number of bytes needed by an instance of the class
2325     virtual unsigned getClassSize (
2326             CORINFO_CLASS_HANDLE        cls
2327             ) = 0;
2328
2329     virtual unsigned getClassAlignmentRequirement (
2330             CORINFO_CLASS_HANDLE        cls,
2331             BOOL                        fDoubleAlignHint = FALSE
2332             ) = 0;
2333
2334     // This is only called for Value classes.  It returns a boolean array
2335     // in representing of 'cls' from a GC perspective.  The class is
2336     // assumed to be an array of machine words
2337     // (of length // getClassSize(cls) / sizeof(void*)),
2338     // 'gcPtrs' is a pointer to an array of BYTEs of this length.
2339     // getClassGClayout fills in this array so that gcPtrs[i] is set
2340     // to one of the CorInfoGCType values which is the GC type of
2341     // the i-th machine word of an object of type 'cls'
2342     // returns the number of GC pointers in the array
2343     virtual unsigned getClassGClayout (
2344             CORINFO_CLASS_HANDLE        cls,        /* IN */
2345             BYTE                       *gcPtrs      /* OUT */
2346             ) = 0;
2347
2348     // returns the number of instance fields in a class
2349     virtual unsigned getClassNumInstanceFields (
2350             CORINFO_CLASS_HANDLE        cls        /* IN */
2351             ) = 0;
2352
2353     virtual CORINFO_FIELD_HANDLE getFieldInClass(
2354             CORINFO_CLASS_HANDLE clsHnd,
2355             INT num
2356             ) = 0;
2357
2358     virtual BOOL checkMethodModifier(
2359             CORINFO_METHOD_HANDLE hMethod,
2360             LPCSTR modifier,
2361             BOOL fOptional
2362             ) = 0;
2363
2364     // returns the "NEW" helper optimized for "newCls."
2365     virtual CorInfoHelpFunc getNewHelper(
2366             CORINFO_RESOLVED_TOKEN * pResolvedToken,
2367             CORINFO_METHOD_HANDLE    callerHandle
2368             ) = 0;
2369
2370     // returns the newArr (1-Dim array) helper optimized for "arrayCls."
2371     virtual CorInfoHelpFunc getNewArrHelper(
2372             CORINFO_CLASS_HANDLE        arrayCls
2373             ) = 0;
2374
2375     // returns the optimized "IsInstanceOf" or "ChkCast" helper
2376     virtual CorInfoHelpFunc getCastingHelper(
2377             CORINFO_RESOLVED_TOKEN * pResolvedToken,
2378             bool fThrowing
2379             ) = 0;
2380
2381     // returns helper to trigger static constructor
2382     virtual CorInfoHelpFunc getSharedCCtorHelper(
2383             CORINFO_CLASS_HANDLE clsHnd
2384             ) = 0;
2385
2386     virtual CorInfoHelpFunc getSecurityPrologHelper(
2387             CORINFO_METHOD_HANDLE   ftn
2388             ) = 0;
2389
2390     // This is not pretty.  Boxing nullable<T> actually returns
2391     // a boxed<T> not a boxed Nullable<T>.  This call allows the verifier
2392     // to call back to the EE on the 'box' instruction and get the transformed
2393     // type to use for verification.
2394     virtual CORINFO_CLASS_HANDLE  getTypeForBox(
2395             CORINFO_CLASS_HANDLE        cls
2396             ) = 0;
2397
2398     // returns the correct box helper for a particular class.  Note
2399     // that if this returns CORINFO_HELP_BOX, the JIT can assume 
2400     // 'standard' boxing (allocate object and copy), and optimize
2401     virtual CorInfoHelpFunc getBoxHelper(
2402             CORINFO_CLASS_HANDLE        cls
2403             ) = 0;
2404
2405     // returns the unbox helper.  If 'helperCopies' points to a true 
2406     // value it means the JIT is requesting a helper that unboxes the
2407     // value into a particular location and thus has the signature
2408     //     void unboxHelper(void* dest, CORINFO_CLASS_HANDLE cls, Object* obj)
2409     // Otherwise (it is null or points at a FALSE value) it is requesting 
2410     // a helper that returns a pointer to the unboxed data 
2411     //     void* unboxHelper(CORINFO_CLASS_HANDLE cls, Object* obj)
2412     // The EE has the option of NOT returning the copy style helper
2413     // (But must be able to always honor the non-copy style helper)
2414     // The EE set 'helperCopies' on return to indicate what kind of
2415     // helper has been created.  
2416
2417     virtual CorInfoHelpFunc getUnBoxHelper(
2418             CORINFO_CLASS_HANDLE        cls
2419             ) = 0;
2420
2421     virtual bool getReadyToRunHelper(
2422             CORINFO_RESOLVED_TOKEN *        pResolvedToken,
2423             CORINFO_LOOKUP_KIND *           pGenericLookupKind,
2424             CorInfoHelpFunc                 id,
2425             CORINFO_CONST_LOOKUP *          pLookup
2426             ) = 0;
2427
2428     virtual void getReadyToRunDelegateCtorHelper(
2429             CORINFO_RESOLVED_TOKEN * pTargetMethod,
2430             CORINFO_CLASS_HANDLE     delegateType,
2431             CORINFO_LOOKUP *   pLookup
2432             ) = 0;
2433
2434     virtual const char* getHelperName(
2435             CorInfoHelpFunc
2436             ) = 0;
2437
2438     // This function tries to initialize the class (run the class constructor).
2439     // this function returns whether the JIT must insert helper calls before 
2440     // accessing static field or method.
2441     //
2442     // See code:ICorClassInfo#ClassConstruction.
2443     virtual CorInfoInitClassResult initClass(
2444             CORINFO_FIELD_HANDLE    field,          // Non-NULL - inquire about cctor trigger before static field access
2445                                                     // NULL - inquire about cctor trigger in method prolog
2446             CORINFO_METHOD_HANDLE   method,         // Method referencing the field or prolog
2447             CORINFO_CONTEXT_HANDLE  context,        // Exact context of method
2448             BOOL                    speculative = FALSE     // TRUE means don't actually run it
2449             ) = 0;
2450
2451     // This used to be called "loadClass".  This records the fact
2452     // that the class must be loaded (including restored if necessary) before we execute the
2453     // code that we are currently generating.  When jitting code
2454     // the function loads the class immediately.  When zapping code
2455     // the zapper will if necessary use the call to record the fact that we have
2456     // to do a fixup/restore before running the method currently being generated.
2457     //
2458     // This is typically used to ensure value types are loaded before zapped
2459     // code that manipulates them is executed, so that the GC can access information
2460     // about those value types.
2461     virtual void classMustBeLoadedBeforeCodeIsRun(
2462             CORINFO_CLASS_HANDLE        cls
2463             ) = 0;
2464
2465     // returns the class handle for the special builtin classes
2466     virtual CORINFO_CLASS_HANDLE getBuiltinClass (
2467             CorInfoClassId              classId
2468             ) = 0;
2469
2470     // "System.Int32" ==> CORINFO_TYPE_INT..
2471     virtual CorInfoType getTypeForPrimitiveValueClass(
2472             CORINFO_CLASS_HANDLE        cls
2473             ) = 0;
2474
2475     // TRUE if child is a subtype of parent
2476     // if parent is an interface, then does child implement / extend parent
2477     virtual BOOL canCast(
2478             CORINFO_CLASS_HANDLE        child,  // subtype (extends parent)
2479             CORINFO_CLASS_HANDLE        parent  // base type
2480             ) = 0;
2481
2482     // TRUE if cls1 and cls2 are considered equivalent types.
2483     virtual BOOL areTypesEquivalent(
2484             CORINFO_CLASS_HANDLE        cls1,
2485             CORINFO_CLASS_HANDLE        cls2
2486             ) = 0;
2487
2488     // returns is the intersection of cls1 and cls2.
2489     virtual CORINFO_CLASS_HANDLE mergeClasses(
2490             CORINFO_CLASS_HANDLE        cls1,
2491             CORINFO_CLASS_HANDLE        cls2
2492             ) = 0;
2493
2494     // Given a class handle, returns the Parent type.
2495     // For COMObjectType, it returns Class Handle of System.Object.
2496     // Returns 0 if System.Object is passed in.
2497     virtual CORINFO_CLASS_HANDLE getParentType (
2498             CORINFO_CLASS_HANDLE        cls
2499             ) = 0;
2500
2501     // Returns the CorInfoType of the "child type". If the child type is
2502     // not a primitive type, *clsRet will be set.
2503     // Given an Array of Type Foo, returns Foo.
2504     // Given BYREF Foo, returns Foo
2505     virtual CorInfoType getChildType (
2506             CORINFO_CLASS_HANDLE       clsHnd,
2507             CORINFO_CLASS_HANDLE       *clsRet
2508             ) = 0;
2509
2510     // Check constraints on type arguments of this class and parent classes
2511     virtual BOOL satisfiesClassConstraints(
2512             CORINFO_CLASS_HANDLE cls
2513             ) = 0;
2514
2515     // Check if this is a single dimensional array type
2516     virtual BOOL isSDArray(
2517             CORINFO_CLASS_HANDLE        cls
2518             ) = 0;
2519
2520     // Get the numbmer of dimensions in an array 
2521     virtual unsigned getArrayRank(
2522             CORINFO_CLASS_HANDLE        cls
2523             ) = 0;
2524
2525     // Get static field data for an array
2526     virtual void * getArrayInitializationData(
2527             CORINFO_FIELD_HANDLE        field,
2528             DWORD                       size
2529             ) = 0;
2530
2531     // Check Visibility rules.
2532     virtual CorInfoIsAccessAllowedResult canAccessClass(
2533                         CORINFO_RESOLVED_TOKEN * pResolvedToken,
2534                         CORINFO_METHOD_HANDLE   callerHandle,
2535                         CORINFO_HELPER_DESC    *pAccessHelper /* If canAccessMethod returns something other
2536                                                                  than ALLOWED, then this is filled in. */
2537                         ) = 0;
2538
2539     /**********************************************************************************/
2540     //
2541     // ICorFieldInfo
2542     //
2543     /**********************************************************************************/
2544
2545     // this function is for debugging only.  It returns the field name
2546     // and if 'moduleName' is non-null, it sets it to something that will
2547     // says which method (a class name, or a module name)
2548     virtual const char* getFieldName (
2549                         CORINFO_FIELD_HANDLE        ftn,        /* IN */
2550                         const char                **moduleName  /* OUT */
2551                         ) = 0;
2552
2553     // return class it belongs to
2554     virtual CORINFO_CLASS_HANDLE getFieldClass (
2555                         CORINFO_FIELD_HANDLE    field
2556                         ) = 0;
2557
2558     // Return the field's type, if it is CORINFO_TYPE_VALUECLASS 'structType' is set
2559     // the field's value class (if 'structType' == 0, then don't bother
2560     // the structure info).
2561     //
2562     // 'memberParent' is typically only set when verifying.  It should be the
2563     // result of calling getMemberParent.
2564     virtual CorInfoType getFieldType(
2565                         CORINFO_FIELD_HANDLE    field,
2566                         CORINFO_CLASS_HANDLE   *structType,
2567                         CORINFO_CLASS_HANDLE    memberParent = NULL /* IN */
2568                         ) = 0;
2569
2570     // return the data member's instance offset
2571     virtual unsigned getFieldOffset(
2572                         CORINFO_FIELD_HANDLE    field
2573                         ) = 0;
2574
2575     // TODO: jit64 should be switched to the same plan as the i386 jits - use
2576     // getClassGClayout to figure out the need for writebarrier helper, and inline the copying.
2577     // The interpretted value class copy is slow. Once this happens, USE_WRITE_BARRIER_HELPERS
2578     virtual bool isWriteBarrierHelperRequired(
2579                         CORINFO_FIELD_HANDLE    field) = 0;
2580
2581     virtual void getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken,
2582                                CORINFO_METHOD_HANDLE  callerHandle,
2583                                CORINFO_ACCESS_FLAGS   flags,
2584                                CORINFO_FIELD_INFO    *pResult
2585                               ) = 0;
2586
2587     // Returns true iff "fldHnd" represents a static field.
2588     virtual bool isFieldStatic(CORINFO_FIELD_HANDLE fldHnd) = 0;
2589
2590     /*********************************************************************************/
2591     //
2592     // ICorDebugInfo
2593     //
2594     /*********************************************************************************/
2595
2596     // Query the EE to find out where interesting break points
2597     // in the code are.  The native compiler will ensure that these places
2598     // have a corresponding break point in native code.
2599     //
2600     // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will
2601     // be used only as a hint and the native compiler should not change its
2602     // code generation.
2603     virtual void getBoundaries(
2604                 CORINFO_METHOD_HANDLE   ftn,                // [IN] method of interest
2605                 unsigned int           *cILOffsets,         // [OUT] size of pILOffsets
2606                 DWORD                 **pILOffsets,         // [OUT] IL offsets of interest
2607                                                             //       jit MUST free with freeArray!
2608                 ICorDebugInfo::BoundaryTypes *implictBoundaries // [OUT] tell jit, all boundries of this type
2609                 ) = 0;
2610
2611     // Report back the mapping from IL to native code,
2612     // this map should include all boundaries that 'getBoundaries'
2613     // reported as interesting to the debugger.
2614
2615     // Note that debugger (and profiler) is assuming that all of the
2616     // offsets form a contiguous block of memory, and that the
2617     // OffsetMapping is sorted in order of increasing native offset.
2618     virtual void setBoundaries(
2619                 CORINFO_METHOD_HANDLE   ftn,            // [IN] method of interest
2620                 ULONG32                 cMap,           // [IN] size of pMap
2621                 ICorDebugInfo::OffsetMapping *pMap      // [IN] map including all points of interest.
2622                                                         //      jit allocated with allocateArray, EE frees
2623                 ) = 0;
2624
2625     // Query the EE to find out the scope of local varables.
2626     // normally the JIT would trash variables after last use, but
2627     // under debugging, the JIT needs to keep them live over their
2628     // entire scope so that they can be inspected.
2629     //
2630     // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will
2631     // be used only as a hint and the native compiler should not change its
2632     // code generation.
2633     virtual void getVars(
2634             CORINFO_METHOD_HANDLE           ftn,            // [IN]  method of interest
2635             ULONG32                        *cVars,          // [OUT] size of 'vars'
2636             ICorDebugInfo::ILVarInfo       **vars,          // [OUT] scopes of variables of interest
2637                                                             //       jit MUST free with freeArray!
2638             bool                           *extendOthers    // [OUT] it TRUE, then assume the scope
2639                                                             //       of unmentioned vars is entire method
2640             ) = 0;
2641
2642     // Report back to the EE the location of every variable.
2643     // note that the JIT might split lifetimes into different
2644     // locations etc.
2645
2646     virtual void setVars(
2647             CORINFO_METHOD_HANDLE           ftn,            // [IN] method of interest
2648             ULONG32                         cVars,          // [IN] size of 'vars'
2649             ICorDebugInfo::NativeVarInfo   *vars            // [IN] map telling where local vars are stored at what points
2650                                                             //      jit allocated with allocateArray, EE frees
2651             ) = 0;
2652
2653     /*-------------------------- Misc ---------------------------------------*/
2654
2655     // Used to allocate memory that needs to handed to the EE.
2656     // For eg, use this to allocated memory for reporting debug info,
2657     // which will be handed to the EE by setVars() and setBoundaries()
2658     virtual void * allocateArray(
2659                         ULONG              cBytes
2660                         ) = 0;
2661
2662     // JitCompiler will free arrays passed by the EE using this
2663     // For eg, The EE returns memory in getVars() and getBoundaries()
2664     // to the JitCompiler, which the JitCompiler should release using
2665     // freeArray()
2666     virtual void freeArray(
2667             void               *array
2668             ) = 0;
2669
2670     /*********************************************************************************/
2671     //
2672     // ICorArgInfo
2673     //
2674     /*********************************************************************************/
2675
2676     // advance the pointer to the argument list.
2677     // a ptr of 0, is special and always means the first argument
2678     virtual CORINFO_ARG_LIST_HANDLE getArgNext (
2679             CORINFO_ARG_LIST_HANDLE     args            /* IN */
2680             ) = 0;
2681
2682     // Get the type of a particular argument
2683     // CORINFO_TYPE_UNDEF is returned when there are no more arguments
2684     // If the type returned is a primitive type (or an enum) *vcTypeRet set to NULL
2685     // otherwise it is set to the TypeHandle associted with the type
2686     // Enumerations will always look their underlying type (probably should fix this)
2687     // Otherwise vcTypeRet is the type as would be seen by the IL,
2688     // The return value is the type that is used for calling convention purposes
2689     // (Thus if the EE wants a value class to be passed like an int, then it will
2690     // return CORINFO_TYPE_INT
2691     virtual CorInfoTypeWithMod getArgType (
2692             CORINFO_SIG_INFO*           sig,            /* IN */
2693             CORINFO_ARG_LIST_HANDLE     args,           /* IN */
2694             CORINFO_CLASS_HANDLE       *vcTypeRet       /* OUT */
2695             ) = 0;
2696
2697     // If the Arg is a CORINFO_TYPE_CLASS fetch the class handle associated with it
2698     virtual CORINFO_CLASS_HANDLE getArgClass (
2699             CORINFO_SIG_INFO*           sig,            /* IN */
2700             CORINFO_ARG_LIST_HANDLE     args            /* IN */
2701             ) = 0;
2702
2703     // Returns type of HFA for valuetype
2704     virtual CorInfoType getHFAType (
2705             CORINFO_CLASS_HANDLE hClass
2706             ) = 0;
2707
2708  /*****************************************************************************
2709  * ICorErrorInfo contains methods to deal with SEH exceptions being thrown
2710  * from the corinfo interface.  These methods may be called when an exception
2711  * with code EXCEPTION_COMPLUS is caught.
2712  *****************************************************************************/
2713
2714     // Returns the HRESULT of the current exception
2715     virtual HRESULT GetErrorHRESULT(
2716             struct _EXCEPTION_POINTERS *pExceptionPointers
2717             ) = 0;
2718
2719     // Fetches the message of the current exception
2720     // Returns the size of the message (including terminating null). This can be
2721     // greater than bufferLength if the buffer is insufficient.
2722     virtual ULONG GetErrorMessage(
2723             __inout_ecount(bufferLength) LPWSTR buffer,
2724             ULONG bufferLength
2725             ) = 0;
2726
2727     // returns EXCEPTION_EXECUTE_HANDLER if it is OK for the compile to handle the
2728     //                        exception, abort some work (like the inlining) and continue compilation
2729     // returns EXCEPTION_CONTINUE_SEARCH if exception must always be handled by the EE
2730     //                    things like ThreadStoppedException ...
2731     // returns EXCEPTION_CONTINUE_EXECUTION if exception is fixed up by the EE
2732
2733     virtual int FilterException(
2734             struct _EXCEPTION_POINTERS *pExceptionPointers
2735             ) = 0;
2736
2737     // Cleans up internal EE tracking when an exception is caught.
2738     virtual void HandleException(
2739             struct _EXCEPTION_POINTERS *pExceptionPointers
2740             ) = 0;
2741
2742     virtual void ThrowExceptionForJitResult(
2743             HRESULT result) = 0;
2744
2745     //Throws an exception defined by the given throw helper.
2746     virtual void ThrowExceptionForHelper(
2747             const CORINFO_HELPER_DESC * throwHelper) = 0;
2748
2749     // Runs the given function under an error trap. This allows the JIT to make calls
2750     // to interface functions that may throw exceptions without needing to be aware of
2751     // the EH ABI, exception types, etc. Returns true if the given function completed
2752     // successfully and false otherwise.
2753     virtual bool runWithErrorTrap(
2754         void (*function)(void*), // The function to run
2755         void* parameter          // The context parameter that will be passed to the function and the handler
2756         ) = 0;
2757
2758 /*****************************************************************************
2759  * ICorStaticInfo contains EE interface methods which return values that are
2760  * constant from invocation to invocation.  Thus they may be embedded in
2761  * persisted information like statically generated code. (This is of course
2762  * assuming that all code versions are identical each time.)
2763  *****************************************************************************/
2764
2765     // Return details about EE internal data structures
2766     virtual void getEEInfo(
2767                 CORINFO_EE_INFO            *pEEInfoOut
2768                 ) = 0;
2769
2770     // Returns name of the JIT timer log
2771     virtual LPCWSTR getJitTimeLogFilename() = 0;
2772
2773     /*********************************************************************************/
2774     //
2775     // Diagnostic methods
2776     //
2777     /*********************************************************************************/
2778
2779     // this function is for debugging only. Returns method token.
2780     // Returns mdMethodDefNil for dynamic methods.
2781     virtual mdMethodDef getMethodDefFromMethod(
2782             CORINFO_METHOD_HANDLE hMethod
2783             ) = 0;
2784
2785     // this function is for debugging only.  It returns the method name
2786     // and if 'moduleName' is non-null, it sets it to something that will
2787     // says which method (a class name, or a module name)
2788     virtual const char* getMethodName (
2789             CORINFO_METHOD_HANDLE       ftn,        /* IN */
2790             const char                **moduleName  /* OUT */
2791             ) = 0;
2792
2793     // this function is for debugging only.  It returns a value that
2794     // is will always be the same for a given method.  It is used
2795     // to implement the 'jitRange' functionality
2796     virtual unsigned getMethodHash (
2797             CORINFO_METHOD_HANDLE       ftn         /* IN */
2798             ) = 0;
2799
2800     // this function is for debugging only.
2801     virtual size_t findNameOfToken (
2802             CORINFO_MODULE_HANDLE       module,     /* IN  */
2803             mdToken                     metaTOK,     /* IN  */
2804             __out_ecount (FQNameCapacity) char * szFQName, /* OUT */
2805             size_t FQNameCapacity  /* IN */
2806             ) = 0;
2807
2808     // returns whether the struct is enregisterable. Only valid on a System V VM. Returns true on success, false on failure.
2809     virtual bool getSystemVAmd64PassStructInRegisterDescriptor(
2810         /* IN */    CORINFO_CLASS_HANDLE        structHnd,
2811         /* OUT */   SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr
2812         ) = 0;
2813
2814 };
2815
2816 /*****************************************************************************
2817  * ICorDynamicInfo contains EE interface methods which return values that may
2818  * change from invocation to invocation.  They cannot be embedded in persisted
2819  * data; they must be requeried each time the EE is run.
2820  *****************************************************************************/
2821
2822 class ICorDynamicInfo : public ICorStaticInfo
2823 {
2824 public:
2825
2826     //
2827     // These methods return values to the JIT which are not constant
2828     // from session to session.
2829     //
2830     // These methods take an extra parameter : void **ppIndirection.
2831     // If a JIT supports generation of prejit code (install-o-jit), it
2832     // must pass a non-null value for this parameter, and check the
2833     // resulting value.  If *ppIndirection is NULL, code should be
2834     // generated normally.  If non-null, then the value of
2835     // *ppIndirection is an address in the cookie table, and the code
2836     // generator needs to generate an indirection through the table to
2837     // get the resulting value.  In this case, the return result of the
2838     // function must NOT be directly embedded in the generated code.
2839     //
2840     // Note that if a JIT does not support prejit code generation, it
2841     // may ignore the extra parameter & pass the default of NULL - the
2842     // prejit ICorDynamicInfo implementation will see this & generate
2843     // an error if the jitter is used in a prejit scenario.
2844     //
2845
2846     // Return details about EE internal data structures
2847
2848     virtual DWORD getThreadTLSIndex(
2849                     void                  **ppIndirection = NULL
2850                     ) = 0;
2851
2852     virtual const void * getInlinedCallFrameVptr(
2853                     void                  **ppIndirection = NULL
2854                     ) = 0;
2855
2856     virtual LONG * getAddrOfCaptureThreadGlobal(
2857                     void                  **ppIndirection = NULL
2858                     ) = 0;
2859
2860     // return the native entry point to an EE helper (see CorInfoHelpFunc)
2861     virtual void* getHelperFtn (
2862                     CorInfoHelpFunc         ftnNum,
2863                     void                  **ppIndirection = NULL
2864                     ) = 0;
2865
2866     // return a callable address of the function (native code). This function
2867     // may return a different value (depending on whether the method has
2868     // been JITed or not.
2869     virtual void getFunctionEntryPoint(
2870                               CORINFO_METHOD_HANDLE   ftn,                 /* IN  */
2871                               CORINFO_CONST_LOOKUP *  pResult,             /* OUT */
2872                               CORINFO_ACCESS_FLAGS    accessFlags = CORINFO_ACCESS_ANY) = 0;
2873
2874     // return a directly callable address. This can be used similarly to the
2875     // value returned by getFunctionEntryPoint() except that it is
2876     // guaranteed to be multi callable entrypoint.
2877     virtual void getFunctionFixedEntryPoint(
2878                               CORINFO_METHOD_HANDLE   ftn,
2879                               CORINFO_CONST_LOOKUP *  pResult) = 0;
2880
2881     // get the synchronization handle that is passed to monXstatic function
2882     virtual void* getMethodSync(
2883                     CORINFO_METHOD_HANDLE               ftn,
2884                     void                  **ppIndirection = NULL
2885                     ) = 0;
2886
2887     // get slow lazy string literal helper to use (CORINFO_HELP_STRCNS*). 
2888     // Returns CORINFO_HELP_UNDEF if lazy string literal helper cannot be used.
2889     virtual CorInfoHelpFunc getLazyStringLiteralHelper(
2890                     CORINFO_MODULE_HANDLE   handle
2891                     ) = 0;
2892
2893     virtual CORINFO_MODULE_HANDLE embedModuleHandle(
2894                     CORINFO_MODULE_HANDLE   handle,
2895                     void                  **ppIndirection = NULL
2896                     ) = 0;
2897
2898     virtual CORINFO_CLASS_HANDLE embedClassHandle(
2899                     CORINFO_CLASS_HANDLE    handle,
2900                     void                  **ppIndirection = NULL
2901                     ) = 0;
2902
2903     virtual CORINFO_METHOD_HANDLE embedMethodHandle(
2904                     CORINFO_METHOD_HANDLE   handle,
2905                     void                  **ppIndirection = NULL
2906                     ) = 0;
2907
2908     virtual CORINFO_FIELD_HANDLE embedFieldHandle(
2909                     CORINFO_FIELD_HANDLE    handle,
2910                     void                  **ppIndirection = NULL
2911                     ) = 0;
2912
2913     // Given a module scope (module), a method handle (context) and
2914     // a metadata token (metaTOK), fetch the handle
2915     // (type, field or method) associated with the token.
2916     // If this is not possible at compile-time (because the current method's
2917     // code is shared and the token contains generic parameters)
2918     // then indicate how the handle should be looked up at run-time.
2919     //
2920     virtual void embedGenericHandle(
2921                         CORINFO_RESOLVED_TOKEN *        pResolvedToken,
2922                         BOOL                            fEmbedParent, // TRUE - embeds parent type handle of the field/method handle
2923                         CORINFO_GENERICHANDLE_RESULT *  pResult) = 0;
2924
2925     // Return information used to locate the exact enclosing type of the current method.
2926     // Used only to invoke .cctor method from code shared across generic instantiations
2927     //   !needsRuntimeLookup       statically known (enclosing type of method itself)
2928     //   needsRuntimeLookup:
2929     //      CORINFO_LOOKUP_THISOBJ     use vtable pointer of 'this' param
2930     //      CORINFO_LOOKUP_CLASSPARAM  use vtable hidden param
2931     //      CORINFO_LOOKUP_METHODPARAM use enclosing type of method-desc hidden param
2932     virtual CORINFO_LOOKUP_KIND getLocationOfThisType(
2933                     CORINFO_METHOD_HANDLE context
2934                     ) = 0;
2935
2936     // NOTE: the two methods below--getPInvokeUnmanagedTarget and getAddressOfPInvokeFixup--are
2937     //       deprecated. New code should instead use getAddressOfPInvokeTarget, which subsumes the
2938     //       functionality of these methods.
2939
2940     // return the unmanaged target *if method has already been prelinked.*
2941     virtual void* getPInvokeUnmanagedTarget(
2942                     CORINFO_METHOD_HANDLE   method,
2943                     void                  **ppIndirection = NULL
2944                     ) = 0;
2945
2946     // return address of fixup area for late-bound PInvoke calls.
2947     virtual void* getAddressOfPInvokeFixup(
2948                     CORINFO_METHOD_HANDLE   method,
2949                     void                  **ppIndirection = NULL
2950                     ) = 0;
2951
2952     // return the address of the PInvoke target. May be a fixup area in the
2953     // case of late-bound PInvoke calls.
2954     virtual void getAddressOfPInvokeTarget(
2955                     CORINFO_METHOD_HANDLE  method,
2956                     CORINFO_CONST_LOOKUP  *pLookup
2957                     ) = 0;
2958
2959     // Generate a cookie based on the signature that would needs to be passed
2960     // to CORINFO_HELP_PINVOKE_CALLI
2961     virtual LPVOID GetCookieForPInvokeCalliSig(
2962             CORINFO_SIG_INFO* szMetaSig,
2963             void           ** ppIndirection = NULL
2964             ) = 0;
2965
2966     // returns true if a VM cookie can be generated for it (might be false due to cross-module
2967     // inlining, in which case the inlining should be aborted)
2968     virtual bool canGetCookieForPInvokeCalliSig(
2969                     CORINFO_SIG_INFO* szMetaSig
2970                     ) = 0;
2971
2972     // Gets a handle that is checked to see if the current method is
2973     // included in "JustMyCode"
2974     virtual CORINFO_JUST_MY_CODE_HANDLE getJustMyCodeHandle(
2975                     CORINFO_METHOD_HANDLE       method,
2976                     CORINFO_JUST_MY_CODE_HANDLE**ppIndirection = NULL
2977                     ) = 0;
2978
2979     // Gets a method handle that can be used to correlate profiling data.
2980     // This is the IP of a native method, or the address of the descriptor struct
2981     // for IL.  Always guaranteed to be unique per process, and not to move. */
2982     virtual void GetProfilingHandle(
2983                     BOOL                      *pbHookFunction,
2984                     void                     **pProfilerHandle,
2985                     BOOL                      *pbIndirectedHandles
2986                     ) = 0;
2987
2988     // Returns instructions on how to make the call. See code:CORINFO_CALL_INFO for possible return values.
2989     virtual void getCallInfo(
2990                         // Token info
2991                         CORINFO_RESOLVED_TOKEN * pResolvedToken,
2992
2993                         //Generics info
2994                         CORINFO_RESOLVED_TOKEN * pConstrainedResolvedToken,
2995
2996                         //Security info
2997                         CORINFO_METHOD_HANDLE   callerHandle,
2998
2999                         //Jit info
3000                         CORINFO_CALLINFO_FLAGS  flags,
3001
3002                         //out params
3003                         CORINFO_CALL_INFO       *pResult
3004                         ) = 0;
3005
3006     virtual BOOL canAccessFamily(CORINFO_METHOD_HANDLE hCaller,
3007                                            CORINFO_CLASS_HANDLE hInstanceType) = 0;
3008
3009     // Returns TRUE if the Class Domain ID is the RID of the class (currently true for every class
3010     // except reflection emitted classes and generics)
3011     virtual BOOL isRIDClassDomainID(CORINFO_CLASS_HANDLE cls) = 0;
3012
3013     // returns the class's domain ID for accessing shared statics
3014     virtual unsigned getClassDomainID (
3015                     CORINFO_CLASS_HANDLE    cls,
3016                     void                  **ppIndirection = NULL
3017                     ) = 0;
3018
3019
3020     // return the data's address (for static fields only)
3021     virtual void* getFieldAddress(
3022                     CORINFO_FIELD_HANDLE    field,
3023                     void                  **ppIndirection = NULL
3024                     ) = 0;
3025
3026     // registers a vararg sig & returns a VM cookie for it (which can contain other stuff)
3027     virtual CORINFO_VARARGS_HANDLE getVarArgsHandle(
3028                     CORINFO_SIG_INFO       *pSig,
3029                     void                  **ppIndirection = NULL
3030                     ) = 0;
3031
3032     // returns true if a VM cookie can be generated for it (might be false due to cross-module
3033     // inlining, in which case the inlining should be aborted)
3034     virtual bool canGetVarArgsHandle(
3035                     CORINFO_SIG_INFO       *pSig
3036                     ) = 0;
3037
3038     // Allocate a string literal on the heap and return a handle to it
3039     virtual InfoAccessType constructStringLiteral(
3040                     CORINFO_MODULE_HANDLE   module,
3041                     mdToken                 metaTok,
3042                     void                  **ppValue
3043                     ) = 0;
3044
3045     virtual InfoAccessType emptyStringLiteral(
3046                     void                  **ppValue
3047                     ) = 0;
3048
3049     // (static fields only) given that 'field' refers to thread local store,
3050     // return the ID (TLS index), which is used to find the begining of the
3051     // TLS data area for the particular DLL 'field' is associated with.
3052     virtual DWORD getFieldThreadLocalStoreID (
3053                     CORINFO_FIELD_HANDLE    field,
3054                     void                  **ppIndirection = NULL
3055                     ) = 0;
3056
3057     // Sets another object to intercept calls to "self" and current method being compiled
3058     virtual void setOverride(
3059                 ICorDynamicInfo             *pOverride,
3060                 CORINFO_METHOD_HANDLE       currentMethod
3061                 ) = 0;
3062
3063     // Adds an active dependency from the context method's module to the given module
3064     // This is internal callback for the EE. JIT should not call it directly.
3065     virtual void addActiveDependency(
3066                CORINFO_MODULE_HANDLE       moduleFrom,
3067                CORINFO_MODULE_HANDLE       moduleTo
3068                 ) = 0;
3069
3070     virtual CORINFO_METHOD_HANDLE GetDelegateCtor(
3071             CORINFO_METHOD_HANDLE  methHnd,
3072             CORINFO_CLASS_HANDLE   clsHnd,
3073             CORINFO_METHOD_HANDLE  targetMethodHnd,
3074             DelegateCtorArgs *     pCtorData
3075             ) = 0;
3076
3077     virtual void MethodCompileComplete(
3078                 CORINFO_METHOD_HANDLE methHnd
3079                 ) = 0;
3080
3081     // return a thunk that will copy the arguments for the given signature.
3082     virtual void* getTailCallCopyArgsThunk (
3083                     CORINFO_SIG_INFO       *pSig,
3084                     CorInfoHelperTailCallSpecialHandling flags
3085                     ) = 0;
3086 };
3087
3088 /**********************************************************************************/
3089
3090 // It would be nicer to use existing IMAGE_REL_XXX constants instead of defining our own here...
3091 #define IMAGE_REL_BASED_REL32           0x10
3092 #define IMAGE_REL_BASED_THUMB_BRANCH24  0x13
3093
3094 // The identifier for ARM32-specific PC-relative address
3095 // computation corresponds to the following instruction
3096 // sequence:
3097 //  l0: movw rX, #imm_lo  // 4 byte
3098 //  l4: movt rX, #imm_hi  // 4 byte
3099 //  l8: add  rX, pc <- after this instruction rX = relocTarget
3100 //
3101 // Program counter at l8 is address of l8 + 4
3102 // Address of relocated movw/movt is l0
3103 // So, imm should be calculated as the following:
3104 //  imm = relocTarget - (l8 + 4) = relocTarget - (l0 + 8 + 4) = relocTarget - (l_0 + 12)
3105 // So, the value of offset correction is 12
3106 //
3107 #define IMAGE_REL_BASED_REL_THUMB_MOV32_PCREL   0x14
3108
3109 #endif // _COR_INFO_H_