Merge pull request #11456 from CarolEidt/EHWriteThruDoc
[platform/upstream/coreclr.git] / src / ToolBox / superpmi / superpmi-shim-counter / icorjitinfo.cpp
1 //
2 // Copyright (c) Microsoft. All rights reserved.
3 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4 //
5
6 #include "standardpch.h"
7 #include "icorjitinfo.h"
8 #include "superpmi-shim-counter.h"
9 #include "ieememorymanager.h"
10 #include "icorjitcompiler.h"
11 #include "spmiutil.h"
12
13 // Stuff on ICorStaticInfo
14 /**********************************************************************************/
15 //
16 // ICorMethodInfo
17 //
18 /**********************************************************************************/
19 // return flags (defined above, CORINFO_FLG_PUBLIC ...)
20 DWORD interceptor_ICJI::getMethodAttribs(CORINFO_METHOD_HANDLE ftn /* IN */)
21 {
22     mcs->AddCall("getMethodAttribs");
23     return original_ICorJitInfo->getMethodAttribs(ftn);
24 }
25
26 // sets private JIT flags, which can be, retrieved using getAttrib.
27 void interceptor_ICJI::setMethodAttribs(CORINFO_METHOD_HANDLE     ftn, /* IN */
28                                         CorInfoMethodRuntimeFlags attribs /* IN */)
29 {
30     mcs->AddCall("setMethodAttribs");
31     original_ICorJitInfo->setMethodAttribs(ftn, attribs);
32 }
33
34 // Given a method descriptor ftnHnd, extract signature information into sigInfo
35 //
36 // 'memberParent' is typically only set when verifying.  It should be the
37 // result of calling getMemberParent.
38 void interceptor_ICJI::getMethodSig(CORINFO_METHOD_HANDLE ftn,         /* IN  */
39                                     CORINFO_SIG_INFO*     sig,         /* OUT */
40                                     CORINFO_CLASS_HANDLE  memberParent /* IN */
41                                     )
42 {
43     mcs->AddCall("getMethodSig");
44     original_ICorJitInfo->getMethodSig(ftn, sig, memberParent);
45 }
46
47 /*********************************************************************
48 * Note the following methods can only be used on functions known
49 * to be IL.  This includes the method being compiled and any method
50 * that 'getMethodInfo' returns true for
51 *********************************************************************/
52
53 // return information about a method private to the implementation
54 //      returns false if method is not IL, or is otherwise unavailable.
55 //      This method is used to fetch data needed to inline functions
56 bool interceptor_ICJI::getMethodInfo(CORINFO_METHOD_HANDLE ftn, /* IN  */
57                                      CORINFO_METHOD_INFO*  info /* OUT */
58                                      )
59 {
60     mcs->AddCall("getMethodInfo");
61     return original_ICorJitInfo->getMethodInfo(ftn, info);
62 }
63
64 // Decides if you have any limitations for inlining. If everything's OK, it will return
65 // INLINE_PASS and will fill out pRestrictions with a mask of restrictions the caller of this
66 // function must respect. If caller passes pRestrictions = nullptr, if there are any restrictions
67 // INLINE_FAIL will be returned
68 //
69 // The callerHnd must be the immediate caller (i.e. when we have a chain of inlined calls)
70 //
71 // The inlined method need not be verified
72
73 CorInfoInline interceptor_ICJI::canInline(CORINFO_METHOD_HANDLE callerHnd,    /* IN  */
74                                           CORINFO_METHOD_HANDLE calleeHnd,    /* IN  */
75                                           DWORD*                pRestrictions /* OUT */
76                                           )
77 {
78     mcs->AddCall("canInline");
79     return original_ICorJitInfo->canInline(callerHnd, calleeHnd, pRestrictions);
80 }
81
82 // Reports whether or not a method can be inlined, and why.  canInline is responsible for reporting all
83 // inlining results when it returns INLINE_FAIL and INLINE_NEVER.  All other results are reported by the
84 // JIT.
85 void interceptor_ICJI::reportInliningDecision(CORINFO_METHOD_HANDLE inlinerHnd,
86                                               CORINFO_METHOD_HANDLE inlineeHnd,
87                                               CorInfoInline         inlineResult,
88                                               const char*           reason)
89 {
90     mcs->AddCall("reportInliningDecision");
91     original_ICorJitInfo->reportInliningDecision(inlinerHnd, inlineeHnd, inlineResult, reason);
92 }
93
94 // Returns false if the call is across security boundaries thus we cannot tailcall
95 //
96 // The callerHnd must be the immediate caller (i.e. when we have a chain of inlined calls)
97 bool interceptor_ICJI::canTailCall(CORINFO_METHOD_HANDLE callerHnd,         /* IN */
98                                    CORINFO_METHOD_HANDLE declaredCalleeHnd, /* IN */
99                                    CORINFO_METHOD_HANDLE exactCalleeHnd,    /* IN */
100                                    bool                  fIsTailPrefix      /* IN */
101                                    )
102 {
103     mcs->AddCall("canTailCall");
104     return original_ICorJitInfo->canTailCall(callerHnd, declaredCalleeHnd, exactCalleeHnd, fIsTailPrefix);
105 }
106
107 // Reports whether or not a method can be tail called, and why.
108 // canTailCall is responsible for reporting all results when it returns
109 // false.  All other results are reported by the JIT.
110 void interceptor_ICJI::reportTailCallDecision(CORINFO_METHOD_HANDLE callerHnd,
111                                               CORINFO_METHOD_HANDLE calleeHnd,
112                                               bool                  fIsTailPrefix,
113                                               CorInfoTailCall       tailCallResult,
114                                               const char*           reason)
115 {
116     mcs->AddCall("reportTailCallDecision");
117     original_ICorJitInfo->reportTailCallDecision(callerHnd, calleeHnd, fIsTailPrefix, tailCallResult, reason);
118 }
119
120 // get individual exception handler
121 void interceptor_ICJI::getEHinfo(CORINFO_METHOD_HANDLE ftn,      /* IN  */
122                                  unsigned              EHnumber, /* IN */
123                                  CORINFO_EH_CLAUSE*    clause    /* OUT */
124                                  )
125 {
126     mcs->AddCall("getEHinfo");
127     original_ICorJitInfo->getEHinfo(ftn, EHnumber, clause);
128 }
129
130 // return class it belongs to
131 CORINFO_CLASS_HANDLE interceptor_ICJI::getMethodClass(CORINFO_METHOD_HANDLE method)
132 {
133     mcs->AddCall("getMethodClass");
134     return original_ICorJitInfo->getMethodClass(method);
135 }
136
137 // return module it belongs to
138 CORINFO_MODULE_HANDLE interceptor_ICJI::getMethodModule(CORINFO_METHOD_HANDLE method)
139 {
140     mcs->AddCall("getMethodModule");
141     return original_ICorJitInfo->getMethodModule(method);
142 }
143
144 // This function returns the offset of the specified method in the
145 // vtable of it's owning class or interface.
146 void interceptor_ICJI::getMethodVTableOffset(CORINFO_METHOD_HANDLE method,                /* IN */
147                                              unsigned*             offsetOfIndirection,   /* OUT */
148                                              unsigned*             offsetAfterIndirection /* OUT */
149                                              )
150 {
151     mcs->AddCall("getMethodVTableOffset");
152     original_ICorJitInfo->getMethodVTableOffset(method, offsetOfIndirection, offsetAfterIndirection);
153 }
154
155 // Find the virtual method in implementingClass that overrides virtualMethod.
156 // Return null if devirtualization is not possible.
157 CORINFO_METHOD_HANDLE interceptor_ICJI::resolveVirtualMethod(CORINFO_METHOD_HANDLE  virtualMethod,
158                                                              CORINFO_CLASS_HANDLE   implementingClass,
159                                                              CORINFO_CONTEXT_HANDLE ownerType)
160 {
161     mcs->AddCall("resolveVirtualMethod");
162     return original_ICorJitInfo->resolveVirtualMethod(virtualMethod, implementingClass, ownerType);
163 }
164
165 void interceptor_ICJI::expandRawHandleIntrinsic(
166     CORINFO_RESOLVED_TOKEN *        pResolvedToken,
167     CORINFO_GENERICHANDLE_RESULT *  pResult)
168 {
169     mcs->AddCall("expandRawHandleIntrinsic");
170     original_ICorJitInfo->expandRawHandleIntrinsic(pResolvedToken, pResult);
171 }
172
173 // If a method's attributes have (getMethodAttribs) CORINFO_FLG_INTRINSIC set,
174 // getIntrinsicID() returns the intrinsic ID.
175 CorInfoIntrinsics interceptor_ICJI::getIntrinsicID(CORINFO_METHOD_HANDLE method, bool* pMustExpand /* OUT */
176                                                    )
177 {
178     mcs->AddCall("getIntrinsicID");
179     return original_ICorJitInfo->getIntrinsicID(method, pMustExpand);
180 }
181
182 // Is the given module the System.Numerics.Vectors module?
183 bool interceptor_ICJI::isInSIMDModule(CORINFO_CLASS_HANDLE classHnd)
184 {
185     mcs->AddCall("isInSIMDModule");
186     return original_ICorJitInfo->isInSIMDModule(classHnd);
187 }
188
189 // return the unmanaged calling convention for a PInvoke
190 CorInfoUnmanagedCallConv interceptor_ICJI::getUnmanagedCallConv(CORINFO_METHOD_HANDLE method)
191 {
192     mcs->AddCall("getUnmanagedCallConv");
193     return original_ICorJitInfo->getUnmanagedCallConv(method);
194 }
195
196 // return if any marshaling is required for PInvoke methods.  Note that
197 // method == 0 => calli.  The call site sig is only needed for the varargs or calli case
198 BOOL interceptor_ICJI::pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* callSiteSig)
199 {
200     mcs->AddCall("pInvokeMarshalingRequired");
201     return original_ICorJitInfo->pInvokeMarshalingRequired(method, callSiteSig);
202 }
203
204 // Check constraints on method type arguments (only).
205 // The parent class should be checked separately using satisfiesClassConstraints(parent).
206 BOOL interceptor_ICJI::satisfiesMethodConstraints(CORINFO_CLASS_HANDLE  parent, // the exact parent of the method
207                                                   CORINFO_METHOD_HANDLE method)
208 {
209     mcs->AddCall("satisfiesMethodConstraints");
210     return original_ICorJitInfo->satisfiesMethodConstraints(parent, method);
211 }
212
213 // Given a delegate target class, a target method parent class,  a  target method,
214 // a delegate class, check if the method signature is compatible with the Invoke method of the delegate
215 // (under the typical instantiation of any free type variables in the memberref signatures).
216 BOOL interceptor_ICJI::isCompatibleDelegate(
217     CORINFO_CLASS_HANDLE  objCls,          /* type of the delegate target, if any */
218     CORINFO_CLASS_HANDLE  methodParentCls, /* exact parent of the target method, if any */
219     CORINFO_METHOD_HANDLE method,          /* (representative) target method, if any */
220     CORINFO_CLASS_HANDLE  delegateCls,     /* exact type of the delegate */
221     BOOL*                 pfIsOpenDelegate /* is the delegate open */
222     )
223 {
224     mcs->AddCall("isCompatibleDelegate");
225     return original_ICorJitInfo->isCompatibleDelegate(objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate);
226 }
227
228 // Indicates if the method is an instance of the generic
229 // method that passes (or has passed) verification
230 CorInfoInstantiationVerification interceptor_ICJI::isInstantiationOfVerifiedGeneric(CORINFO_METHOD_HANDLE method /* IN
231                                                                                                                   */
232                                                                                     )
233 {
234     mcs->AddCall("isInstantiationOfVerifiedGeneric");
235     return original_ICorJitInfo->isInstantiationOfVerifiedGeneric(method);
236 }
237
238 // Loads the constraints on a typical method definition, detecting cycles;
239 // for use in verification.
240 void interceptor_ICJI::initConstraintsForVerification(CORINFO_METHOD_HANDLE method,                        /* IN */
241                                                       BOOL*                 pfHasCircularClassConstraints, /* OUT */
242                                                       BOOL*                 pfHasCircularMethodConstraint  /* OUT */
243                                                       )
244 {
245     mcs->AddCall("initConstraintsForVerification");
246     original_ICorJitInfo->initConstraintsForVerification(method, pfHasCircularClassConstraints,
247                                                          pfHasCircularMethodConstraint);
248 }
249
250 // Returns enum whether the method does not require verification
251 // Also see ICorModuleInfo::canSkipVerification
252 CorInfoCanSkipVerificationResult interceptor_ICJI::canSkipMethodVerification(CORINFO_METHOD_HANDLE ftnHandle)
253 {
254     mcs->AddCall("canSkipMethodVerification");
255     return original_ICorJitInfo->canSkipMethodVerification(ftnHandle);
256 }
257
258 // load and restore the method
259 void interceptor_ICJI::methodMustBeLoadedBeforeCodeIsRun(CORINFO_METHOD_HANDLE method)
260 {
261     mcs->AddCall("methodMustBeLoadedBeforeCodeIsRun");
262     original_ICorJitInfo->methodMustBeLoadedBeforeCodeIsRun(method);
263 }
264
265 CORINFO_METHOD_HANDLE interceptor_ICJI::mapMethodDeclToMethodImpl(CORINFO_METHOD_HANDLE method)
266 {
267     mcs->AddCall("mapMethodDeclToMethodImpl");
268     return original_ICorJitInfo->mapMethodDeclToMethodImpl(method);
269 }
270
271 // Returns the global cookie for the /GS unsafe buffer checks
272 // The cookie might be a constant value (JIT), or a handle to memory location (Ngen)
273 void interceptor_ICJI::getGSCookie(GSCookie*  pCookieVal, // OUT
274                                    GSCookie** ppCookieVal // OUT
275                                    )
276 {
277     mcs->AddCall("getGSCookie");
278     original_ICorJitInfo->getGSCookie(pCookieVal, ppCookieVal);
279 }
280
281 /**********************************************************************************/
282 //
283 // ICorModuleInfo
284 //
285 /**********************************************************************************/
286
287 // Resolve metadata token into runtime method handles.
288 void interceptor_ICJI::resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN* pResolvedToken)
289 {
290     mcs->AddCall("resolveToken");
291     original_ICorJitInfo->resolveToken(pResolvedToken);
292 }
293
294 bool interceptor_ICJI::tryResolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN* pResolvedToken)
295 {
296     mcs->AddCall("tryResolveToken");
297     return original_ICorJitInfo->tryResolveToken(pResolvedToken);
298 }
299
300 // Signature information about the call sig
301 void interceptor_ICJI::findSig(CORINFO_MODULE_HANDLE  module,  /* IN */
302                                unsigned               sigTOK,  /* IN */
303                                CORINFO_CONTEXT_HANDLE context, /* IN */
304                                CORINFO_SIG_INFO*      sig      /* OUT */
305                                )
306 {
307     mcs->AddCall("findSig");
308     original_ICorJitInfo->findSig(module, sigTOK, context, sig);
309 }
310
311 // for Varargs, the signature at the call site may differ from
312 // the signature at the definition.  Thus we need a way of
313 // fetching the call site information
314 void interceptor_ICJI::findCallSiteSig(CORINFO_MODULE_HANDLE  module,  /* IN */
315                                        unsigned               methTOK, /* IN */
316                                        CORINFO_CONTEXT_HANDLE context, /* IN */
317                                        CORINFO_SIG_INFO*      sig      /* OUT */
318                                        )
319 {
320     mcs->AddCall("findCallSiteSig");
321     original_ICorJitInfo->findCallSiteSig(module, methTOK, context, sig);
322 }
323
324 CORINFO_CLASS_HANDLE interceptor_ICJI::getTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken /* IN  */)
325 {
326     mcs->AddCall("getTokenTypeAsHandle");
327     return original_ICorJitInfo->getTokenTypeAsHandle(pResolvedToken);
328 }
329
330 // Returns true if the module does not require verification
331 //
332 // If fQuickCheckOnlyWithoutCommit=TRUE, the function only checks that the
333 // module does not currently require verification in the current AppDomain.
334 // This decision could change in the future, and so should not be cached.
335 // If it is cached, it should only be used as a hint.
336 // This is only used by ngen for calculating certain hints.
337 //
338
339 // Returns enum whether the module does not require verification
340 // Also see ICorMethodInfo::canSkipMethodVerification();
341 CorInfoCanSkipVerificationResult interceptor_ICJI::canSkipVerification(CORINFO_MODULE_HANDLE module /* IN  */
342                                                                        )
343 {
344     mcs->AddCall("canSkipVerification");
345     return original_ICorJitInfo->canSkipVerification(module);
346 }
347
348 // Checks if the given metadata token is valid
349 BOOL interceptor_ICJI::isValidToken(CORINFO_MODULE_HANDLE module, /* IN  */
350                                     unsigned              metaTOK /* IN  */
351                                     )
352 {
353     mcs->AddCall("isValidToken");
354     return original_ICorJitInfo->isValidToken(module, metaTOK);
355 }
356
357 // Checks if the given metadata token is valid StringRef
358 BOOL interceptor_ICJI::isValidStringRef(CORINFO_MODULE_HANDLE module, /* IN  */
359                                         unsigned              metaTOK /* IN  */
360                                         )
361 {
362     mcs->AddCall("isValidStringRef");
363     return original_ICorJitInfo->isValidStringRef(module, metaTOK);
364 }
365
366 BOOL interceptor_ICJI::shouldEnforceCallvirtRestriction(CORINFO_MODULE_HANDLE scope)
367 {
368     mcs->AddCall("shouldEnforceCallvirtRestriction");
369     return original_ICorJitInfo->shouldEnforceCallvirtRestriction(scope);
370 }
371
372 /**********************************************************************************/
373 //
374 // ICorClassInfo
375 //
376 /**********************************************************************************/
377
378 // If the value class 'cls' is isomorphic to a primitive type it will
379 // return that type, otherwise it will return CORINFO_TYPE_VALUECLASS
380 CorInfoType interceptor_ICJI::asCorInfoType(CORINFO_CLASS_HANDLE cls)
381 {
382     mcs->AddCall("asCorInfoType");
383     return original_ICorJitInfo->asCorInfoType(cls);
384 }
385
386 // for completeness
387 const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls)
388 {
389     mcs->AddCall("getClassName");
390     return original_ICorJitInfo->getClassName(cls);
391 }
392
393 // Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
394 // If fNamespace=TRUE, include the namespace/enclosing classes
395 // If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters
396 // If fAssembly=TRUE, suffix with a comma and the full assembly qualification
397 // return size of representation
398 int interceptor_ICJI::appendClassName(__deref_inout_ecount(*pnBufLen) WCHAR** ppBuf,
399                                       int*                                    pnBufLen,
400                                       CORINFO_CLASS_HANDLE                    cls,
401                                       BOOL                                    fNamespace,
402                                       BOOL                                    fFullInst,
403                                       BOOL                                    fAssembly)
404 {
405     mcs->AddCall("appendClassName");
406     return original_ICorJitInfo->appendClassName(ppBuf, pnBufLen, cls, fNamespace, fFullInst, fAssembly);
407 }
408
409 // Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) &
410 // CORINFO_FLG_VALUECLASS, except faster.
411 BOOL interceptor_ICJI::isValueClass(CORINFO_CLASS_HANDLE cls)
412 {
413     mcs->AddCall("isValueClass");
414     return original_ICorJitInfo->isValueClass(cls);
415 }
416
417 // If this method returns true, JIT will do optimization to inline the check for
418 //     GetTypeFromHandle(handle) == obj.GetType()
419 BOOL interceptor_ICJI::canInlineTypeCheckWithObjectVTable(CORINFO_CLASS_HANDLE cls)
420 {
421     mcs->AddCall("canInlineTypeCheckWithObjectVTable");
422     return original_ICorJitInfo->canInlineTypeCheckWithObjectVTable(cls);
423 }
424
425 // return flags (defined above, CORINFO_FLG_PUBLIC ...)
426 DWORD interceptor_ICJI::getClassAttribs(CORINFO_CLASS_HANDLE cls)
427 {
428     mcs->AddCall("getClassAttribs");
429     return original_ICorJitInfo->getClassAttribs(cls);
430 }
431
432 // Returns "TRUE" iff "cls" is a struct type such that return buffers used for returning a value
433 // of this type must be stack-allocated.  This will generally be true only if the struct
434 // contains GC pointers, and does not exceed some size limit.  Maintaining this as an invariant allows
435 // an optimization: the JIT may assume that return buffer pointers for return types for which this predicate
436 // returns TRUE are always stack allocated, and thus, that stores to the GC-pointer fields of such return
437 // buffers do not require GC write barriers.
438 BOOL interceptor_ICJI::isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls)
439 {
440     mcs->AddCall("isStructRequiringStackAllocRetBuf");
441     return original_ICorJitInfo->isStructRequiringStackAllocRetBuf(cls);
442 }
443
444 CORINFO_MODULE_HANDLE interceptor_ICJI::getClassModule(CORINFO_CLASS_HANDLE cls)
445 {
446     mcs->AddCall("getClassModule");
447     return original_ICorJitInfo->getClassModule(cls);
448 }
449
450 // Returns the assembly that contains the module "mod".
451 CORINFO_ASSEMBLY_HANDLE interceptor_ICJI::getModuleAssembly(CORINFO_MODULE_HANDLE mod)
452 {
453     mcs->AddCall("getModuleAssembly");
454     return original_ICorJitInfo->getModuleAssembly(mod);
455 }
456
457 // Returns the name of the assembly "assem".
458 const char* interceptor_ICJI::getAssemblyName(CORINFO_ASSEMBLY_HANDLE assem)
459 {
460     mcs->AddCall("getAssemblyName");
461     return original_ICorJitInfo->getAssemblyName(assem);
462 }
463
464 // Allocate and delete process-lifetime objects.  Should only be
465 // referred to from static fields, lest a leak occur.
466 // Note that "LongLifetimeFree" does not execute destructors, if "obj"
467 // is an array of a struct type with a destructor.
468 void* interceptor_ICJI::LongLifetimeMalloc(size_t sz)
469 {
470     mcs->AddCall("LongLifetimeMalloc");
471     return original_ICorJitInfo->LongLifetimeMalloc(sz);
472 }
473
474 void interceptor_ICJI::LongLifetimeFree(void* obj)
475 {
476     mcs->AddCall("LongLifetimeFree");
477     original_ICorJitInfo->LongLifetimeFree(obj);
478 }
479
480 size_t interceptor_ICJI::getClassModuleIdForStatics(CORINFO_CLASS_HANDLE   cls,
481                                                     CORINFO_MODULE_HANDLE* pModule,
482                                                     void**                 ppIndirection)
483 {
484     mcs->AddCall("getClassModuleIdForStatics");
485     return original_ICorJitInfo->getClassModuleIdForStatics(cls, pModule, ppIndirection);
486 }
487
488 // return the number of bytes needed by an instance of the class
489 unsigned interceptor_ICJI::getClassSize(CORINFO_CLASS_HANDLE cls)
490 {
491     mcs->AddCall("getClassSize");
492     return original_ICorJitInfo->getClassSize(cls);
493 }
494
495 unsigned interceptor_ICJI::getClassAlignmentRequirement(CORINFO_CLASS_HANDLE cls, BOOL fDoubleAlignHint)
496 {
497     mcs->AddCall("getClassAlignmentRequirement");
498     return original_ICorJitInfo->getClassAlignmentRequirement(cls, fDoubleAlignHint);
499 }
500
501 // This is only called for Value classes.  It returns a boolean array
502 // in representing of 'cls' from a GC perspective.  The class is
503 // assumed to be an array of machine words
504 // (of length // getClassSize(cls) / sizeof(void*)),
505 // 'gcPtrs' is a pointer to an array of BYTEs of this length.
506 // getClassGClayout fills in this array so that gcPtrs[i] is set
507 // to one of the CorInfoGCType values which is the GC type of
508 // the i-th machine word of an object of type 'cls'
509 // returns the number of GC pointers in the array
510 unsigned interceptor_ICJI::getClassGClayout(CORINFO_CLASS_HANDLE cls,   /* IN */
511                                             BYTE*                gcPtrs /* OUT */
512                                             )
513 {
514     mcs->AddCall("getClassGClayout");
515     return original_ICorJitInfo->getClassGClayout(cls, gcPtrs);
516 }
517
518 // returns the number of instance fields in a class
519 unsigned interceptor_ICJI::getClassNumInstanceFields(CORINFO_CLASS_HANDLE cls /* IN */
520                                                      )
521 {
522     mcs->AddCall("getClassNumInstanceFields");
523     return original_ICorJitInfo->getClassNumInstanceFields(cls);
524 }
525
526 CORINFO_FIELD_HANDLE interceptor_ICJI::getFieldInClass(CORINFO_CLASS_HANDLE clsHnd, INT num)
527 {
528     mcs->AddCall("getFieldInClass");
529     return original_ICorJitInfo->getFieldInClass(clsHnd, num);
530 }
531
532 BOOL interceptor_ICJI::checkMethodModifier(CORINFO_METHOD_HANDLE hMethod, LPCSTR modifier, BOOL fOptional)
533 {
534     mcs->AddCall("checkMethodModifier");
535     return original_ICorJitInfo->checkMethodModifier(hMethod, modifier, fOptional);
536 }
537
538 // returns the "NEW" helper optimized for "newCls."
539 CorInfoHelpFunc interceptor_ICJI::getNewHelper(CORINFO_RESOLVED_TOKEN* pResolvedToken,
540                                                CORINFO_METHOD_HANDLE   callerHandle)
541 {
542     mcs->AddCall("getNewHelper");
543     return original_ICorJitInfo->getNewHelper(pResolvedToken, callerHandle);
544 }
545
546 // returns the newArr (1-Dim array) helper optimized for "arrayCls."
547 CorInfoHelpFunc interceptor_ICJI::getNewArrHelper(CORINFO_CLASS_HANDLE arrayCls)
548 {
549     mcs->AddCall("getNewArrHelper");
550     return original_ICorJitInfo->getNewArrHelper(arrayCls);
551 }
552
553 // returns the optimized "IsInstanceOf" or "ChkCast" helper
554 CorInfoHelpFunc interceptor_ICJI::getCastingHelper(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fThrowing)
555 {
556     mcs->AddCall("getCastingHelper");
557     return original_ICorJitInfo->getCastingHelper(pResolvedToken, fThrowing);
558 }
559
560 // returns helper to trigger static constructor
561 CorInfoHelpFunc interceptor_ICJI::getSharedCCtorHelper(CORINFO_CLASS_HANDLE clsHnd)
562 {
563     mcs->AddCall("getSharedCCtorHelper");
564     return original_ICorJitInfo->getSharedCCtorHelper(clsHnd);
565 }
566
567 CorInfoHelpFunc interceptor_ICJI::getSecurityPrologHelper(CORINFO_METHOD_HANDLE ftn)
568 {
569     mcs->AddCall("getSecurityPrologHelper");
570     return original_ICorJitInfo->getSecurityPrologHelper(ftn);
571 }
572
573 // This is not pretty.  Boxing nullable<T> actually returns
574 // a boxed<T> not a boxed Nullable<T>.  This call allows the verifier
575 // to call back to the EE on the 'box' instruction and get the transformed
576 // type to use for verification.
577 CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeForBox(CORINFO_CLASS_HANDLE cls)
578 {
579     mcs->AddCall("getTypeForBox");
580     return original_ICorJitInfo->getTypeForBox(cls);
581 }
582
583 // returns the correct box helper for a particular class.  Note
584 // that if this returns CORINFO_HELP_BOX, the JIT can assume
585 // 'standard' boxing (allocate object and copy), and optimize
586 CorInfoHelpFunc interceptor_ICJI::getBoxHelper(CORINFO_CLASS_HANDLE cls)
587 {
588     mcs->AddCall("getBoxHelper");
589     return original_ICorJitInfo->getBoxHelper(cls);
590 }
591
592 // returns the unbox helper.  If 'helperCopies' points to a true
593 // value it means the JIT is requesting a helper that unboxes the
594 // value into a particular location and thus has the signature
595 //     void unboxHelper(void* dest, CORINFO_CLASS_HANDLE cls, Object* obj)
596 // Otherwise (it is null or points at a FALSE value) it is requesting
597 // a helper that returns a pointer to the unboxed data
598 //     void* unboxHelper(CORINFO_CLASS_HANDLE cls, Object* obj)
599 // The EE has the option of NOT returning the copy style helper
600 // (But must be able to always honor the non-copy style helper)
601 // The EE set 'helperCopies' on return to indicate what kind of
602 // helper has been created.
603
604 CorInfoHelpFunc interceptor_ICJI::getUnBoxHelper(CORINFO_CLASS_HANDLE cls)
605 {
606     mcs->AddCall("getUnBoxHelper");
607     return original_ICorJitInfo->getUnBoxHelper(cls);
608 }
609
610 bool interceptor_ICJI::getReadyToRunHelper(CORINFO_RESOLVED_TOKEN* pResolvedToken,
611                                            CORINFO_LOOKUP_KIND*    pGenericLookupKind,
612                                            CorInfoHelpFunc         id,
613                                            CORINFO_CONST_LOOKUP*   pLookup)
614 {
615     mcs->AddCall("getReadyToRunHelper");
616     return original_ICorJitInfo->getReadyToRunHelper(pResolvedToken, pGenericLookupKind, id, pLookup);
617 }
618
619 void interceptor_ICJI::getReadyToRunDelegateCtorHelper(CORINFO_RESOLVED_TOKEN* pTargetMethod,
620                                                        CORINFO_CLASS_HANDLE    delegateType,
621                                                        CORINFO_LOOKUP*         pLookup)
622 {
623     mcs->AddCall("getReadyToRunDelegateCtorHelper");
624     original_ICorJitInfo->getReadyToRunDelegateCtorHelper(pTargetMethod, delegateType, pLookup);
625 }
626
627 const char* interceptor_ICJI::getHelperName(CorInfoHelpFunc funcNum)
628 {
629     mcs->AddCall("getHelperName");
630     return original_ICorJitInfo->getHelperName(funcNum);
631 }
632
633 // This function tries to initialize the class (run the class constructor).
634 // this function returns whether the JIT must insert helper calls before
635 // accessing static field or method.
636 //
637 // See code:ICorClassInfo#ClassConstruction.
638 CorInfoInitClassResult interceptor_ICJI::initClass(
639     CORINFO_FIELD_HANDLE field,        // Non-nullptr - inquire about cctor trigger before static field access
640                                        // nullptr - inquire about cctor trigger in method prolog
641     CORINFO_METHOD_HANDLE  method,     // Method referencing the field or prolog
642     CORINFO_CONTEXT_HANDLE context,    // Exact context of method
643     BOOL                   speculative // TRUE means don't actually run it
644     )
645 {
646     mcs->AddCall("initClass");
647     return original_ICorJitInfo->initClass(field, method, context, speculative);
648 }
649
650 // This used to be called "loadClass".  This records the fact
651 // that the class must be loaded (including restored if necessary) before we execute the
652 // code that we are currently generating.  When jitting code
653 // the function loads the class immediately.  When zapping code
654 // the zapper will if necessary use the call to record the fact that we have
655 // to do a fixup/restore before running the method currently being generated.
656 //
657 // This is typically used to ensure value types are loaded before zapped
658 // code that manipulates them is executed, so that the GC can access information
659 // about those value types.
660 void interceptor_ICJI::classMustBeLoadedBeforeCodeIsRun(CORINFO_CLASS_HANDLE cls)
661 {
662     mcs->AddCall("classMustBeLoadedBeforeCodeIsRun");
663     original_ICorJitInfo->classMustBeLoadedBeforeCodeIsRun(cls);
664 }
665
666 // returns the class handle for the special builtin classes
667 CORINFO_CLASS_HANDLE interceptor_ICJI::getBuiltinClass(CorInfoClassId classId)
668 {
669     mcs->AddCall("getBuiltinClass");
670     return original_ICorJitInfo->getBuiltinClass(classId);
671 }
672
673 // "System.Int32" ==> CORINFO_TYPE_INT..
674 CorInfoType interceptor_ICJI::getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE cls)
675 {
676     mcs->AddCall("getTypeForPrimitiveValueClass");
677     return original_ICorJitInfo->getTypeForPrimitiveValueClass(cls);
678 }
679
680 // TRUE if child is a subtype of parent
681 // if parent is an interface, then does child implement / extend parent
682 BOOL interceptor_ICJI::canCast(CORINFO_CLASS_HANDLE child, // subtype (extends parent)
683                                CORINFO_CLASS_HANDLE parent // base type
684                                )
685 {
686     mcs->AddCall("canCast");
687     return original_ICorJitInfo->canCast(child, parent);
688 }
689
690 // TRUE if cls1 and cls2 are considered equivalent types.
691 BOOL interceptor_ICJI::areTypesEquivalent(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2)
692 {
693     mcs->AddCall("areTypesEquivalent");
694     return original_ICorJitInfo->areTypesEquivalent(cls1, cls2);
695 }
696
697 // returns is the intersection of cls1 and cls2.
698 CORINFO_CLASS_HANDLE interceptor_ICJI::mergeClasses(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2)
699 {
700     mcs->AddCall("mergeClasses");
701     return original_ICorJitInfo->mergeClasses(cls1, cls2);
702 }
703
704 // Given a class handle, returns the Parent type.
705 // For COMObjectType, it returns Class Handle of System.Object.
706 // Returns 0 if System.Object is passed in.
707 CORINFO_CLASS_HANDLE interceptor_ICJI::getParentType(CORINFO_CLASS_HANDLE cls)
708 {
709     mcs->AddCall("getParentType");
710     return original_ICorJitInfo->getParentType(cls);
711 }
712
713 // Returns the CorInfoType of the "child type". If the child type is
714 // not a primitive type, *clsRet will be set.
715 // Given an Array of Type Foo, returns Foo.
716 // Given BYREF Foo, returns Foo
717 CorInfoType interceptor_ICJI::getChildType(CORINFO_CLASS_HANDLE clsHnd, CORINFO_CLASS_HANDLE* clsRet)
718 {
719     mcs->AddCall("getChildType");
720     return original_ICorJitInfo->getChildType(clsHnd, clsRet);
721 }
722
723 // Check constraints on type arguments of this class and parent classes
724 BOOL interceptor_ICJI::satisfiesClassConstraints(CORINFO_CLASS_HANDLE cls)
725 {
726     mcs->AddCall("satisfiesClassConstraints");
727     return original_ICorJitInfo->satisfiesClassConstraints(cls);
728 }
729
730 // Check if this is a single dimensional array type
731 BOOL interceptor_ICJI::isSDArray(CORINFO_CLASS_HANDLE cls)
732 {
733     mcs->AddCall("isSDArray");
734     return original_ICorJitInfo->isSDArray(cls);
735 }
736
737 // Get the numbmer of dimensions in an array
738 unsigned interceptor_ICJI::getArrayRank(CORINFO_CLASS_HANDLE cls)
739 {
740     mcs->AddCall("getArrayRank");
741     return original_ICorJitInfo->getArrayRank(cls);
742 }
743
744 // Get static field data for an array
745 void* interceptor_ICJI::getArrayInitializationData(CORINFO_FIELD_HANDLE field, DWORD size)
746 {
747     mcs->AddCall("getArrayInitializationData");
748     return original_ICorJitInfo->getArrayInitializationData(field, size);
749 }
750
751 // Check Visibility rules.
752 CorInfoIsAccessAllowedResult interceptor_ICJI::canAccessClass(
753     CORINFO_RESOLVED_TOKEN* pResolvedToken,
754     CORINFO_METHOD_HANDLE   callerHandle,
755     CORINFO_HELPER_DESC*    pAccessHelper /* If canAccessMethod returns something other
756                                                 than ALLOWED, then this is filled in. */
757     )
758 {
759     mcs->AddCall("canAccessClass");
760     return original_ICorJitInfo->canAccessClass(pResolvedToken, callerHandle, pAccessHelper);
761 }
762
763 /**********************************************************************************/
764 //
765 // ICorFieldInfo
766 //
767 /**********************************************************************************/
768
769 // this function is for debugging only.  It returns the field name
770 // and if 'moduleName' is non-null, it sets it to something that will
771 // says which method (a class name, or a module name)
772 const char* interceptor_ICJI::getFieldName(CORINFO_FIELD_HANDLE ftn,       /* IN */
773                                            const char**         moduleName /* OUT */
774                                            )
775 {
776     mcs->AddCall("getFieldName");
777     return original_ICorJitInfo->getFieldName(ftn, moduleName);
778 }
779
780 // return class it belongs to
781 CORINFO_CLASS_HANDLE interceptor_ICJI::getFieldClass(CORINFO_FIELD_HANDLE field)
782 {
783     mcs->AddCall("getFieldClass");
784     return original_ICorJitInfo->getFieldClass(field);
785 }
786
787 // Return the field's type, if it is CORINFO_TYPE_VALUECLASS 'structType' is set
788 // the field's value class (if 'structType' == 0, then don't bother
789 // the structure info).
790 //
791 // 'memberParent' is typically only set when verifying.  It should be the
792 // result of calling getMemberParent.
793 CorInfoType interceptor_ICJI::getFieldType(CORINFO_FIELD_HANDLE  field,
794                                            CORINFO_CLASS_HANDLE* structType,
795                                            CORINFO_CLASS_HANDLE  memberParent /* IN */
796                                            )
797 {
798     mcs->AddCall("getFieldType");
799     return original_ICorJitInfo->getFieldType(field, structType, memberParent);
800 }
801
802 // return the data member's instance offset
803 unsigned interceptor_ICJI::getFieldOffset(CORINFO_FIELD_HANDLE field)
804 {
805     mcs->AddCall("getFieldOffset");
806     return original_ICorJitInfo->getFieldOffset(field);
807 }
808
809 // TODO: jit64 should be switched to the same plan as the i386 jits - use
810 // getClassGClayout to figure out the need for writebarrier helper, and inline the copying.
811 // The interpretted value class copy is slow. Once this happens, USE_WRITE_BARRIER_HELPERS
812 bool interceptor_ICJI::isWriteBarrierHelperRequired(CORINFO_FIELD_HANDLE field)
813 {
814     mcs->AddCall("isWriteBarrierHelperRequired");
815     return original_ICorJitInfo->isWriteBarrierHelperRequired(field);
816 }
817
818 void interceptor_ICJI::getFieldInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken,
819                                     CORINFO_METHOD_HANDLE   callerHandle,
820                                     CORINFO_ACCESS_FLAGS    flags,
821                                     CORINFO_FIELD_INFO*     pResult)
822 {
823     mcs->AddCall("getFieldInfo");
824     original_ICorJitInfo->getFieldInfo(pResolvedToken, callerHandle, flags, pResult);
825 }
826
827 // Returns true iff "fldHnd" represents a static field.
828 bool interceptor_ICJI::isFieldStatic(CORINFO_FIELD_HANDLE fldHnd)
829 {
830     mcs->AddCall("isFieldStatic");
831     return original_ICorJitInfo->isFieldStatic(fldHnd);
832 }
833
834 /*********************************************************************************/
835 //
836 // ICorDebugInfo
837 //
838 /*********************************************************************************/
839
840 // Query the EE to find out where interesting break points
841 // in the code are.  The native compiler will ensure that these places
842 // have a corresponding break point in native code.
843 //
844 // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will
845 // be used only as a hint and the native compiler should not change its
846 // code generation.
847 void interceptor_ICJI::getBoundaries(CORINFO_METHOD_HANDLE ftn,        // [IN] method of interest
848                                      unsigned int*         cILOffsets, // [OUT] size of pILOffsets
849                                      DWORD**               pILOffsets, // [OUT] IL offsets of interest
850                                                                        //       jit MUST free with freeArray!
851                                      ICorDebugInfo::BoundaryTypes* implictBoundaries // [OUT] tell jit, all boundries of
852                                                                                      // this type
853                                      )
854 {
855     mcs->AddCall("getBoundaries");
856     original_ICorJitInfo->getBoundaries(ftn, cILOffsets, pILOffsets, implictBoundaries);
857 }
858
859 // Report back the mapping from IL to native code,
860 // this map should include all boundaries that 'getBoundaries'
861 // reported as interesting to the debugger.
862
863 // Note that debugger (and profiler) is assuming that all of the
864 // offsets form a contiguous block of memory, and that the
865 // OffsetMapping is sorted in order of increasing native offset.
866 void interceptor_ICJI::setBoundaries(CORINFO_METHOD_HANDLE         ftn,  // [IN] method of interest
867                                      ULONG32                       cMap, // [IN] size of pMap
868                                      ICorDebugInfo::OffsetMapping* pMap  // [IN] map including all points of interest.
869                                                                          //      jit allocated with allocateArray, EE
870                                                                          //      frees
871                                      )
872 {
873     mcs->AddCall("setBoundaries");
874     original_ICorJitInfo->setBoundaries(ftn, cMap, pMap);
875 }
876
877 // Query the EE to find out the scope of local varables.
878 // normally the JIT would trash variables after last use, but
879 // under debugging, the JIT needs to keep them live over their
880 // entire scope so that they can be inspected.
881 //
882 // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will
883 // be used only as a hint and the native compiler should not change its
884 // code generation.
885 void interceptor_ICJI::getVars(CORINFO_METHOD_HANDLE      ftn,   // [IN]  method of interest
886                                ULONG32*                   cVars, // [OUT] size of 'vars'
887                                ICorDebugInfo::ILVarInfo** vars,  // [OUT] scopes of variables of interest
888                                                                  //       jit MUST free with freeArray!
889                                bool* extendOthers                // [OUT] it TRUE, then assume the scope
890                                                                  //       of unmentioned vars is entire method
891                                )
892 {
893     mcs->AddCall("getVars");
894     original_ICorJitInfo->getVars(ftn, cVars, vars, extendOthers);
895 }
896
897 // Report back to the EE the location of every variable.
898 // note that the JIT might split lifetimes into different
899 // locations etc.
900
901 void interceptor_ICJI::setVars(CORINFO_METHOD_HANDLE         ftn,   // [IN] method of interest
902                                ULONG32                       cVars, // [IN] size of 'vars'
903                                ICorDebugInfo::NativeVarInfo* vars   // [IN] map telling where local vars are stored at
904                                                                     // what points
905                                                                     //      jit allocated with allocateArray, EE frees
906                                )
907 {
908     mcs->AddCall("setVars");
909     original_ICorJitInfo->setVars(ftn, cVars, vars);
910 }
911
912 /*-------------------------- Misc ---------------------------------------*/
913
914 // Used to allocate memory that needs to handed to the EE.
915 // For eg, use this to allocated memory for reporting debug info,
916 // which will be handed to the EE by setVars() and setBoundaries()
917 void* interceptor_ICJI::allocateArray(ULONG cBytes)
918 {
919     mcs->AddCall("allocateArray");
920     return original_ICorJitInfo->allocateArray(cBytes);
921 }
922
923 // JitCompiler will free arrays passed by the EE using this
924 // For eg, The EE returns memory in getVars() and getBoundaries()
925 // to the JitCompiler, which the JitCompiler should release using
926 // freeArray()
927 void interceptor_ICJI::freeArray(void* array)
928 {
929     mcs->AddCall("freeArray");
930     original_ICorJitInfo->freeArray(array);
931 }
932
933 /*********************************************************************************/
934 //
935 // ICorArgInfo
936 //
937 /*********************************************************************************/
938
939 // advance the pointer to the argument list.
940 // a ptr of 0, is special and always means the first argument
941 CORINFO_ARG_LIST_HANDLE interceptor_ICJI::getArgNext(CORINFO_ARG_LIST_HANDLE args /* IN */
942                                                      )
943 {
944     mcs->AddCall("getArgNext");
945     return original_ICorJitInfo->getArgNext(args);
946 }
947
948 // Get the type of a particular argument
949 // CORINFO_TYPE_UNDEF is returned when there are no more arguments
950 // If the type returned is a primitive type (or an enum) *vcTypeRet set to nullptr
951 // otherwise it is set to the TypeHandle associted with the type
952 // Enumerations will always look their underlying type (probably should fix this)
953 // Otherwise vcTypeRet is the type as would be seen by the IL,
954 // The return value is the type that is used for calling convention purposes
955 // (Thus if the EE wants a value class to be passed like an int, then it will
956 // return CORINFO_TYPE_INT
957 CorInfoTypeWithMod interceptor_ICJI::getArgType(CORINFO_SIG_INFO*       sig,      /* IN */
958                                                 CORINFO_ARG_LIST_HANDLE args,     /* IN */
959                                                 CORINFO_CLASS_HANDLE*   vcTypeRet /* OUT */
960                                                 )
961 {
962     mcs->AddCall("getArgType");
963     return original_ICorJitInfo->getArgType(sig, args, vcTypeRet);
964 }
965
966 // If the Arg is a CORINFO_TYPE_CLASS fetch the class handle associated with it
967 CORINFO_CLASS_HANDLE interceptor_ICJI::getArgClass(CORINFO_SIG_INFO*       sig, /* IN */
968                                                    CORINFO_ARG_LIST_HANDLE args /* IN */
969                                                    )
970 {
971     mcs->AddCall("getArgClass");
972     return original_ICorJitInfo->getArgClass(sig, args);
973 }
974
975 // Returns type of HFA for valuetype
976 CorInfoType interceptor_ICJI::getHFAType(CORINFO_CLASS_HANDLE hClass)
977 {
978     mcs->AddCall("getHFAType");
979     return original_ICorJitInfo->getHFAType(hClass);
980 }
981
982 /*****************************************************************************
983 * ICorErrorInfo contains methods to deal with SEH exceptions being thrown
984 * from the corinfo interface.  These methods may be called when an exception
985 * with code EXCEPTION_COMPLUS is caught.
986 *****************************************************************************/
987
988 // Returns the HRESULT of the current exception
989 HRESULT interceptor_ICJI::GetErrorHRESULT(struct _EXCEPTION_POINTERS* pExceptionPointers)
990 {
991     mcs->AddCall("GetErrorHRESULT");
992     return original_ICorJitInfo->GetErrorHRESULT(pExceptionPointers);
993 }
994
995 // Fetches the message of the current exception
996 // Returns the size of the message (including terminating null). This can be
997 // greater than bufferLength if the buffer is insufficient.
998 ULONG interceptor_ICJI::GetErrorMessage(__inout_ecount(bufferLength) LPWSTR buffer, ULONG bufferLength)
999 {
1000     mcs->AddCall("GetErrorMessage");
1001     return original_ICorJitInfo->GetErrorMessage(buffer, bufferLength);
1002 }
1003
1004 // returns EXCEPTION_EXECUTE_HANDLER if it is OK for the compile to handle the
1005 //                        exception, abort some work (like the inlining) and continue compilation
1006 // returns EXCEPTION_CONTINUE_SEARCH if exception must always be handled by the EE
1007 //                    things like ThreadStoppedException ...
1008 // returns EXCEPTION_CONTINUE_EXECUTION if exception is fixed up by the EE
1009
1010 int interceptor_ICJI::FilterException(struct _EXCEPTION_POINTERS* pExceptionPointers)
1011 {
1012     mcs->AddCall("FilterException");
1013     return original_ICorJitInfo->FilterException(pExceptionPointers);
1014 }
1015
1016 // Cleans up internal EE tracking when an exception is caught.
1017 void interceptor_ICJI::HandleException(struct _EXCEPTION_POINTERS* pExceptionPointers)
1018 {
1019     mcs->AddCall("HandleException");
1020     original_ICorJitInfo->HandleException(pExceptionPointers);
1021 }
1022
1023 void interceptor_ICJI::ThrowExceptionForJitResult(HRESULT result)
1024 {
1025     mcs->AddCall("ThrowExceptionForJitResult");
1026     original_ICorJitInfo->ThrowExceptionForJitResult(result);
1027 }
1028
1029 // Throws an exception defined by the given throw helper.
1030 void interceptor_ICJI::ThrowExceptionForHelper(const CORINFO_HELPER_DESC* throwHelper)
1031 {
1032     mcs->AddCall("ThrowExceptionForHelper");
1033     original_ICorJitInfo->ThrowExceptionForHelper(throwHelper);
1034 }
1035
1036 /*****************************************************************************
1037  * ICorStaticInfo contains EE interface methods which return values that are
1038  * constant from invocation to invocation.  Thus they may be embedded in
1039  * persisted information like statically generated code. (This is of course
1040  * assuming that all code versions are identical each time.)
1041  *****************************************************************************/
1042
1043 // Return details about EE internal data structures
1044 void interceptor_ICJI::getEEInfo(CORINFO_EE_INFO* pEEInfoOut)
1045 {
1046     mcs->AddCall("getEEInfo");
1047     original_ICorJitInfo->getEEInfo(pEEInfoOut);
1048 }
1049
1050 // Returns name of the JIT timer log
1051 LPCWSTR interceptor_ICJI::getJitTimeLogFilename()
1052 {
1053     mcs->AddCall("getJitTimeLogFilename");
1054     return original_ICorJitInfo->getJitTimeLogFilename();
1055 }
1056
1057 /*********************************************************************************/
1058 //
1059 // Diagnostic methods
1060 //
1061 /*********************************************************************************/
1062
1063 // this function is for debugging only. Returns method token.
1064 // Returns mdMethodDefNil for dynamic methods.
1065 mdMethodDef interceptor_ICJI::getMethodDefFromMethod(CORINFO_METHOD_HANDLE hMethod)
1066 {
1067     mcs->AddCall("getMethodDefFromMethod");
1068     return original_ICorJitInfo->getMethodDefFromMethod(hMethod);
1069 }
1070
1071 // this function is for debugging only.  It returns the method name
1072 // and if 'moduleName' is non-null, it sets it to something that will
1073 // says which method (a class name, or a module name)
1074 const char* interceptor_ICJI::getMethodName(CORINFO_METHOD_HANDLE ftn,       /* IN */
1075                                             const char**          moduleName /* OUT */
1076                                             )
1077 {
1078     mcs->AddCall("getMethodName");
1079     return original_ICorJitInfo->getMethodName(ftn, moduleName);
1080 }
1081
1082 // this function is for debugging only.  It returns a value that
1083 // is will always be the same for a given method.  It is used
1084 // to implement the 'jitRange' functionality
1085 unsigned interceptor_ICJI::getMethodHash(CORINFO_METHOD_HANDLE ftn /* IN */
1086                                          )
1087 {
1088     mcs->AddCall("getMethodHash");
1089     return original_ICorJitInfo->getMethodHash(ftn);
1090 }
1091
1092 // this function is for debugging only.
1093 size_t interceptor_ICJI::findNameOfToken(CORINFO_MODULE_HANDLE              module,        /* IN  */
1094                                          mdToken                            metaTOK,       /* IN  */
1095                                          __out_ecount(FQNameCapacity) char* szFQName,      /* OUT */
1096                                          size_t                             FQNameCapacity /* IN */
1097                                          )
1098 {
1099     mcs->AddCall("findNameOfToken");
1100     return original_ICorJitInfo->findNameOfToken(module, metaTOK, szFQName, FQNameCapacity);
1101 }
1102
1103 bool interceptor_ICJI::getSystemVAmd64PassStructInRegisterDescriptor(
1104     /* IN */ CORINFO_CLASS_HANDLE                                  structHnd,
1105     /* OUT */ SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr)
1106 {
1107     mcs->AddCall("getSystemVAmd64PassStructInRegisterDescriptor");
1108     return original_ICorJitInfo->getSystemVAmd64PassStructInRegisterDescriptor(structHnd, structPassInRegDescPtr);
1109 }
1110
1111 // Stuff on ICorDynamicInfo
1112 DWORD interceptor_ICJI::getThreadTLSIndex(void** ppIndirection)
1113 {
1114     mcs->AddCall("getThreadTLSIndex");
1115     return original_ICorJitInfo->getThreadTLSIndex(ppIndirection);
1116 }
1117
1118 const void* interceptor_ICJI::getInlinedCallFrameVptr(void** ppIndirection)
1119 {
1120     mcs->AddCall("getInlinedCallFrameVptr");
1121     return original_ICorJitInfo->getInlinedCallFrameVptr(ppIndirection);
1122 }
1123
1124 LONG* interceptor_ICJI::getAddrOfCaptureThreadGlobal(void** ppIndirection)
1125 {
1126     mcs->AddCall("getAddrOfCaptureThreadGlobal");
1127     return original_ICorJitInfo->getAddrOfCaptureThreadGlobal(ppIndirection);
1128 }
1129
1130 // return the native entry point to an EE helper (see CorInfoHelpFunc)
1131 void* interceptor_ICJI::getHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection)
1132 {
1133     mcs->AddCall("getHelperFtn");
1134     return original_ICorJitInfo->getHelperFtn(ftnNum, ppIndirection);
1135 }
1136
1137 // return a callable address of the function (native code). This function
1138 // may return a different value (depending on whether the method has
1139 // been JITed or not.
1140 void interceptor_ICJI::getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftn,     /* IN  */
1141                                              CORINFO_CONST_LOOKUP* pResult, /* OUT */
1142                                              CORINFO_ACCESS_FLAGS  accessFlags)
1143 {
1144     mcs->AddCall("getFunctionEntryPoint");
1145     original_ICorJitInfo->getFunctionEntryPoint(ftn, pResult, accessFlags);
1146 }
1147
1148 // return a directly callable address. This can be used similarly to the
1149 // value returned by getFunctionEntryPoint() except that it is
1150 // guaranteed to be multi callable entrypoint.
1151 void interceptor_ICJI::getFunctionFixedEntryPoint(CORINFO_METHOD_HANDLE ftn, CORINFO_CONST_LOOKUP* pResult)
1152 {
1153     mcs->AddCall("getFunctionFixedEntryPoint");
1154     original_ICorJitInfo->getFunctionFixedEntryPoint(ftn, pResult);
1155 }
1156
1157 // get the synchronization handle that is passed to monXstatic function
1158 void* interceptor_ICJI::getMethodSync(CORINFO_METHOD_HANDLE ftn, void** ppIndirection)
1159 {
1160     mcs->AddCall("getMethodSync");
1161     return original_ICorJitInfo->getMethodSync(ftn, ppIndirection);
1162 }
1163
1164 // These entry points must be called if a handle is being embedded in
1165 // the code to be passed to a JIT helper function. (as opposed to just
1166 // being passed back into the ICorInfo interface.)
1167
1168 // get slow lazy string literal helper to use (CORINFO_HELP_STRCNS*).
1169 // Returns CORINFO_HELP_UNDEF if lazy string literal helper cannot be used.
1170 CorInfoHelpFunc interceptor_ICJI::getLazyStringLiteralHelper(CORINFO_MODULE_HANDLE handle)
1171 {
1172     mcs->AddCall("getLazyStringLiteralHelper");
1173     return original_ICorJitInfo->getLazyStringLiteralHelper(handle);
1174 }
1175
1176 CORINFO_MODULE_HANDLE interceptor_ICJI::embedModuleHandle(CORINFO_MODULE_HANDLE handle, void** ppIndirection)
1177 {
1178     mcs->AddCall("embedModuleHandle");
1179     return original_ICorJitInfo->embedModuleHandle(handle, ppIndirection);
1180 }
1181
1182 CORINFO_CLASS_HANDLE interceptor_ICJI::embedClassHandle(CORINFO_CLASS_HANDLE handle, void** ppIndirection)
1183 {
1184     mcs->AddCall("embedClassHandle");
1185     return original_ICorJitInfo->embedClassHandle(handle, ppIndirection);
1186 }
1187
1188 CORINFO_METHOD_HANDLE interceptor_ICJI::embedMethodHandle(CORINFO_METHOD_HANDLE handle, void** ppIndirection)
1189 {
1190     mcs->AddCall("embedMethodHandle");
1191     return original_ICorJitInfo->embedMethodHandle(handle, ppIndirection);
1192 }
1193
1194 CORINFO_FIELD_HANDLE interceptor_ICJI::embedFieldHandle(CORINFO_FIELD_HANDLE handle, void** ppIndirection)
1195 {
1196     mcs->AddCall("embedFieldHandle");
1197     return original_ICorJitInfo->embedFieldHandle(handle, ppIndirection);
1198 }
1199
1200 // Given a module scope (module), a method handle (context) and
1201 // a metadata token (metaTOK), fetch the handle
1202 // (type, field or method) associated with the token.
1203 // If this is not possible at compile-time (because the current method's
1204 // code is shared and the token contains generic parameters)
1205 // then indicate how the handle should be looked up at run-time.
1206 //
1207 void interceptor_ICJI::embedGenericHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken,
1208                                           BOOL fEmbedParent, // TRUE - embeds parent type handle of the field/method
1209                                                              // handle
1210                                           CORINFO_GENERICHANDLE_RESULT* pResult)
1211 {
1212     mcs->AddCall("embedGenericHandle");
1213     original_ICorJitInfo->embedGenericHandle(pResolvedToken, fEmbedParent, pResult);
1214 }
1215
1216 // Return information used to locate the exact enclosing type of the current method.
1217 // Used only to invoke .cctor method from code shared across generic instantiations
1218 //   !needsRuntimeLookup       statically known (enclosing type of method itself)
1219 //   needsRuntimeLookup:
1220 //      CORINFO_LOOKUP_THISOBJ     use vtable pointer of 'this' param
1221 //      CORINFO_LOOKUP_CLASSPARAM  use vtable hidden param
1222 //      CORINFO_LOOKUP_METHODPARAM use enclosing type of method-desc hidden param
1223 CORINFO_LOOKUP_KIND interceptor_ICJI::getLocationOfThisType(CORINFO_METHOD_HANDLE context)
1224 {
1225     mcs->AddCall("getLocationOfThisType");
1226     return original_ICorJitInfo->getLocationOfThisType(context);
1227 }
1228
1229 // return the unmanaged target *if method has already been prelinked.*
1230 void* interceptor_ICJI::getPInvokeUnmanagedTarget(CORINFO_METHOD_HANDLE method, void** ppIndirection)
1231 {
1232     mcs->AddCall("getPInvokeUnmanagedTarget");
1233     return original_ICorJitInfo->getPInvokeUnmanagedTarget(method, ppIndirection);
1234 }
1235
1236 // return address of fixup area for late-bound PInvoke calls.
1237 void* interceptor_ICJI::getAddressOfPInvokeFixup(CORINFO_METHOD_HANDLE method, void** ppIndirection)
1238 {
1239     mcs->AddCall("getAddressOfPInvokeFixup");
1240     return original_ICorJitInfo->getAddressOfPInvokeFixup(method, ppIndirection);
1241 }
1242
1243 // return address of fixup area for late-bound PInvoke calls.
1244 void interceptor_ICJI::getAddressOfPInvokeTarget(CORINFO_METHOD_HANDLE method, CORINFO_CONST_LOOKUP* pLookup)
1245 {
1246     mcs->AddCall("getAddressOfPInvokeTarget");
1247     original_ICorJitInfo->getAddressOfPInvokeTarget(method, pLookup);
1248 }
1249
1250 // Generate a cookie based on the signature that would needs to be passed
1251 // to CORINFO_HELP_PINVOKE_CALLI
1252 LPVOID interceptor_ICJI::GetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig, void** ppIndirection)
1253 {
1254     mcs->AddCall("GetCookieForPInvokeCalliSig");
1255     return original_ICorJitInfo->GetCookieForPInvokeCalliSig(szMetaSig, ppIndirection);
1256 }
1257
1258 // returns true if a VM cookie can be generated for it (might be false due to cross-module
1259 // inlining, in which case the inlining should be aborted)
1260 bool interceptor_ICJI::canGetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig)
1261 {
1262     mcs->AddCall("canGetCookieForPInvokeCalliSig");
1263     return original_ICorJitInfo->canGetCookieForPInvokeCalliSig(szMetaSig);
1264 }
1265
1266 // Gets a handle that is checked to see if the current method is
1267 // included in "JustMyCode"
1268 CORINFO_JUST_MY_CODE_HANDLE interceptor_ICJI::getJustMyCodeHandle(CORINFO_METHOD_HANDLE         method,
1269                                                                   CORINFO_JUST_MY_CODE_HANDLE** ppIndirection)
1270 {
1271     mcs->AddCall("getJustMyCodeHandle");
1272     return original_ICorJitInfo->getJustMyCodeHandle(method, ppIndirection);
1273 }
1274
1275 // Gets a method handle that can be used to correlate profiling data.
1276 // This is the IP of a native method, or the address of the descriptor struct
1277 // for IL.  Always guaranteed to be unique per process, and not to move. */
1278 void interceptor_ICJI::GetProfilingHandle(BOOL* pbHookFunction, void** pProfilerHandle, BOOL* pbIndirectedHandles)
1279 {
1280     mcs->AddCall("GetProfilingHandle");
1281     original_ICorJitInfo->GetProfilingHandle(pbHookFunction, pProfilerHandle, pbIndirectedHandles);
1282 }
1283
1284 // Returns instructions on how to make the call. See code:CORINFO_CALL_INFO for possible return values.
1285 void interceptor_ICJI::getCallInfo(
1286     // Token info
1287     CORINFO_RESOLVED_TOKEN* pResolvedToken,
1288
1289     // Generics info
1290     CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken,
1291
1292     // Security info
1293     CORINFO_METHOD_HANDLE callerHandle,
1294
1295     // Jit info
1296     CORINFO_CALLINFO_FLAGS flags,
1297
1298     // out params
1299     CORINFO_CALL_INFO* pResult)
1300 {
1301     mcs->AddCall("getCallInfo");
1302     original_ICorJitInfo->getCallInfo(pResolvedToken, pConstrainedResolvedToken, callerHandle, flags, pResult);
1303 }
1304
1305 BOOL interceptor_ICJI::canAccessFamily(CORINFO_METHOD_HANDLE hCaller, CORINFO_CLASS_HANDLE hInstanceType)
1306
1307 {
1308     mcs->AddCall("canAccessFamily");
1309     return original_ICorJitInfo->canAccessFamily(hCaller, hInstanceType);
1310 }
1311 // Returns TRUE if the Class Domain ID is the RID of the class (currently true for every class
1312 // except reflection emitted classes and generics)
1313 BOOL interceptor_ICJI::isRIDClassDomainID(CORINFO_CLASS_HANDLE cls)
1314 {
1315     mcs->AddCall("isRIDClassDomainID");
1316     return original_ICorJitInfo->isRIDClassDomainID(cls);
1317 }
1318
1319 // returns the class's domain ID for accessing shared statics
1320 unsigned interceptor_ICJI::getClassDomainID(CORINFO_CLASS_HANDLE cls, void** ppIndirection)
1321 {
1322     mcs->AddCall("getClassDomainID");
1323     return original_ICorJitInfo->getClassDomainID(cls, ppIndirection);
1324 }
1325
1326 // return the data's address (for static fields only)
1327 void* interceptor_ICJI::getFieldAddress(CORINFO_FIELD_HANDLE field, void** ppIndirection)
1328 {
1329     mcs->AddCall("getFieldAddress");
1330     return original_ICorJitInfo->getFieldAddress(field, ppIndirection);
1331 }
1332
1333 // registers a vararg sig & returns a VM cookie for it (which can contain other stuff)
1334 CORINFO_VARARGS_HANDLE interceptor_ICJI::getVarArgsHandle(CORINFO_SIG_INFO* pSig, void** ppIndirection)
1335 {
1336     mcs->AddCall("getVarArgsHandle");
1337     return original_ICorJitInfo->getVarArgsHandle(pSig, ppIndirection);
1338 }
1339
1340 // returns true if a VM cookie can be generated for it (might be false due to cross-module
1341 // inlining, in which case the inlining should be aborted)
1342 bool interceptor_ICJI::canGetVarArgsHandle(CORINFO_SIG_INFO* pSig)
1343 {
1344     mcs->AddCall("canGetVarArgsHandle");
1345     return original_ICorJitInfo->canGetVarArgsHandle(pSig);
1346 }
1347
1348 // Allocate a string literal on the heap and return a handle to it
1349 InfoAccessType interceptor_ICJI::constructStringLiteral(CORINFO_MODULE_HANDLE module, mdToken metaTok, void** ppValue)
1350 {
1351     mcs->AddCall("constructStringLiteral");
1352     return original_ICorJitInfo->constructStringLiteral(module, metaTok, ppValue);
1353 }
1354
1355 InfoAccessType interceptor_ICJI::emptyStringLiteral(void** ppValue)
1356 {
1357     mcs->AddCall("emptyStringLiteral");
1358     return original_ICorJitInfo->emptyStringLiteral(ppValue);
1359 }
1360
1361 // (static fields only) given that 'field' refers to thread local store,
1362 // return the ID (TLS index), which is used to find the begining of the
1363 // TLS data area for the particular DLL 'field' is associated with.
1364 DWORD interceptor_ICJI::getFieldThreadLocalStoreID(CORINFO_FIELD_HANDLE field, void** ppIndirection)
1365 {
1366     mcs->AddCall("getFieldThreadLocalStoreID");
1367     return original_ICorJitInfo->getFieldThreadLocalStoreID(field, ppIndirection);
1368 }
1369
1370 // Sets another object to intercept calls to "self" and current method being compiled
1371 void interceptor_ICJI::setOverride(ICorDynamicInfo* pOverride, CORINFO_METHOD_HANDLE currentMethod)
1372 {
1373     mcs->AddCall("setOverride");
1374     original_ICorJitInfo->setOverride(pOverride, currentMethod);
1375 }
1376
1377 // Adds an active dependency from the context method's module to the given module
1378 // This is internal callback for the EE. JIT should not call it directly.
1379 void interceptor_ICJI::addActiveDependency(CORINFO_MODULE_HANDLE moduleFrom, CORINFO_MODULE_HANDLE moduleTo)
1380 {
1381     mcs->AddCall("addActiveDependency");
1382     original_ICorJitInfo->addActiveDependency(moduleFrom, moduleTo);
1383 }
1384
1385 CORINFO_METHOD_HANDLE interceptor_ICJI::GetDelegateCtor(CORINFO_METHOD_HANDLE methHnd,
1386                                                         CORINFO_CLASS_HANDLE  clsHnd,
1387                                                         CORINFO_METHOD_HANDLE targetMethodHnd,
1388                                                         DelegateCtorArgs*     pCtorData)
1389 {
1390     mcs->AddCall("GetDelegateCtor");
1391     return original_ICorJitInfo->GetDelegateCtor(methHnd, clsHnd, targetMethodHnd, pCtorData);
1392 }
1393
1394 void interceptor_ICJI::MethodCompileComplete(CORINFO_METHOD_HANDLE methHnd)
1395 {
1396     mcs->AddCall("MethodCompileComplete");
1397     original_ICorJitInfo->MethodCompileComplete(methHnd);
1398 }
1399
1400 // return a thunk that will copy the arguments for the given signature.
1401 void* interceptor_ICJI::getTailCallCopyArgsThunk(CORINFO_SIG_INFO* pSig, CorInfoHelperTailCallSpecialHandling flags)
1402 {
1403     mcs->AddCall("getTailCallCopyArgsThunk");
1404     return original_ICorJitInfo->getTailCallCopyArgsThunk(pSig, flags);
1405 }
1406
1407 // Stuff directly on ICorJitInfo
1408
1409 // Returns extended flags for a particular compilation instance.
1410 DWORD interceptor_ICJI::getJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes)
1411 {
1412     mcs->AddCall("getJitFlags");
1413     return original_ICorJitInfo->getJitFlags(jitFlags, sizeInBytes);
1414 }
1415
1416 // Runs the given function with the given parameter under an error trap
1417 // and returns true if the function completes successfully. We don't
1418 // record the results of the call: when this call gets played back,
1419 // its result will depend on whether or not `function` calls something
1420 // that throws at playback time rather than at capture time.
1421 bool interceptor_ICJI::runWithErrorTrap(void (*function)(void*), void* param)
1422 {
1423     mcs->AddCall("runWithErrorTrap");
1424     return original_ICorJitInfo->runWithErrorTrap(function, param);
1425 }
1426
1427 // return memory manager that the JIT can use to allocate a regular memory
1428 IEEMemoryManager* interceptor_ICJI::getMemoryManager()
1429 {
1430     mcs->AddCall("getMemoryManager");
1431     if (current_IEEMM->original_IEEMM == nullptr)
1432         current_IEEMM->original_IEEMM = original_ICorJitInfo->getMemoryManager();
1433
1434     return current_IEEMM;
1435 }
1436
1437 // get a block of memory for the code, readonly data, and read-write data
1438 void interceptor_ICJI::allocMem(ULONG              hotCodeSize,   /* IN */
1439                                 ULONG              coldCodeSize,  /* IN */
1440                                 ULONG              roDataSize,    /* IN */
1441                                 ULONG              xcptnsCount,   /* IN */
1442                                 CorJitAllocMemFlag flag,          /* IN */
1443                                 void**             hotCodeBlock,  /* OUT */
1444                                 void**             coldCodeBlock, /* OUT */
1445                                 void**             roDataBlock    /* OUT */
1446                                 )
1447 {
1448     mcs->AddCall("allocMem");
1449     return original_ICorJitInfo->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock,
1450                                           coldCodeBlock, roDataBlock);
1451 }
1452
1453 // Reserve memory for the method/funclet's unwind information.
1454 // Note that this must be called before allocMem. It should be
1455 // called once for the main method, once for every funclet, and
1456 // once for every block of cold code for which allocUnwindInfo
1457 // will be called.
1458 //
1459 // This is necessary because jitted code must allocate all the
1460 // memory needed for the unwindInfo at the allocMem call.
1461 // For prejitted code we split up the unwinding information into
1462 // separate sections .rdata and .pdata.
1463 //
1464 void interceptor_ICJI::reserveUnwindInfo(BOOL  isFunclet,  /* IN */
1465                                          BOOL  isColdCode, /* IN */
1466                                          ULONG unwindSize  /* IN */
1467                                          )
1468 {
1469     mcs->AddCall("reserveUnwindInfo");
1470     original_ICorJitInfo->reserveUnwindInfo(isFunclet, isColdCode, unwindSize);
1471 }
1472
1473 // Allocate and initialize the .rdata and .pdata for this method or
1474 // funclet, and get the block of memory needed for the machine-specific
1475 // unwind information (the info for crawling the stack frame).
1476 // Note that allocMem must be called first.
1477 //
1478 // Parameters:
1479 //
1480 //    pHotCode        main method code buffer, always filled in
1481 //    pColdCode       cold code buffer, only filled in if this is cold code,
1482 //                      null otherwise
1483 //    startOffset     start of code block, relative to appropriate code buffer
1484 //                      (e.g. pColdCode if cold, pHotCode if hot).
1485 //    endOffset       end of code block, relative to appropriate code buffer
1486 //    unwindSize      size of unwind info pointed to by pUnwindBlock
1487 //    pUnwindBlock    pointer to unwind info
1488 //    funcKind        type of funclet (main method code, handler, filter)
1489 //
1490 void interceptor_ICJI::allocUnwindInfo(BYTE*          pHotCode,     /* IN */
1491                                        BYTE*          pColdCode,    /* IN */
1492                                        ULONG          startOffset,  /* IN */
1493                                        ULONG          endOffset,    /* IN */
1494                                        ULONG          unwindSize,   /* IN */
1495                                        BYTE*          pUnwindBlock, /* IN */
1496                                        CorJitFuncKind funcKind      /* IN */
1497                                        )
1498 {
1499     mcs->AddCall("allocUnwindInfo");
1500     original_ICorJitInfo->allocUnwindInfo(pHotCode, pColdCode, startOffset, endOffset, unwindSize, pUnwindBlock,
1501                                           funcKind);
1502 }
1503
1504 // Get a block of memory needed for the code manager information,
1505 // (the info for enumerating the GC pointers while crawling the
1506 // stack frame).
1507 // Note that allocMem must be called first
1508 void* interceptor_ICJI::allocGCInfo(size_t size /* IN */
1509                                     )
1510 {
1511     mcs->AddCall("allocGCInfo");
1512     return original_ICorJitInfo->allocGCInfo(size);
1513 }
1514
1515 // only used on x64
1516 void interceptor_ICJI::yieldExecution()
1517 {
1518     mcs->AddCall("yieldExecution");
1519     original_ICorJitInfo->yieldExecution();
1520 }
1521
1522 // Indicate how many exception handler blocks are to be returned.
1523 // This is guaranteed to be called before any 'setEHinfo' call.
1524 // Note that allocMem must be called before this method can be called.
1525 void interceptor_ICJI::setEHcount(unsigned cEH /* IN */
1526                                   )
1527 {
1528     mcs->AddCall("setEHcount");
1529     original_ICorJitInfo->setEHcount(cEH);
1530 }
1531
1532 // Set the values for one particular exception handler block.
1533 //
1534 // Handler regions should be lexically contiguous.
1535 // This is because FinallyIsUnwinding() uses lexicality to
1536 // determine if a "finally" clause is executing.
1537 void interceptor_ICJI::setEHinfo(unsigned                 EHnumber, /* IN  */
1538                                  const CORINFO_EH_CLAUSE* clause    /* IN */
1539                                  )
1540 {
1541     mcs->AddCall("setEHinfo");
1542     original_ICorJitInfo->setEHinfo(EHnumber, clause);
1543 }
1544
1545 // Level 1 -> fatalError, Level 2 -> Error, Level 3 -> Warning
1546 // Level 4 means happens 10 times in a run, level 5 means 100, level 6 means 1000 ...
1547 // returns non-zero if the logging succeeded
1548 BOOL interceptor_ICJI::logMsg(unsigned level, const char* fmt, va_list args)
1549 {
1550     mcs->AddCall("logMsg");
1551     return original_ICorJitInfo->logMsg(level, fmt, args);
1552 }
1553
1554 // do an assert.  will return true if the code should retry (DebugBreak)
1555 // returns false, if the assert should be igored.
1556 int interceptor_ICJI::doAssert(const char* szFile, int iLine, const char* szExpr)
1557 {
1558     mcs->AddCall("doAssert");
1559     return original_ICorJitInfo->doAssert(szFile, iLine, szExpr);
1560 }
1561
1562 void interceptor_ICJI::reportFatalError(CorJitResult result)
1563 {
1564     mcs->AddCall("reportFatalError");
1565     original_ICorJitInfo->reportFatalError(result);
1566 }
1567
1568 /*
1569 struct ProfileBuffer  // Also defined here: code:CORBBTPROF_BLOCK_DATA
1570 {
1571     ULONG ILOffset;
1572     ULONG ExecutionCount;
1573 };
1574 */
1575
1576 // allocate a basic block profile buffer where execution counts will be stored
1577 // for jitted basic blocks.
1578 HRESULT interceptor_ICJI::allocBBProfileBuffer(ULONG           count, // The number of basic blocks that we have
1579                                                ProfileBuffer** profileBuffer)
1580 {
1581     mcs->AddCall("allocBBProfileBuffer");
1582     return original_ICorJitInfo->allocBBProfileBuffer(count, profileBuffer);
1583 }
1584
1585 // get profile information to be used for optimizing the current method.  The format
1586 // of the buffer is the same as the format the JIT passes to allocBBProfileBuffer.
1587 HRESULT interceptor_ICJI::getBBProfileData(CORINFO_METHOD_HANDLE ftnHnd,
1588                                            ULONG*                count, // The number of basic blocks that we have
1589                                            ProfileBuffer**       profileBuffer,
1590                                            ULONG*                numRuns)
1591 {
1592     mcs->AddCall("getBBProfileData");
1593     return original_ICorJitInfo->getBBProfileData(ftnHnd, count, profileBuffer, numRuns);
1594 }
1595
1596 // Associates a native call site, identified by its offset in the native code stream, with
1597 // the signature information and method handle the JIT used to lay out the call site. If
1598 // the call site has no signature information (e.g. a helper call) or has no method handle
1599 // (e.g. a CALLI P/Invoke), then null should be passed instead.
1600 void interceptor_ICJI::recordCallSite(ULONG                 instrOffset, /* IN */
1601                                       CORINFO_SIG_INFO*     callSig,     /* IN */
1602                                       CORINFO_METHOD_HANDLE methodHandle /* IN */
1603                                       )
1604 {
1605     mcs->AddCall("recordCallSite");
1606     return original_ICorJitInfo->recordCallSite(instrOffset, callSig, methodHandle);
1607 }
1608
1609 // A relocation is recorded if we are pre-jitting.
1610 // A jump thunk may be inserted if we are jitting
1611 void interceptor_ICJI::recordRelocation(void* location,   /* IN  */
1612                                         void* target,     /* IN  */
1613                                         WORD  fRelocType, /* IN  */
1614                                         WORD  slotNum,    /* IN  */
1615                                         INT32 addlDelta   /* IN  */
1616                                         )
1617 {
1618     mcs->AddCall("recordRelocation");
1619     original_ICorJitInfo->recordRelocation(location, target, fRelocType, slotNum, addlDelta);
1620 }
1621
1622 WORD interceptor_ICJI::getRelocTypeHint(void* target)
1623 {
1624     mcs->AddCall("getRelocTypeHint");
1625     return original_ICorJitInfo->getRelocTypeHint(target);
1626 }
1627
1628 // A callback to identify the range of address known to point to
1629 // compiler-generated native entry points that call back into
1630 // MSIL.
1631 void interceptor_ICJI::getModuleNativeEntryPointRange(void** pStart, /* OUT */
1632                                                       void** pEnd    /* OUT */
1633                                                       )
1634 {
1635     mcs->AddCall("getModuleNativeEntryPointRange");
1636     original_ICorJitInfo->getModuleNativeEntryPointRange(pStart, pEnd);
1637 }
1638
1639 // For what machine does the VM expect the JIT to generate code? The VM
1640 // returns one of the IMAGE_FILE_MACHINE_* values. Note that if the VM
1641 // is cross-compiling (such as the case for crossgen), it will return a
1642 // different value than if it was compiling for the host architecture.
1643 //
1644 DWORD interceptor_ICJI::getExpectedTargetArchitecture()
1645 {
1646     mcs->AddCall("getExpectedTargetArchitecture");
1647     return original_ICorJitInfo->getExpectedTargetArchitecture();
1648 }