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.
6 /*****************************************************************************/
9 /*****************************************************************************/
12 #include "windef.h" // For BYTE
14 // Some declarations in this file are used on non-x86 platforms, but most are x86-specific.
16 // Use the lower 2 bits of the offsets stored in the tables
17 // to encode properties
19 const unsigned OFFSET_MASK = 0x3; // mask to access the low 2 bits
22 // Note for untracked locals the flags allowed are "pinned" and "byref"
23 // and for tracked locals the flags allowed are "this" and "byref"
24 // Note that these definitions should also match the definitions of
25 // GC_CALL_INTERIOR and GC_CALL_PINNED in VM/gc.h
27 const unsigned byref_OFFSET_FLAG = 0x1; // the offset is an interior ptr
28 const unsigned pinned_OFFSET_FLAG = 0x2; // the offset is a pinned ptr
29 const unsigned this_OFFSET_FLAG = 0x2; // the offset is "this"
31 //-----------------------------------------------------------------------------
32 // The current GCInfo Version
33 //-----------------------------------------------------------------------------
35 #if defined(_TARGET_X86_) && !defined(FEATURE_CORECLR)
36 // X86 GcInfo encoding is yet to be changed for Desktop JIT32.
37 #define GCINFO_VERSION 1
39 #define GCINFO_VERSION 2
40 #endif // _TARGET_X86_
42 #define MIN_GCINFO_VERSION_WITH_RETURN_KIND 2
43 #define MIN_GCINFO_VERSION_WITH_REV_PINVOKE_FRAME 2
45 inline BOOL GCInfoEncodesReturnKind(UINT32 version=GCINFO_VERSION)
47 return version >= MIN_GCINFO_VERSION_WITH_RETURN_KIND;
50 inline BOOL GCInfoEncodesRevPInvokeFrame(UINT32 version=GCINFO_VERSION)
52 return version >= MIN_GCINFO_VERSION_WITH_REV_PINVOKE_FRAME;
55 //-----------------------------------------------------------------------------
56 // GCInfoToken: A wrapper that contains the GcInfo data and version number.
58 // The version# is not stored in the GcInfo structure -- because it is
59 // wasteful to store the version once for every method.
60 // Instead, the version# istracked per range-section of generated/loaded methods.
62 // The GCInfo version is computed as :
63 // 1) The current GCINFO_VERSION for JITted and Ngened images
64 // 2) A function of the Ready - to - run major version stored in READYTORUN_HEADER
65 // for ready - to - run images.ReadyToRunJitManager::JitTokenToGCInfoVersion()
66 // provides the GcInfo version for any Method.
67 //-----------------------------------------------------------------------------
74 BOOL IsReturnKindAvailable()
76 return GCInfoEncodesReturnKind(Version);
78 BOOL IsReversePInvokeFrameAvailable()
80 return GCInfoEncodesRevPInvokeFrame(Version);
83 static UINT32 ReadyToRunVersionToGcInfoVersion(UINT32 readyToRunMajorVersion)
85 // GcInfo version is 1 up to ReadyTorun version 1.x
86 // GcInfo version is current from ReadyToRun version 2.0
87 return (readyToRunMajorVersion == 1) ? 1 : GCINFO_VERSION;
91 /*****************************************************************************/
93 /*****************************************************************************/