Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert frozen RuntimeType objects and write barriers for frozen objects" #76649

Merged
merged 29 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
810171d
Revert "Revert "Allocate RuntimeType objects on Frozen Object Heap (#…
EgorBo Oct 5, 2022
e0737c0
Regenerate generated files (JIT-EE, CRST)
EgorBo Oct 5, 2022
aadadc6
fix nativeaot compilation
EgorBo Oct 5, 2022
ecc25ea
Address feedback
EgorBo Oct 5, 2022
1d95438
Merge branch 'main' of github.com:dotnet/runtime into foh-frozen-types-2
EgorBo Oct 5, 2022
1e32f9c
Address feedback
EgorBo Oct 5, 2022
19e1d79
Remove == -1 check
EgorBo Oct 5, 2022
5a54c51
Update src/coreclr/vm/jitinterface.cpp
EgorBo Oct 5, 2022
c144fa4
Rename to printObjectDescription
EgorBo Oct 5, 2022
34c45aa
Address feedback
EgorBo Oct 5, 2022
a07ab89
Address feedback
EgorBo Oct 5, 2022
5adff12
Update CorInfoImpl.cs
EgorBo Oct 5, 2022
26c43d9
Update ee_il_dll.cpp
EgorBo Oct 5, 2022
1b910df
Address Jan's feedback
EgorBo Oct 5, 2022
31772b3
Fix methodcontext.cpp
EgorBo Oct 5, 2022
b5fd562
Fix comments
EgorBo Oct 5, 2022
45d7673
Apply suggestions from code review
EgorBo Oct 5, 2022
c639b79
Address feedback
EgorBo Oct 6, 2022
cece178
Update src/coreclr/vm/jitinterface.cpp
EgorBo Oct 6, 2022
6d2cac3
Do the same for crossgen/nativeaot
EgorBo Oct 6, 2022
05cc624
Update src/coreclr/vm/jitinterface.cpp
EgorBo Oct 6, 2022
2ea47b9
Update src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
EgorBo Oct 6, 2022
606086a
Apply suggestions from code review
EgorBo Oct 6, 2022
513a8b9
fix build
EgorBo Oct 6, 2022
e0c51fd
Fix build error on 32bit
EgorBo Oct 6, 2022
d2e1e39
Address feedback
EgorBo Oct 6, 2022
dd4ec29
Merge branch 'main' of github.com:dotnet/runtime into foh-frozen-types-2
EgorBo Oct 6, 2022
12320c4
Update src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
EgorBo Oct 6, 2022
2660380
fix compilation
EgorBo Oct 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/coreclr/inc/CrstTypes.def
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ Crst FCall
End

Crst FrozenObjectHeap
Unordered
End

Crst MethodTableExposedObject
Unordered
End

Crst RetThunkCache
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,6 @@ CONFIG_DWORD_INFO(INTERNAL_LoaderHeapCallTracing, W("LoaderHeapCallTracing"), 0,
RETAIL_CONFIG_DWORD_INFO(INTERNAL_CodeHeapReserveForJumpStubs, W("CodeHeapReserveForJumpStubs"), 1, "Percentage of code heap to reserve for jump stubs")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_BreakOnOutOfMemoryWithinRange, W("BreakOnOutOfMemoryWithinRange"), 0, "Break before out of memory within range exception is thrown")

///
/// Frozen segments (aka Frozen Object Heap)
///
RETAIL_CONFIG_DWORD_INFO(INTERNAL_UseFrozenObjectHeap, W("UseFrozenObjectHeap"), 1, "Use frozen object heap for certain types of objects (e.g. string literals) as an optimization.")

///
/// Log
///
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2265,6 +2265,13 @@ class ICorStaticInfo
int bufferSize /* IN */
) = 0;

// Calls ToString() for given pinned/frozen object handle
virtual int objectToString (
void* handle, /* IN */
char* buffer, /* OUT */
int bufferSize /* IN */
) = 0;

/**********************************************************************************/
//
// ICorClassInfo
Expand Down Expand Up @@ -2475,6 +2482,10 @@ class ICorStaticInfo
CORINFO_CLASS_HANDLE cls
) = 0;

virtual void* getRuntimeTypePointer(
CORINFO_CLASS_HANDLE cls
) = 0;

virtual bool getReadyToRunHelper(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_LOOKUP_KIND * pGenericLookupKind,
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,58 +81,59 @@ enum CrstType
CrstLoaderHeap = 63,
CrstManagedObjectWrapperMap = 64,
CrstMethodDescBackpatchInfoTracker = 65,
CrstModule = 66,
CrstModuleFixup = 67,
CrstModuleLookupTable = 68,
CrstMulticoreJitHash = 69,
CrstMulticoreJitManager = 70,
CrstNativeImageEagerFixups = 71,
CrstNativeImageLoad = 72,
CrstNls = 73,
CrstNotifyGdb = 74,
CrstObjectList = 75,
CrstPEImage = 76,
CrstPendingTypeLoadEntry = 77,
CrstPgoData = 78,
CrstPinnedByrefValidation = 79,
CrstPinnedHeapHandleTable = 80,
CrstProfilerGCRefDataFreeList = 81,
CrstProfilingAPIStatus = 82,
CrstRCWCache = 83,
CrstRCWCleanupList = 84,
CrstReadyToRunEntryPointToMethodDescMap = 85,
CrstReflection = 86,
CrstReJITGlobalRequest = 87,
CrstRetThunkCache = 88,
CrstSavedExceptionInfo = 89,
CrstSaveModuleProfileData = 90,
CrstSecurityStackwalkCache = 91,
CrstSigConvert = 92,
CrstSingleUseLock = 93,
CrstSpecialStatics = 94,
CrstStackSampler = 95,
CrstStressLog = 96,
CrstStubCache = 97,
CrstStubDispatchCache = 98,
CrstStubUnwindInfoHeapSegments = 99,
CrstSyncBlockCache = 100,
CrstSyncHashLock = 101,
CrstSystemBaseDomain = 102,
CrstSystemDomain = 103,
CrstSystemDomainDelayedUnloadList = 104,
CrstThreadIdDispenser = 105,
CrstThreadStore = 106,
CrstTieredCompilation = 107,
CrstTypeEquivalenceMap = 108,
CrstTypeIDMap = 109,
CrstUMEntryThunkCache = 110,
CrstUMEntryThunkFreeListLock = 111,
CrstUniqueStack = 112,
CrstUnresolvedClassLock = 113,
CrstUnwindInfoTableLock = 114,
CrstVSDIndirectionCellLock = 115,
CrstWrapperTemplate = 116,
kNumberOfCrstTypes = 117
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
};

#endif // __CRST_TYPES_INCLUDED
Expand Down Expand Up @@ -180,7 +181,7 @@ int g_rgCrstLevelMap[] =
0, // CrstExecuteManRangeLock
0, // CrstExternalObjectContextCache
4, // CrstFCall
0, // CrstFrozenObjectHeap
-1, // CrstFrozenObjectHeap
7, // CrstFuncPtrStubs
10, // CrstFusionAppCtx
10, // CrstGCCover
Expand Down Expand Up @@ -209,6 +210,7 @@ int g_rgCrstLevelMap[] =
3, // CrstLoaderHeap
3, // CrstManagedObjectWrapperMap
10, // CrstMethodDescBackpatchInfoTracker
-1, // CrstMethodTableExposedObject
5, // CrstModule
16, // CrstModuleFixup
4, // CrstModuleLookupTable
Expand Down Expand Up @@ -331,6 +333,7 @@ LPCSTR g_rgCrstNameMap[] =
"CrstLoaderHeap",
"CrstManagedObjectWrapperMap",
"CrstMethodDescBackpatchInfoTracker",
"CrstMethodTableExposedObject",
"CrstModule",
"CrstModuleFixup",
"CrstModuleLookupTable",
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ int getStringLiteral(
char16_t* buffer,
int bufferSize) override;

int objectToString(
void* handle,
char* buffer,
int bufferSize) override;

CorInfoType asCorInfoType(
CORINFO_CLASS_HANDLE cls) override;

Expand Down Expand Up @@ -280,6 +285,9 @@ CorInfoHelpFunc getBoxHelper(
CorInfoHelpFunc getUnBoxHelper(
CORINFO_CLASS_HANDLE cls) override;

void* getRuntimeTypePointer(
CORINFO_CLASS_HANDLE cls) override;

bool getReadyToRunHelper(
CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_LOOKUP_KIND* pGenericLookupKind,
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* eb8352bd-0a13-4b5b-badb-58f9ecc40c44 */
0xeb8352bd,
0x0a13,
0x4b5b,
{0xba, 0xdb, 0x58, 0xf9, 0xec, 0xc4, 0x0c, 0x44}
constexpr GUID JITEEVersionIdentifier = { /* 3f5e4630-b29a-4aeb-bab7-07bdff43a156 */
0x3f5e4630,
0xb29a,
0x4aeb,
{0xba, 0xb7, 0x7, 0xbd, 0xff, 0x43, 0xa1, 0x56}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/ICorJitInfo_API_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ DEF_CLR_API(getTokenTypeAsHandle)
DEF_CLR_API(isValidToken)
DEF_CLR_API(isValidStringRef)
DEF_CLR_API(getStringLiteral)
DEF_CLR_API(objectToString)
DEF_CLR_API(asCorInfoType)
DEF_CLR_API(getClassName)
DEF_CLR_API(getClassNameFromMetadata)
Expand Down Expand Up @@ -70,6 +71,7 @@ DEF_CLR_API(getSharedCCtorHelper)
DEF_CLR_API(getTypeForBox)
DEF_CLR_API(getBoxHelper)
DEF_CLR_API(getUnBoxHelper)
DEF_CLR_API(getRuntimeTypePointer)
DEF_CLR_API(getReadyToRunHelper)
DEF_CLR_API(getReadyToRunDelegateCtorHelper)
DEF_CLR_API(getHelperName)
Expand Down
20 changes: 20 additions & 0 deletions src/coreclr/jit/ICorJitInfo_API_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@ int WrapICorJitInfo::getStringLiteral(
return temp;
}

int WrapICorJitInfo::objectToString(
void* handle,
char* buffer,
int bufferSize)
{
API_ENTER(objectToString);
int temp = wrapHnd->objectToString(handle, buffer, bufferSize);
API_LEAVE(objectToString);
return temp;
}

CorInfoType WrapICorJitInfo::asCorInfoType(
CORINFO_CLASS_HANDLE cls)
{
Expand Down Expand Up @@ -652,6 +663,15 @@ CorInfoHelpFunc WrapICorJitInfo::getUnBoxHelper(
return temp;
}

void* WrapICorJitInfo::getRuntimeTypePointer(
CORINFO_CLASS_HANDLE cls)
{
API_ENTER(getRuntimeTypePointer);
void* temp = wrapHnd->getRuntimeTypePointer(cls);
API_LEAVE(getRuntimeTypePointer);
return temp;
}

bool WrapICorJitInfo::getReadyToRunHelper(
CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_LOOKUP_KIND* pGenericLookupKind,
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ void Compiler::optDebugCheckAssertion(AssertionDsc* assertion)
break;
case O1K_LCLVAR:
assert((lvaGetDesc(assertion->op1.lcl.lclNum)->lvType != TYP_REF) ||
(assertion->op2.u1.iconVal == 0) || doesMethodHaveFrozenString());
(assertion->op2.u1.iconVal == 0) || doesMethodHaveFrozenObjects());
break;
case O1K_VALUE_NUMBER:
assert((vnStore->TypeOfVN(assertion->op1.vn) != TYP_REF) || (assertion->op2.u1.iconVal == 0));
Expand Down Expand Up @@ -3408,7 +3408,7 @@ GenTree* Compiler::optConstantAssertionProp(AssertionDsc* curAssertion,

// Make sure we don't retype const gc handles to TYP_I_IMPL
// Although, it's possible for e.g. GTF_ICON_STATIC_HDL
if (!newTree->IsIntegralConst(0) && newTree->IsIconHandle(GTF_ICON_STR_HDL))
if (!newTree->IsIntegralConst(0) && newTree->IsIconHandle(GTF_ICON_OBJ_HDL))
{
if (tree->TypeIs(TYP_BYREF))
{
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9415,6 +9415,11 @@ void cTreeFlags(Compiler* comp, GenTree* tree)
chars += printf("[ICON_STR_HDL]");
break;

case GTF_ICON_OBJ_HDL:

chars += printf("[ICON_OBJ_HDL]");
break;

case GTF_ICON_CONST_PTR:

chars += printf("[ICON_CONST_PTR]");
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6804,7 +6804,7 @@ class Compiler
#define OMF_HAS_EXPRUNTIMELOOKUP 0x00000080 // Method contains a runtime lookup to an expandable dictionary.
#define OMF_HAS_PATCHPOINT 0x00000100 // Method contains patchpoints
#define OMF_NEEDS_GCPOLLS 0x00000200 // Method needs GC polls
#define OMF_HAS_FROZEN_STRING 0x00000400 // Method has a frozen string (REF constant int), currently only on NativeAOT.
#define OMF_HAS_FROZEN_OBJECTS 0x00000400 // Method has frozen objects (REF constant int)
#define OMF_HAS_PARTIAL_COMPILATION_PATCHPOINT 0x00000800 // Method contains partial compilation patchpoints
#define OMF_HAS_TAILCALL_SUCCESSOR 0x00001000 // Method has potential tail call in a non BBJ_RETURN block
#define OMF_HAS_MDNEWARRAY 0x00002000 // Method contains 'new' of an MD array
Expand All @@ -6829,14 +6829,14 @@ class Compiler

void addFatPointerCandidate(GenTreeCall* call);

bool doesMethodHaveFrozenString() const
bool doesMethodHaveFrozenObjects() const
{
return (optMethodFlags & OMF_HAS_FROZEN_STRING) != 0;
return (optMethodFlags & OMF_HAS_FROZEN_OBJECTS) != 0;
}

void setMethodHasFrozenString()
void setMethodHasFrozenObjects()
{
optMethodFlags |= OMF_HAS_FROZEN_STRING;
optMethodFlags |= OMF_HAS_FROZEN_OBJECTS;
}

bool doesMethodHaveGuardedDevirtualization() const
Expand Down Expand Up @@ -7801,7 +7801,7 @@ class Compiler
const char* eeGetFieldName(CORINFO_FIELD_HANDLE fieldHnd, const char** classNamePtr = nullptr);

#if defined(DEBUG)
const WCHAR* eeGetCPString(size_t stringHandle);
void eePrintFrozenObjectDescription(const char* prefix, size_t handle);
unsigned eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd);
const char16_t* eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd);
#endif
Expand Down
Loading