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// ZapInfo.h
6//
7
8//
9// JIT-EE interface for zapping
10//
11// ======================================================================================
12
13#ifndef __ZAPINFO_H__
14#define __ZAPINFO_H__
15
16#include "zapcode.h"
17
18class ZapInfo;
19struct InlineContext;
20
21// The compiled code often implicitly needs fixups for various subtle reasons.
22// We only emit explict fixups while compiling the method, while collecting
23// implicit fixups in the LoadTable. At the end of compiling, we expect
24// many of the LoadTable entries to be subsumed by the explicit entries
25// and will not need to be emitted.
26// This is also used to detect duplicate explicit fixups for the same type.
27
28template <typename HandleType>
29class LoadTable
30{
31private:
32 ZapImage *m_pModule;
33
34 struct LoadEntry
35 {
36 HandleType handle;
37 int order; // -1 = fixed
38 };
39
40 static int __cdecl LoadEntryCmp(const void* a_, const void* b_)
41 {
42 return ((LoadEntry*)a_)->order - ((LoadEntry*)b_)->order;
43 }
44
45 class LoadEntryTraits : public NoRemoveSHashTraits< DefaultSHashTraits<LoadEntry> >
46 {
47 public:
48 typedef typename NoRemoveSHashTraits<DefaultSHashTraits<LoadEntry> >::count_t count_t;
49 typedef typename NoRemoveSHashTraits<DefaultSHashTraits<LoadEntry> >::element_t element_t;
50 typedef HandleType key_t;
51
52 static key_t GetKey(element_t e)
53 {
54 LIMITED_METHOD_CONTRACT;
55 return e.handle;
56 }
57 static BOOL Equals(key_t k1, key_t k2)
58 {
59 LIMITED_METHOD_CONTRACT;
60 return k1 == k2;
61 }
62 static count_t Hash(key_t k)
63 {
64 LIMITED_METHOD_CONTRACT;
65 return (count_t)(size_t)k;
66 }
67
68 static const element_t Null() { LIMITED_METHOD_CONTRACT; LoadEntry e; e.handle = NULL; e.order = 0; return e; }
69 static bool IsNull(const element_t &e) { LIMITED_METHOD_CONTRACT; return (e.handle == NULL); }
70 };
71
72 typedef SHash<LoadEntryTraits> LoadEntryHashTable;
73
74 LoadEntryHashTable m_entries;
75
76public:
77 LoadTable(ZapImage *pModule)
78 : m_pModule(pModule)
79 {
80 }
81
82 // fixed=TRUE if the caller can guarantee that type will be fixed up because
83 // of some implicit fixup. In this case, we track 'handle' only to avoid
84 // duplicates and will not actually emit an explicit fixup for 'handle'
85 //
86 // fixed=FALSE if the caller needs an explicit fixup. We will emit an
87 // explicit fixup for 'handle' if there are no other implicit fixups.
88
89 void Load(HandleType handle, BOOL fixed)
90 {
91 CONTRACTL
92 {
93 THROWS;
94 GC_NOTRIGGER;
95 }
96 CONTRACTL_END;
97
98 const LoadEntry *result = m_entries.LookupPtr(handle);
99
100 if (result != NULL)
101 {
102 if (fixed)
103 ((LoadEntry*)result)->order = -1;
104 return;
105 }
106
107 LoadEntry newEntry;
108
109 newEntry.handle = handle;
110 newEntry.order = fixed ? -1 : m_entries.GetCount();
111
112 m_entries.Add(newEntry);
113 }
114
115 void EmitLoadFixups(CORINFO_METHOD_HANDLE currentMethodHandle, ZapInfo * pZapInfo);
116};
117
118// Declare some specializations of EmitLoadFixups().
119template<> void LoadTable<CORINFO_CLASS_HANDLE>::EmitLoadFixups(CORINFO_METHOD_HANDLE currentMethodHandle, ZapInfo * pZapInfo);
120template<> void LoadTable<CORINFO_METHOD_HANDLE>::EmitLoadFixups(CORINFO_METHOD_HANDLE currentMethodHandle, ZapInfo * pZapInfo);
121
122
123class ZapInfo
124 : public ICorJitInfo
125{
126 friend class ZapImage;
127
128 // Owning ZapImage
129 ZapImage * m_pImage;
130
131 Zapper * m_zapper;
132 ICorDynamicInfo * m_pEEJitInfo;
133 ICorCompileInfo * m_pEECompileInfo;
134
135 // Current method being compiled; it is non-nil only for
136 // method defs whose IL is in this module and (for generic code)
137 // have <object> instantiation. It is also nil for IL_STUBs.
138 mdMethodDef m_currentMethodToken;
139 CORINFO_METHOD_HANDLE m_currentMethodHandle;
140 CORINFO_METHOD_INFO m_currentMethodInfo;
141
142 // m_currentMethodModule==m_hModule except for generic types/methods
143 // defined in another assembly but instantiated in the current assembly.
144 CORINFO_MODULE_HANDLE m_currentMethodModule;
145
146 unsigned m_currentMethodProfilingDataFlags;
147
148 // Debug information reported by the JIT compiler for the current method
149 ICorDebugInfo::NativeVarInfo *m_pNativeVarInfo;
150 ULONG32 m_iNativeVarInfo;
151 ICorDebugInfo::OffsetMapping *m_pOffsetMapping;
152 ULONG32 m_iOffsetMapping;
153
154 BYTE * m_pGCInfo;
155 SIZE_T m_cbGCInfo;
156
157
158 ZapBlobWithRelocs * m_pCode;
159 ZapBlobWithRelocs * m_pColdCode;
160 ZapBlobWithRelocs * m_pROData;
161
162#ifdef WIN64EXCEPTIONS
163 // Unwind info of the main method body. It will get merged with GC info.
164 BYTE * m_pMainUnwindInfo;
165 ULONG m_cbMainUnwindInfo;
166
167 ZapUnwindInfo * m_pUnwindInfo;
168 ZapUnwindInfo * m_pUnwindInfoFragments;
169#if defined(_TARGET_AMD64_)
170 ZapUnwindInfo * m_pChainedColdUnwindInfo;
171#endif
172#endif // WIN64EXCEPTIONS
173
174 ZapExceptionInfo * m_pExceptionInfo;
175
176 ZapBlobWithRelocs * m_pProfileData;
177
178 ZapImport * m_pProfilingHandle;
179
180 struct CodeRelocation : ZapReloc
181 {
182 ZapBlobWithRelocs * m_pNode;
183 };
184
185 SArray<CodeRelocation> m_CodeRelocations;
186
187 static int __cdecl CompareCodeRelocation(const void * a, const void * b);
188
189 struct ImportEntry
190 {
191 ZapImport * pImport;
192 bool fConditional; // Conditional imports are emitted only if they are actually referenced by the code.
193 };
194
195 class ImportTraits : public NoRemoveSHashTraits< DefaultSHashTraits<ImportEntry> >
196 {
197 public:
198 typedef ZapImport * key_t;
199
200 static key_t GetKey(element_t e)
201 {
202 LIMITED_METHOD_CONTRACT;
203 return e.pImport;
204 }
205 static BOOL Equals(key_t k1, key_t k2)
206 {
207 LIMITED_METHOD_CONTRACT;
208 return k1 == k2;
209 }
210 static count_t Hash(key_t k)
211 {
212 LIMITED_METHOD_CONTRACT;
213 return (count_t)(size_t)k;
214 }
215
216 static const element_t Null() { LIMITED_METHOD_CONTRACT; ImportEntry e; e.pImport = NULL; return e; }
217 static bool IsNull(const element_t &e) { LIMITED_METHOD_CONTRACT; return e.pImport == NULL; }
218 };
219
220 SHash<ImportTraits> m_ImportSet;
221 SArray<ZapImport *> m_Imports;
222
223 InlineSString<128> m_currentMethodName;
224
225 // Cache to reduce the number of entries in CORCOMPILE_LOAD_TABLE if it
226 // is implied by some other fixup type
227 LoadTable<CORINFO_CLASS_HANDLE> m_ClassLoadTable;
228 LoadTable<CORINFO_METHOD_HANDLE> m_MethodLoadTable;
229
230 CORJIT_FLAGS m_jitFlags;
231
232 void InitMethodName();
233
234 CORJIT_FLAGS ComputeJitFlags(CORINFO_METHOD_HANDLE handle);
235
236 ZapDebugInfo * EmitDebugInfo();
237 ZapGCInfo * EmitGCInfo();
238 ZapImport ** EmitFixupList();
239
240 void PublishCompiledMethod();
241
242 void EmitCodeRelocations();
243
244 void ProcessReferences();
245
246 BOOL CurrentMethodHasProfileData();
247
248 void embedGenericSignature(CORINFO_LOOKUP * pLookup);
249
250 PVOID embedDirectCall(CORINFO_METHOD_HANDLE ftn,
251 CORINFO_ACCESS_FLAGS accessFlags,
252 BOOL fAllowThunk);
253
254public:
255 ZapInfo(ZapImage * pImage, mdMethodDef md, CORINFO_METHOD_HANDLE handle, CORINFO_MODULE_HANDLE module, unsigned methodProfilingDataFlags);
256 ~ZapInfo();
257
258#ifdef ALLOW_SXS_JIT_NGEN
259 void ResetForJitRetry();
260#endif // ALLOW_SXS_JIT_NGEN
261
262 void CompileMethod();
263
264 void AppendImport(ZapImport * pImport);
265 void AppendConditionalImport(ZapImport * pImport);
266
267 ULONG GetNumFixups();
268
269 // ICorJitInfo
270
271 IEEMemoryManager* getMemoryManager();
272
273 virtual void allocMem (
274 ULONG hotCodeSize, /* IN */
275 ULONG coldCodeSize, /* IN */
276 ULONG roDataSize, /* IN */
277 ULONG xcptnsCount, /* IN */
278 CorJitAllocMemFlag flag, /* IN */
279 void ** hotCodeBlock, /* OUT */
280 void ** coldCodeBlock, /* OUT */
281 void ** roDataBlock /* OUT */
282 );
283
284 void reserveUnwindInfo(
285 BOOL isFunclet, /* IN */
286 BOOL isColdCode, /* IN */
287 ULONG unwindSize /* IN */
288 );
289
290 void allocUnwindInfo (
291 BYTE * pHotCode, /* IN */
292 BYTE * pColdCode, /* IN */
293 ULONG startOffset, /* IN */
294 ULONG endOffset, /* IN */
295 ULONG unwindSize, /* IN */
296 BYTE * pUnwindBlock, /* IN */
297 CorJitFuncKind funcKind /* IN */
298 );
299
300 void * allocGCInfo(size_t size);
301 void yieldExecution();
302 void setEHcount(unsigned cEH);
303 void setEHinfo(unsigned EHnumber, const CORINFO_EH_CLAUSE *clause);
304
305 int canHandleException(struct _EXCEPTION_POINTERS *pExceptionPointers);
306 BOOL logMsg(unsigned level, const char *fmt, va_list args);
307 int doAssert(const char* szFile, int iLine, const char* szExpr);
308 void reportFatalError(CorJitResult result);
309
310 HRESULT allocBBProfileBuffer (
311 ULONG cBlock,
312 ICorJitInfo::ProfileBuffer ** ppBlock);
313
314 HRESULT getBBProfileData (
315 CORINFO_METHOD_HANDLE ftnHnd,
316 ULONG * size,
317 ICorJitInfo::ProfileBuffer ** profileBuffer,
318 ULONG * numRuns);
319
320 DWORD getJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes);
321
322 bool runWithErrorTrap(void (*function)(void*), void* param);
323
324 // ICorDynamicInfo
325
326 DWORD getThreadTLSIndex(void **ppIndirection);
327 const void * getInlinedCallFrameVptr(void **ppIndirection);
328 LONG * getAddrOfCaptureThreadGlobal(void **ppIndirection);
329
330 // get slow lazy string literal helper to use (CORINFO_HELP_STRCNS*).
331 // Returns CORINFO_HELP_UNDEF if lazy string literal helper cannot be used.
332 CorInfoHelpFunc getLazyStringLiteralHelper(CORINFO_MODULE_HANDLE handle);
333
334 CORINFO_MODULE_HANDLE
335 embedModuleHandle(CORINFO_MODULE_HANDLE handle,
336 void **ppIndirection);
337 CORINFO_CLASS_HANDLE
338 embedClassHandle(CORINFO_CLASS_HANDLE handle,
339 void **ppIndirection);
340 CORINFO_FIELD_HANDLE
341 embedFieldHandle(CORINFO_FIELD_HANDLE handle,
342 void **ppIndirection);
343 CORINFO_METHOD_HANDLE
344 embedMethodHandle(CORINFO_METHOD_HANDLE handle,
345 void **ppIndirection);
346 void
347 embedGenericHandle(CORINFO_RESOLVED_TOKEN * pResolvedToken,
348 BOOL fEmbedParent,
349 CORINFO_GENERICHANDLE_RESULT *pResult);
350
351 CORINFO_LOOKUP_KIND
352 getLocationOfThisType(CORINFO_METHOD_HANDLE context);
353
354
355
356 void * getHelperFtn (CorInfoHelpFunc ftnNum,
357 void** ppIndirection);
358
359 void* getTailCallCopyArgsThunk (
360 CORINFO_SIG_INFO *pSig,
361 CorInfoHelperTailCallSpecialHandling flags);
362
363 bool convertPInvokeCalliToCall(
364 CORINFO_RESOLVED_TOKEN * pResolvedToken,
365 bool fMustConvert);
366
367 void getFunctionEntryPoint(
368 CORINFO_METHOD_HANDLE ftn, /* IN */
369 CORINFO_CONST_LOOKUP * pResult, /* OUT */
370 CORINFO_ACCESS_FLAGS accessFlags = CORINFO_ACCESS_ANY);
371
372 void getFunctionFixedEntryPoint(
373 CORINFO_METHOD_HANDLE ftn,
374 CORINFO_CONST_LOOKUP * pResult);
375
376
377 void * getMethodSync(CORINFO_METHOD_HANDLE ftn,
378 void **ppIndirection);
379 void * getPInvokeUnmanagedTarget(CORINFO_METHOD_HANDLE method,
380 void **ppIndirection);
381 void * getAddressOfPInvokeFixup(CORINFO_METHOD_HANDLE method,
382 void **ppIndirection);
383 void getAddressOfPInvokeTarget(CORINFO_METHOD_HANDLE method,
384 CORINFO_CONST_LOOKUP *pLookup);
385 CORINFO_JUST_MY_CODE_HANDLE getJustMyCodeHandle(
386 CORINFO_METHOD_HANDLE method,
387 CORINFO_JUST_MY_CODE_HANDLE **ppIndirection);
388
389 ZapImport * GetProfilingHandleImport();
390
391 void GetProfilingHandle(
392 BOOL *pbHookFunction,
393 void **pProfilerHandle,
394 BOOL *pbIndirectedHandles
395 );
396
397 void getCallInfo(
398 // Token info
399 CORINFO_RESOLVED_TOKEN * pResolvedToken,
400 //Generics info
401 CORINFO_RESOLVED_TOKEN * pConstrainedResolvedToken,
402 //Security info
403 CORINFO_METHOD_HANDLE callerHandle,
404 //Jit info
405 CORINFO_CALLINFO_FLAGS flags,
406 //out params
407 CORINFO_CALL_INFO *pResult);
408
409 BOOL canAccessFamily(CORINFO_METHOD_HANDLE hCaller,
410 CORINFO_CLASS_HANDLE hInstanceType);
411
412
413 BOOL isRIDClassDomainID(CORINFO_CLASS_HANDLE cls);
414
415 unsigned getClassDomainID(CORINFO_CLASS_HANDLE cls,
416 void **ppIndirection);
417
418 void * getFieldAddress(CORINFO_FIELD_HANDLE field,
419 void **ppIndirection);
420 CORINFO_CLASS_HANDLE getStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field,
421 bool* pIsSpeculative);
422
423 DWORD getFieldThreadLocalStoreID (CORINFO_FIELD_HANDLE field,
424 void **ppIndirection);
425 CORINFO_VARARGS_HANDLE getVarArgsHandle(CORINFO_SIG_INFO *sig,
426 void **ppIndirection);
427 bool canGetVarArgsHandle(CORINFO_SIG_INFO *sig);
428
429 InfoAccessType constructStringLiteral(CORINFO_MODULE_HANDLE module,
430 unsigned metaTok, void **ppIndirection);
431
432 InfoAccessType emptyStringLiteral(void **ppIndirection);
433
434 void setOverride(ICorDynamicInfo *pOverride, CORINFO_METHOD_HANDLE currentMethod);
435
436 void addActiveDependency(CORINFO_MODULE_HANDLE moduleFrom, CORINFO_MODULE_HANDLE moduleTo);
437
438 void recordCallSite(ULONG instrOffset, CORINFO_SIG_INFO *callSig, CORINFO_METHOD_HANDLE methodHandle);
439
440 // Relocations
441
442 void recordRelocation(void *location, void *target,
443 WORD fRelocType, WORD slotNum, INT32 addlDelta);
444
445 WORD getRelocTypeHint(void * target);
446
447 void getModuleNativeEntryPointRange(void** pStart, void** pEnd);
448
449 DWORD getExpectedTargetArchitecture();
450
451 // ICorJitInfo delegate ctor optimization
452 CORINFO_METHOD_HANDLE GetDelegateCtor(
453 CORINFO_METHOD_HANDLE methHnd,
454 CORINFO_CLASS_HANDLE clsHnd,
455 CORINFO_METHOD_HANDLE targetMethodHnd,
456 DelegateCtorArgs * pCtorData);
457
458 void MethodCompileComplete(
459 CORINFO_METHOD_HANDLE methHnd);
460
461 // ICorStaticInfo
462
463 void getEEInfo(CORINFO_EE_INFO *pEEInfoOut);
464
465 LPCWSTR getJitTimeLogFilename();
466
467 // ICorArgInfo
468
469 CORINFO_ARG_LIST_HANDLE getArgNext(CORINFO_ARG_LIST_HANDLE args);
470 CorInfoTypeWithMod getArgType(CORINFO_SIG_INFO* sig,
471 CORINFO_ARG_LIST_HANDLE args,
472 CORINFO_CLASS_HANDLE *vcTypeRet);
473 CORINFO_CLASS_HANDLE getArgClass(CORINFO_SIG_INFO* sig,
474 CORINFO_ARG_LIST_HANDLE args);
475 CorInfoType getHFAType(CORINFO_CLASS_HANDLE hClass);
476
477 // ICorDebugInfo
478
479 void getBoundaries(CORINFO_METHOD_HANDLE ftn, unsigned int *cILOffsets,
480 DWORD **pILOffsets, ICorDebugInfo::BoundaryTypes *implicitBoundaries);
481 void setBoundaries(CORINFO_METHOD_HANDLE ftn, ULONG32 cMap,
482 ICorDebugInfo::OffsetMapping *pMap);
483 void getVars(CORINFO_METHOD_HANDLE ftn, ULONG32 *cVars,
484 ICorDebugInfo::ILVarInfo **vars, bool *extendOthers);
485 void setVars(CORINFO_METHOD_HANDLE ftn, ULONG32 cVars,
486 ICorDebugInfo::NativeVarInfo*vars);
487 void * allocateArray(ULONG cBytes);
488 void freeArray(void *array);
489
490 // ICorFieldInfo
491
492 const char* getFieldName(CORINFO_FIELD_HANDLE ftn, const char **moduleName);
493 CORINFO_CLASS_HANDLE getFieldClass(CORINFO_FIELD_HANDLE field);
494
495 CorInfoType getFieldType(CORINFO_FIELD_HANDLE field,
496 CORINFO_CLASS_HANDLE *structType,
497 CORINFO_CLASS_HANDLE memberParent);
498
499 unsigned getFieldOffset(CORINFO_FIELD_HANDLE field);
500
501 bool isWriteBarrierHelperRequired(
502 CORINFO_FIELD_HANDLE field);
503
504 void getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken,
505 CORINFO_METHOD_HANDLE callerHandle,
506 CORINFO_ACCESS_FLAGS flags,
507 CORINFO_FIELD_INFO *pResult);
508
509 bool isFieldStatic(CORINFO_FIELD_HANDLE fldHnd);
510
511 // ICorClassInfo
512
513 CorInfoType asCorInfoType(CORINFO_CLASS_HANDLE cls);
514 const char* getClassName(CORINFO_CLASS_HANDLE cls);
515 const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName);
516 CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index);
517 const char* getHelperName(CorInfoHelpFunc ftnNum);
518 int appendClassName(__deref_inout_ecount(*pnBufLen) WCHAR** ppBuf, int* pnBufLen,
519 CORINFO_CLASS_HANDLE cls,
520 BOOL fNamespace,
521 BOOL fFullInst,
522 BOOL fAssembly);
523 BOOL isValueClass(CORINFO_CLASS_HANDLE clsHnd);
524 CorInfoInlineTypeCheck canInlineTypeCheck(CORINFO_CLASS_HANDLE cls, CorInfoInlineTypeCheckSource source);
525 BOOL canInlineTypeCheckWithObjectVTable(CORINFO_CLASS_HANDLE clsHnd);
526 DWORD getClassAttribs(CORINFO_CLASS_HANDLE cls);
527 BOOL isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls);
528 CORINFO_MODULE_HANDLE getClassModule(CORINFO_CLASS_HANDLE cls);
529 CORINFO_ASSEMBLY_HANDLE getModuleAssembly(CORINFO_MODULE_HANDLE mod);
530 const char* getAssemblyName(CORINFO_ASSEMBLY_HANDLE assem);
531 void* LongLifetimeMalloc(size_t sz);
532 void LongLifetimeFree(void* obj);
533 size_t getClassModuleIdForStatics(CORINFO_CLASS_HANDLE cls, CORINFO_MODULE_HANDLE *pModule, void **ppIndirection);
534
535 unsigned getClassSize(CORINFO_CLASS_HANDLE cls);
536 unsigned getHeapClassSize(CORINFO_CLASS_HANDLE cls);
537 BOOL canAllocateOnStack(CORINFO_CLASS_HANDLE cls);
538 unsigned getClassAlignmentRequirement(CORINFO_CLASS_HANDLE cls, BOOL fDoubleAlignHint);
539
540 CORINFO_FIELD_HANDLE getFieldInClass(CORINFO_CLASS_HANDLE clsHnd, INT num);
541
542 mdMethodDef getMethodDefFromMethod(CORINFO_METHOD_HANDLE hMethod);
543 BOOL checkMethodModifier(CORINFO_METHOD_HANDLE hMethod, LPCSTR modifier, BOOL fOptional);
544
545 unsigned getClassGClayout(CORINFO_CLASS_HANDLE cls, BYTE *gcPtrs);
546
547 bool getSystemVAmd64PassStructInRegisterDescriptor(
548 /*IN*/ CORINFO_CLASS_HANDLE _structHnd,
549 /*OUT*/ SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr);
550
551 unsigned getClassNumInstanceFields(CORINFO_CLASS_HANDLE cls);
552
553 CorInfoHelpFunc getNewHelper(CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_METHOD_HANDLE callerHandle, bool * pHasSideEffects = NULL);
554 CorInfoHelpFunc getCastingHelper(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fThrowing);
555 CorInfoHelpFunc getNewArrHelper(CORINFO_CLASS_HANDLE arrayCls);
556 CorInfoHelpFunc getSharedCCtorHelper(CORINFO_CLASS_HANDLE clsHnd);
557 CorInfoHelpFunc getSecurityPrologHelper(CORINFO_METHOD_HANDLE ftn);
558 CORINFO_CLASS_HANDLE getTypeForBox(CORINFO_CLASS_HANDLE cls);
559 CorInfoHelpFunc getBoxHelper(CORINFO_CLASS_HANDLE cls);
560 CorInfoHelpFunc getUnBoxHelper(CORINFO_CLASS_HANDLE cls);
561
562 bool getReadyToRunHelper(
563 CORINFO_RESOLVED_TOKEN * pResolvedToken,
564 CORINFO_LOOKUP_KIND * pGenericLookupKind,
565 CorInfoHelpFunc id,
566 CORINFO_CONST_LOOKUP * pLookup
567 );
568
569 void getReadyToRunDelegateCtorHelper(
570 CORINFO_RESOLVED_TOKEN * pTargetMethod,
571 CORINFO_CLASS_HANDLE delegateType,
572 CORINFO_LOOKUP * pLookup
573 );
574
575 CorInfoInitClassResult initClass(
576 CORINFO_FIELD_HANDLE field,
577 CORINFO_METHOD_HANDLE method,
578 CORINFO_CONTEXT_HANDLE context,
579 BOOL speculative = FALSE);
580
581 void classMustBeLoadedBeforeCodeIsRun(CORINFO_CLASS_HANDLE cls);
582 void methodMustBeLoadedBeforeCodeIsRun(CORINFO_METHOD_HANDLE meth);
583 CORINFO_METHOD_HANDLE mapMethodDeclToMethodImpl(CORINFO_METHOD_HANDLE methHnd);
584 CORINFO_CLASS_HANDLE getBuiltinClass(CorInfoClassId classId);
585 CorInfoType getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE cls);
586 CorInfoType getTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls);
587 BOOL canCast(CORINFO_CLASS_HANDLE child, CORINFO_CLASS_HANDLE parent);
588 BOOL areTypesEquivalent(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2);
589 TypeCompareState compareTypesForCast(CORINFO_CLASS_HANDLE fromClass, CORINFO_CLASS_HANDLE toClass);
590 TypeCompareState compareTypesForEquality(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2);
591
592 CORINFO_CLASS_HANDLE mergeClasses(CORINFO_CLASS_HANDLE cls1,
593 CORINFO_CLASS_HANDLE cls2);
594 BOOL shouldEnforceCallvirtRestriction(CORINFO_MODULE_HANDLE scope);
595 CORINFO_CLASS_HANDLE getParentType(CORINFO_CLASS_HANDLE cls);
596 CorInfoType getChildType (CORINFO_CLASS_HANDLE clsHnd,
597 CORINFO_CLASS_HANDLE *clsRet);
598 BOOL satisfiesClassConstraints(CORINFO_CLASS_HANDLE cls);
599
600 BOOL isSDArray (CORINFO_CLASS_HANDLE cls);
601 unsigned getArrayRank(CORINFO_CLASS_HANDLE cls);
602 void * getArrayInitializationData(CORINFO_FIELD_HANDLE field, DWORD size);
603 CorInfoIsAccessAllowedResult canAccessClass(CORINFO_RESOLVED_TOKEN * pResolvedToken,
604 CORINFO_METHOD_HANDLE callerHandle,
605 CORINFO_HELPER_DESC *throwHelper);
606
607 // ICorModuleInfo
608
609 void resolveToken(CORINFO_RESOLVED_TOKEN * pResolvedToken);
610 bool tryResolveToken(CORINFO_RESOLVED_TOKEN * pResolvedToken);
611
612 void findSig(CORINFO_MODULE_HANDLE module, unsigned sigTOK,
613 CORINFO_CONTEXT_HANDLE context,
614 CORINFO_SIG_INFO *sig);
615 void findCallSiteSig(CORINFO_MODULE_HANDLE module,
616 unsigned methTOK,
617 CORINFO_CONTEXT_HANDLE context,
618 CORINFO_SIG_INFO *sig);
619 CORINFO_CLASS_HANDLE getTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN * pResolvedToken);
620 size_t findNameOfToken(CORINFO_MODULE_HANDLE module,
621 unsigned metaTOK,
622 __out_ecount (FQNameCapacity) char * szFQName,
623 size_t FQNameCapacity);
624 CorInfoCanSkipVerificationResult canSkipVerification (CORINFO_MODULE_HANDLE module);
625 BOOL isValidToken(CORINFO_MODULE_HANDLE module,
626 unsigned metaTOK);
627 BOOL isValidStringRef(CORINFO_MODULE_HANDLE module,
628 unsigned metaTOK);
629
630
631 // ICorMethodInfo
632
633 const char* getMethodName(CORINFO_METHOD_HANDLE ftn,
634 const char **moduleName);
635 const char* getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,
636 const char **className,
637 const char **namespaceName,
638 const char **enclosingClassName);
639
640 unsigned getMethodHash(CORINFO_METHOD_HANDLE ftn);
641 DWORD getMethodAttribs(CORINFO_METHOD_HANDLE ftn);
642 void setMethodAttribs(CORINFO_METHOD_HANDLE ftn, CorInfoMethodRuntimeFlags attribs);
643
644 void getMethodSig(CORINFO_METHOD_HANDLE ftn, CORINFO_SIG_INFO *sig, CORINFO_CLASS_HANDLE memberParent);
645
646 bool getMethodInfo(CORINFO_METHOD_HANDLE ftn,
647 CORINFO_METHOD_INFO* info);
648
649 CorInfoInline canInline(CORINFO_METHOD_HANDLE caller,
650 CORINFO_METHOD_HANDLE callee,
651 DWORD* pRestrictions);
652
653 void reportInliningDecision (CORINFO_METHOD_HANDLE inlinerHnd,
654 CORINFO_METHOD_HANDLE inlineeHnd,
655 CorInfoInline inlineResult,
656 const char * reason);
657
658 CorInfoInstantiationVerification isInstantiationOfVerifiedGeneric(
659 CORINFO_METHOD_HANDLE method);
660
661 void initConstraintsForVerification(CORINFO_METHOD_HANDLE method,
662 BOOL *pfHasCircularClassConstraints,
663 BOOL *pfHasCircularMethodConstraints);
664
665 bool canTailCall(CORINFO_METHOD_HANDLE caller,
666 CORINFO_METHOD_HANDLE declaredCallee,
667 CORINFO_METHOD_HANDLE exactCallee,
668 bool fIsTailPrefix);
669
670 void reportTailCallDecision (CORINFO_METHOD_HANDLE callerHnd,
671 CORINFO_METHOD_HANDLE calleeHnd,
672 bool fIsTailPrefix,
673 CorInfoTailCall tailCallResult,
674 const char * reason);
675
676 CorInfoCanSkipVerificationResult canSkipMethodVerification (
677 CORINFO_METHOD_HANDLE callerHnd);
678
679 void getEHinfo(CORINFO_METHOD_HANDLE ftn,
680 unsigned EHnumber, CORINFO_EH_CLAUSE* clause);
681 CORINFO_CLASS_HANDLE getMethodClass(CORINFO_METHOD_HANDLE method);
682 CORINFO_MODULE_HANDLE getMethodModule(CORINFO_METHOD_HANDLE method);
683
684 void getMethodVTableOffset(CORINFO_METHOD_HANDLE method,
685 unsigned * pOffsetOfIndirection,
686 unsigned * pOffsetAfterIndirection,
687 bool * isRelative);
688
689 CORINFO_METHOD_HANDLE resolveVirtualMethod(
690 CORINFO_METHOD_HANDLE virtualMethod,
691 CORINFO_CLASS_HANDLE implementingClass,
692 CORINFO_CONTEXT_HANDLE ownerType);
693
694 CORINFO_METHOD_HANDLE getUnboxedEntry(
695 CORINFO_METHOD_HANDLE ftn,
696 bool* requiresInstMethodTableArg);
697
698 CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass(
699 CORINFO_CLASS_HANDLE elemType);
700
701 void expandRawHandleIntrinsic(
702 CORINFO_RESOLVED_TOKEN * pResolvedToken,
703 CORINFO_GENERICHANDLE_RESULT * pResult);
704
705 CorInfoIntrinsics getIntrinsicID(CORINFO_METHOD_HANDLE method,
706 bool * pMustExpand = NULL);
707 bool isInSIMDModule(CORINFO_CLASS_HANDLE classHnd);
708 CorInfoUnmanagedCallConv getUnmanagedCallConv(CORINFO_METHOD_HANDLE method);
709 BOOL pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
710 LPVOID GetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig,
711 void ** ppIndirecton);
712 bool canGetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig);
713 BOOL satisfiesMethodConstraints(CORINFO_CLASS_HANDLE parent,
714 CORINFO_METHOD_HANDLE method);
715
716 BOOL isCompatibleDelegate(CORINFO_CLASS_HANDLE objCls,
717 CORINFO_CLASS_HANDLE methodParentCls,
718 CORINFO_METHOD_HANDLE method,
719 CORINFO_CLASS_HANDLE delegateCls,
720 BOOL* pfIsOpenDelegate);
721
722 void getGSCookie(GSCookie * pCookieVal,
723 GSCookie** ppCookieVal);
724 // ICorErrorInfo
725
726 HRESULT GetErrorHRESULT(struct _EXCEPTION_POINTERS *pExceptionPointers);
727 ULONG GetErrorMessage(__in_ecount(bufferLength) LPWSTR buffer, ULONG bufferLength);
728 int FilterException(struct _EXCEPTION_POINTERS *pExceptionPointers);
729 void HandleException(struct _EXCEPTION_POINTERS *pExceptionPointers);
730 void ThrowExceptionForJitResult(HRESULT result);
731 void ThrowExceptionForHelper(const CORINFO_HELPER_DESC * throwHelper);
732};
733
734#endif // __ZAPINFO_H__
735