Revert ZeroGC: stop depending on MethodTable internal layout for IsLargeObject (#3298) - #3299
Merged
kkokosa merged 1 commit intoAug 5, 2026
Conversation
…argeObject (dotnet#3298)" This reverts commit 6660078.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reverts #3298 ("ZeroGC: stop depending on MethodTable internal layout for IsLargeObject"), restoring the original
pObj->GetGCSafeMethodTable()->GetBaseSize() >= LARGE_OBJECT_SIZEimplementation ofIsLargeObject.Why
Per review discussion on #3298: the GC/EE data-layout contract is versioned in a structured way, not just by convention.
LARGE_OBJECT_SIZE(85,000 bytes) is a public constant from the versionedgcinterface.h- safe to depend on regardless.MethodTable::Collectible()'s flag bit remap (Converge Representations between NativeAOT and CoreCLR runtime#91821) - bumpedEE_INTERFACE_MAJOR_VERSION1→2 in that same PR.gcenv.object.h's existing shim (g_oldMethodTableFlags), which ZeroGC'sdllmain.cppalready plugs into (g_runtimeSupportedVersion.MajorVersion < 2), branches on exactly that signal. So this kind of layout drift is covered by a real, numbered contract, not just convention.MethodTable::GetBaseSize()itself has never needed such a compatibility shim.MethodTable/Objectlayout anyway - those types are mandatory for theIGCHeapinterface signatures it implements. Removing this one call site didn't reduce ZeroGC's actual exposure to layout drift.Net effect of #3298 was added ongoing cost (a
std::map+ critical section on every LOH-sized allocation) without closing off a real risk. This PR reverts it back to the simpler, original implementation.Testing
src/ZeroGC/native/build.ps1.ZeroGCHeap.cppis empty (exact revert, no residual changes).