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