Skip to content

Commit

Permalink
Initial impl
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Oct 10, 2022
1 parent f33d778 commit eab2ff7
Show file tree
Hide file tree
Showing 37 changed files with 924 additions and 273 deletions.
4 changes: 4 additions & 0 deletions src/coreclr/inc/CrstTypes.def
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ Crst MethodTableExposedObject
Unordered
End

Crst MethodSizeCache
Unordered
End

Crst RetThunkCache
AcquiredBefore LoaderHeap
End
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,10 @@ class ICorStaticInfo
CORINFO_METHOD_HANDLE ftn /* IN */
) = 0;

virtual uint32_t getILSize (
CORINFO_METHOD_HANDLE ftn /* IN */
) = 0;

// sets private JIT flags, which can be, retrieved using getAttrib.
virtual void setMethodAttribs (
CORINFO_METHOD_HANDLE ftn, /* IN */
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/inc/corinfoinstructionset.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ struct CORINFO_InstructionSetFlags
uint64_t _flags[FlagsFieldCount] = { };


static uint32_t GetFlagsFieldIndex(CORINFO_InstructionSet instructionSet)
static inline uint32_t GetFlagsFieldIndex(CORINFO_InstructionSet instructionSet)
{
uint32_t bitIndex = (uint32_t)instructionSet;
return (uint32_t)(bitIndex / (uint32_t)BitsPerFlagsField);
}

static uint64_t GetRelativeBitMask(CORINFO_InstructionSet instructionSet)
static inline uint64_t GetRelativeBitMask(CORINFO_InstructionSet instructionSet)
{
return ((uint64_t)1) << (instructionSet & 0x3F);
}
Expand All @@ -196,7 +196,7 @@ struct CORINFO_InstructionSetFlags
_flags[index] &= ~bitIndex;
}

bool HasInstructionSet(CORINFO_InstructionSet instructionSet) const
inline bool HasInstructionSet(CORINFO_InstructionSet instructionSet) const
{
uint32_t index = GetFlagsFieldIndex(instructionSet);
uint64_t bitIndex = GetRelativeBitMask(instructionSet);
Expand Down
109 changes: 56 additions & 53 deletions src/coreclr/inc/crsttypes_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,59 +81,60 @@ enum CrstType
CrstLoaderHeap = 63,
CrstManagedObjectWrapperMap = 64,
CrstMethodDescBackpatchInfoTracker = 65,
CrstMethodTableExposedObject = 66,
CrstModule = 67,
CrstModuleFixup = 68,
CrstModuleLookupTable = 69,
CrstMulticoreJitHash = 70,
CrstMulticoreJitManager = 71,
CrstNativeImageEagerFixups = 72,
CrstNativeImageLoad = 73,
CrstNls = 74,
CrstNotifyGdb = 75,
CrstObjectList = 76,
CrstPEImage = 77,
CrstPendingTypeLoadEntry = 78,
CrstPgoData = 79,
CrstPinnedByrefValidation = 80,
CrstPinnedHeapHandleTable = 81,
CrstProfilerGCRefDataFreeList = 82,
CrstProfilingAPIStatus = 83,
CrstRCWCache = 84,
CrstRCWCleanupList = 85,
CrstReadyToRunEntryPointToMethodDescMap = 86,
CrstReflection = 87,
CrstReJITGlobalRequest = 88,
CrstRetThunkCache = 89,
CrstSavedExceptionInfo = 90,
CrstSaveModuleProfileData = 91,
CrstSecurityStackwalkCache = 92,
CrstSigConvert = 93,
CrstSingleUseLock = 94,
CrstSpecialStatics = 95,
CrstStackSampler = 96,
CrstStressLog = 97,
CrstStubCache = 98,
CrstStubDispatchCache = 99,
CrstStubUnwindInfoHeapSegments = 100,
CrstSyncBlockCache = 101,
CrstSyncHashLock = 102,
CrstSystemBaseDomain = 103,
CrstSystemDomain = 104,
CrstSystemDomainDelayedUnloadList = 105,
CrstThreadIdDispenser = 106,
CrstThreadStore = 107,
CrstTieredCompilation = 108,
CrstTypeEquivalenceMap = 109,
CrstTypeIDMap = 110,
CrstUMEntryThunkCache = 111,
CrstUMEntryThunkFreeListLock = 112,
CrstUniqueStack = 113,
CrstUnresolvedClassLock = 114,
CrstUnwindInfoTableLock = 115,
CrstVSDIndirectionCellLock = 116,
CrstWrapperTemplate = 117,
kNumberOfCrstTypes = 118
CrstMethodSizeCache = 66,
CrstMethodTableExposedObject = 67,
CrstModule = 68,
CrstModuleFixup = 69,
CrstModuleLookupTable = 70,
CrstMulticoreJitHash = 71,
CrstMulticoreJitManager = 72,
CrstNativeImageEagerFixups = 73,
CrstNativeImageLoad = 74,
CrstNls = 75,
CrstNotifyGdb = 76,
CrstObjectList = 77,
CrstPEImage = 78,
CrstPendingTypeLoadEntry = 79,
CrstPgoData = 80,
CrstPinnedByrefValidation = 81,
CrstPinnedHeapHandleTable = 82,
CrstProfilerGCRefDataFreeList = 83,
CrstProfilingAPIStatus = 84,
CrstRCWCache = 85,
CrstRCWCleanupList = 86,
CrstReadyToRunEntryPointToMethodDescMap = 87,
CrstReflection = 88,
CrstReJITGlobalRequest = 89,
CrstRetThunkCache = 90,
CrstSavedExceptionInfo = 91,
CrstSaveModuleProfileData = 92,
CrstSecurityStackwalkCache = 93,
CrstSigConvert = 94,
CrstSingleUseLock = 95,
CrstSpecialStatics = 96,
CrstStackSampler = 97,
CrstStressLog = 98,
CrstStubCache = 99,
CrstStubDispatchCache = 100,
CrstStubUnwindInfoHeapSegments = 101,
CrstSyncBlockCache = 102,
CrstSyncHashLock = 103,
CrstSystemBaseDomain = 104,
CrstSystemDomain = 105,
CrstSystemDomainDelayedUnloadList = 106,
CrstThreadIdDispenser = 107,
CrstThreadStore = 108,
CrstTieredCompilation = 109,
CrstTypeEquivalenceMap = 110,
CrstTypeIDMap = 111,
CrstUMEntryThunkCache = 112,
CrstUMEntryThunkFreeListLock = 113,
CrstUniqueStack = 114,
CrstUnresolvedClassLock = 115,
CrstUnwindInfoTableLock = 116,
CrstVSDIndirectionCellLock = 117,
CrstWrapperTemplate = 118,
kNumberOfCrstTypes = 119
};

#endif // __CRST_TYPES_INCLUDED
Expand Down Expand Up @@ -210,6 +211,7 @@ int g_rgCrstLevelMap[] =
3, // CrstLoaderHeap
3, // CrstManagedObjectWrapperMap
10, // CrstMethodDescBackpatchInfoTracker
-1, // CrstMethodSizeCache
-1, // CrstMethodTableExposedObject
5, // CrstModule
16, // CrstModuleFixup
Expand Down Expand Up @@ -333,6 +335,7 @@ LPCSTR g_rgCrstNameMap[] =
"CrstLoaderHeap",
"CrstManagedObjectWrapperMap",
"CrstMethodDescBackpatchInfoTracker",
"CrstMethodSizeCache",
"CrstMethodTableExposedObject",
"CrstModule",
"CrstModuleFixup",
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ bool isIntrinsic(
uint32_t getMethodAttribs(
CORINFO_METHOD_HANDLE ftn) override;

uint32_t getILSize(
CORINFO_METHOD_HANDLE ftn) override;

void setMethodAttribs(
CORINFO_METHOD_HANDLE ftn,
CorInfoMethodRuntimeFlags attribs) override;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/ICorJitInfo_API_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// and follow the instructions in docs/project/updating-jitinterface.md
DEF_CLR_API(isIntrinsic)
DEF_CLR_API(getMethodAttribs)
DEF_CLR_API(getILSize)
DEF_CLR_API(setMethodAttribs)
DEF_CLR_API(getMethodSig)
DEF_CLR_API(getMethodInfo)
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/jit/ICorJitInfo_API_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ uint32_t WrapICorJitInfo::getMethodAttribs(
return temp;
}

uint32_t WrapICorJitInfo::getILSize(
CORINFO_METHOD_HANDLE ftn)
{
API_ENTER(getILSize);
uint32_t temp = wrapHnd->getILSize(ftn);
API_LEAVE(getILSize);
return temp;
}

void WrapICorJitInfo::setMethodAttribs(
CORINFO_METHOD_HANDLE ftn,
CorInfoMethodRuntimeFlags attribs)
Expand Down
11 changes: 9 additions & 2 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3618,7 +3618,7 @@ void Compiler::compSetOptimizationLevel()

theMinOptsValue = false;

if (opts.compFlags == CLFLG_MINOPT)
if ((opts.compFlags & ~CLFLG_INLINING) == CLFLG_MINOPT)
{
JITLOG((LL_INFO100, "CLFLG_MINOPT set for method %s\n", info.compFullName));
theMinOptsValue = true;
Expand Down Expand Up @@ -3852,6 +3852,13 @@ void Compiler::compSetOptimizationLevel()
opts.compFlags |= CLFLG_MINOPT;
}

if (opts.IsTier0WithQuickOpts() &&
JitConfig.JitExtDefaultPolicy() == 1 &&
JitConfig.JitInlineTier0MaxIL() > 0)
{
opts.compFlags |= CLFLG_INLINING;
}

if (!compIsForInlining())
{
codeGen->setFramePointerRequired(false);
Expand Down Expand Up @@ -6419,7 +6426,7 @@ int Compiler::compCompileHelper(CORINFO_MODULE_HANDLE classPtr,
prejitResult.NoteBool(InlineObservation::CALLSITE_HAS_PROFILE, fgHaveSufficientProfileData());

// Do the initial inline screen.
impCanInlineIL(methodHnd, methodInfo, forceInline, &prejitResult);
impCanInlineIL(methodHnd, methodInfo, forceInline, opts.jitFlags->IsSet(JitFlags::JIT_FLAG_TIER0), &prejitResult);

// Temporarily install the prejitResult as the
// compInlineResult so it's available to fgFindJumpTargets
Expand Down
14 changes: 14 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4132,6 +4132,7 @@ class Compiler
void impCanInlineIL(CORINFO_METHOD_HANDLE fncHandle,
CORINFO_METHOD_INFO* methInfo,
bool forceInline,
bool isTier0,
InlineResult* inlineResult);

void impCheckCanInline(GenTreeCall* call,
Expand Down Expand Up @@ -5431,6 +5432,7 @@ class Compiler

bool fgMayExplicitTailCall();

void fgQuickPrescan(const BYTE* codeAddr, IL_OFFSET codeSize);
void fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, FixedBitVect* jumpTarget);

void fgMarkBackwardJump(BasicBlock* startBlock, BasicBlock* endBlock);
Expand Down Expand Up @@ -9190,6 +9192,18 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
}
#endif

bool IsTier0()
{
return jitFlags->IsSet(JitFlags::JIT_FLAG_TIER0);
}

bool IsTier0WithQuickOpts()
{
return jitFlags->IsSet(JitFlags::JIT_FLAG_TIER0) &&
!jitFlags->IsSet(JitFlags::JIT_FLAG_DEBUG_CODE) &&
!jitFlags->IsSet(JitFlags::JIT_FLAG_MIN_OPT);
}

// true if we should use the PINVOKE_{BEGIN,END} helpers instead of generating
// PInvoke transitions inline. Normally used by R2R, but also used when generating a reverse pinvoke frame, as
// the current logic for frame setup initializes and pushes
Expand Down
Loading

0 comments on commit eab2ff7

Please sign in to comment.