Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9c15c1f
Allocate Type objects on Frozen Heap
EgorBo Sep 13, 2022
232033b
Mitigate perf regressions
EgorBo Sep 13, 2022
f63c941
clean up
EgorBo Sep 13, 2022
841e9c7
fix build issue?
EgorBo Sep 14, 2022
f168d13
Fix eeGetCPString for string literals in JitDisasm
EgorBo Sep 14, 2022
2f50121
Merge branch 'main' of github.com:dotnet/runtime into foh-type-objects
EgorBo Sep 14, 2022
3e6d3ba
clean up
EgorBo Sep 14, 2022
c939027
Merge branch 'main' of github.com:dotnet/runtime into foh-type-objects
EgorBo Sep 14, 2022
c8512a9
Update src/coreclr/jit/compiler.h
EgorBo Sep 17, 2022
bad7cc4
Merge branch 'main' of github.com:dotnet/runtime into foh-type-objects
EgorBo Sep 17, 2022
9d8526e
Address some of the feedback [WIP]
EgorBo Sep 17, 2022
18e1cd4
Address feedback
EgorBo Sep 17, 2022
a7fea6d
Fix compilation
EgorBo Sep 17, 2022
f2afedc
Introduce `objectToString` JIT-EE API
EgorBo Sep 17, 2022
6a8cedf
Update src/coreclr/vm/methodtable.cpp
EgorBo Sep 17, 2022
677f94b
check for unloadability in GetPinnedManagedClassObjectIfExists
EgorBo Sep 17, 2022
15bcad1
Merge branch 'foh-type-objects' of github.com:EgorBo/runtime-1 into f…
EgorBo Sep 17, 2022
81bacbb
Since I still have to check CanUnload I guess I don't need the bit test
EgorBo Sep 17, 2022
b5b7c98
Address feedback
EgorBo Sep 17, 2022
608e6c9
Add more temp debug checks for ci
EgorBo Sep 17, 2022
be063b8
Check if it reproduces because of jit
EgorBo Sep 18, 2022
59af88b
Check if it reproduces because of jit
EgorBo Sep 18, 2022
a8e0786
Ah, facepalm
EgorBo Sep 18, 2022
1f9a348
Clean up
EgorBo Sep 18, 2022
2fd4384
Address Jan's feedback
EgorBo Sep 18, 2022
8f2a767
Oops, a typo
EgorBo Sep 18, 2022
b4b7128
Share logic to extract OBJECTREF from m_hExposedClassObject
EgorBo Sep 18, 2022
a2ca5b1
Merge branch 'main' of github.com:dotnet/runtime into foh-type-objects
EgorBo Sep 19, 2022
fd099a2
Produce better asm code for JIT_GetRuntimeType
EgorBo Sep 19, 2022
64e7171
Merge branch 'main' of github.com:dotnet/runtime into foh-type-objects
EgorBo Sep 20, 2022
ac405a1
Merge branch 'main' of github.com:dotnet/runtime into foh-type-objects
EgorBo Sep 20, 2022
7ab7bd1
Address feedback
EgorBo Sep 20, 2022
895e9f5
Update src/coreclr/vm/jitinterface.cpp
EgorBo Sep 20, 2022
bcd47b1
Address feedback
EgorBo Sep 20, 2022
c217579
Update src/coreclr/vm/methodtable.cpp
EgorBo Sep 21, 2022
253747e
Address feedback: the bit is always there so we can do ` - 1`
EgorBo Sep 21, 2022
ca6c69a
Address feedback
EgorBo Sep 21, 2022
93ef525
Update src/coreclr/vm/methodtable.cpp
jkotas Sep 21, 2022
7394e1e
Update src/coreclr/jit/ee_il_dll.cpp
EgorBo Sep 21, 2022
f6055b9
remove null-termination from api
EgorBo Sep 21, 2022
57b1477
address feedback
EgorBo Sep 21, 2022
e9a396f
Address feedback
EgorBo Sep 21, 2022
4fbb894
Pass utf8 string in objectToString
EgorBo Sep 21, 2022
7476a68
remove char16_t left over
EgorBo Sep 21, 2022
bc2292b
fix compilation warning
EgorBo Sep 22, 2022
7bf7e0e
Update gentree.cpp
EgorBo Sep 22, 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
Prev Previous commit
Next Next commit
Address some of the feedback [WIP]
  • Loading branch information
EgorBo committed Sep 17, 2022
commit 9d8526e401b50ac91ad61cddc64aad43c08664db
5 changes: 0 additions & 5 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,6 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_CodeHeapReserveForJumpStubs, W("CodeHeapReserv
RETAIL_CONFIG_DWORD_INFO(INTERNAL_NGenReserveForJumpStubs, W("NGenReserveForJumpStubs"), 0, "Percentage of ngen image size 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
2 changes: 1 addition & 1 deletion src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3423,7 +3423,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
2 changes: 1 addition & 1 deletion src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11120,7 +11120,7 @@ void Compiler::gtDispConst(GenTree* tree)
}
else
{
assert(doesMethodHaveFrozenString());
assert(doesMethodHaveFrozenObjects());
printf(" 0x%llx", dspIconVal);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8163,7 +8163,7 @@ void Compiler::fgValueNumberTreeConst(GenTree* tree)
}
else
{
assert(doesMethodHaveFrozenString()); // Constant object can be only frozen string.
assert(doesMethodHaveFrozenObjects());
tree->gtVNPair.SetBoth(
vnStore->VNForHandle(ssize_t(tree->AsIntConCommon()->IconValue()), tree->GetIconHandleFlag()));
}
Expand Down
23 changes: 2 additions & 21 deletions src/coreclr/vm/frozenobjectheap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@

FrozenObjectHeapManager::FrozenObjectHeapManager():
m_Crst(CrstFrozenObjectHeap, CRST_UNSAFE_COOPGC),
m_CurrentSegment(nullptr),
m_Enabled(CLRConfig::GetConfigValue(CLRConfig::INTERNAL_UseFrozenObjectHeap) != 0)
m_CurrentSegment(nullptr)
{
}

// Allocates an object of the give size (including header) on a frozen segment.
// May return nullptr in the following cases:
// 1) DOTNET_UseFrozenObjectHeap is 0 (disabled)
// 2) Object is too large (large than FOH_COMMIT_SIZE)
// May return nullptr if object is too large (larger than FOH_COMMIT_SIZE)
// in such cases caller is responsible to find a more appropriate heap to allocate it
Object* FrozenObjectHeapManager::TryAllocateObject(PTR_MethodTable type, size_t objectSize)
{
Expand All @@ -37,12 +34,6 @@ Object* FrozenObjectHeapManager::TryAllocateObject(PTR_MethodTable type, size_t

CrstHolder ch(&m_Crst);

if (!m_Enabled)
{
// Disabled via DOTNET_UseFrozenObjectHeap=0
return nullptr;
}

_ASSERT(type != nullptr);
_ASSERT(FOH_COMMIT_SIZE >= MIN_OBJECT_SIZE);
_ASSERT(FOH_SEGMENT_SIZE > FOH_COMMIT_SIZE);
Expand Down Expand Up @@ -85,16 +76,6 @@ Object* FrozenObjectHeapManager::TryAllocateObject(PTR_MethodTable type, size_t
#endif // !FEATURE_BASICFREEZE
}

// Does object belong to a frozen segment?
bool FrozenObjectHeapManager::IsFromFrozenSegment(Object* object)
{
#ifdef FEATURE_BASICFREEZE
return GCHeapUtilities::GetGCHeap()->IsInFrozenSegment(object);
#else
return false;
#endif
}

FrozenObjectSegment::FrozenObjectSegment():
m_pStart(nullptr),
m_pCurrent(nullptr),
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/frozenobjectheap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ class FrozenObjectHeapManager
public:
FrozenObjectHeapManager();
Object* TryAllocateObject(PTR_MethodTable type, size_t objectSize);
bool IsFromFrozenSegment(Object* object);

private:
Crst m_Crst;
SArray<FrozenObjectSegment*> m_FrozenSegments;
FrozenObjectSegment* m_CurrentSegment;
bool m_Enabled;
};

class FrozenObjectSegment
Expand Down
11 changes: 6 additions & 5 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4232,14 +4232,14 @@ OBJECTREF MethodTable::GetManagedClassObject()
size_t objSize = g_pRuntimeTypeClass->GetBaseSize();
refClass = (REFLECTCLASSBASEREF)ObjectToOBJECTREF(foh->TryAllocateObject(g_pRuntimeTypeClass, objSize));
}

if (refClass == NULL)
else
{
refClass = (REFLECTCLASSBASEREF)AllocateObject(g_pRuntimeTypeClass);
((ReflectClassBaseObject*)OBJECTREFToObject(refClass))->SetKeepAlive(pLoaderAllocator->GetExposedObject());
}
_ASSERT(refClass != NULL);

((ReflectClassBaseObject*)OBJECTREFToObject(refClass))->SetType(TypeHandle(this));
((ReflectClassBaseObject*)OBJECTREFToObject(refClass))->SetKeepAlive(pLoaderAllocator->GetExposedObject());

// Let all threads fight over who wins using InterlockedCompareExchange.
// Only the winner can set m_ExposedClassObject from NULL.
Expand Down Expand Up @@ -4272,8 +4272,9 @@ OBJECTREF MethodTable::GetManagedClassObject(bool* pIsPinned)
GCPROTECT_BEGIN(objRef);

objRef = GetManagedClassObject();
FrozenObjectHeapManager* foh = SystemDomain::GetFrozenObjectHeapManager();
*pIsPinned = foh->IsFromFrozenSegment(OBJECTREFToObject(objRef));

// Type objects in non-unloadable contexts are always "pinned" (allocated on FOH)
*pIsPinned = this->GetLoaderAllocator()->IsUnloaded();

GCPROTECT_END();

Expand Down