Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 13 additions & 4 deletions src/coreclr/nativeaot/Runtime/GcEnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,22 @@ static void GcEnumObject(PTR_PTR_Object ppObj, uint32_t flags, ScanFunc* fnGcEnu
//
assert((flags & ~(GC_CALL_INTERIOR | GC_CALL_PINNED)) == 0);

// for interior pointers, we optimize the case in which
// it points into the current threads stack area
//
if (flags & GC_CALL_INTERIOR)
if ((flags & GC_CALL_PINNED) && !pSc->promotion)
{
// Do nothing. This is the relocate phase, for something that was pinned. It does not need
// to be relocated.
}
else if (flags & GC_CALL_INTERIOR)
{
// for interior pointers, we optimize the case in which
// it points into the current threads stack area
//
PromoteCarefully(ppObj, flags, fnGcEnumRef, pSc);
}
else
{
fnGcEnumRef(ppObj, pSc, flags);
}
}

void EnumGcRef(PTR_OBJECTREF pRef, GCRefKind kind, ScanFunc* fnGcEnumRef, ScanContext* pSc)
Expand Down
19 changes: 15 additions & 4 deletions src/coreclr/vm/gcenv.ee.common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,24 @@ void GcEnumObject(LPVOID pData, OBJECTREF *pObj, uint32_t flags)
//
assert((flags & ~(GC_CALL_INTERIOR|GC_CALL_PINNED)) == 0);

// for interior pointers, we optimize the case in which
// it points into the current threads stack area
//
if (flags & GC_CALL_INTERIOR)
if ((flags & GC_CALL_PINNED) && !pCtx->sc->promotion)
{
// Do nothing. This is the relocate phase, for something that was pinned. It does not need
// to be relocated, and on interpreter builds, where we use conservative reporting in some situations,
// we MUST NOT attempt to do promotion here, as the GC is not expecting conservative reporting to report
// conservative roots during the relocate phase.
}
else if (flags & GC_CALL_INTERIOR)
{
// for interior pointers, we optimize the case in which
// it points into the current threads stack area
//
PromoteCarefully(pCtx->f, ppObj, pCtx->sc, flags);
}
else
{
(pCtx->f)(ppObj, pCtx->sc, flags);
}
}

//-----------------------------------------------------------------------------
Expand Down