Skip to content

Commit

Permalink
Create final IG before clearing GC info
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceForstall committed Jan 20, 2024
1 parent d01f784 commit fca4c50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/coreclr/jit/codegenlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,28 +835,29 @@ void CodeGen::genCodeForBBlist()
#endif // DEBUG
} //------------------ END-FOR each block of the method -------------------

// There could be variables alive at this point. For example see lvaKeepAliveAndReportThis.
// This call is for cleaning the GC refs
genUpdateLife(VarSetOps::MakeEmpty(compiler));

#if !defined(FEATURE_EH_FUNCLETS)
// If this is a synchronized method on x86, and we generated all the code without
// generating the "exit monitor" call, then we must have deleted the single return block
// with that call because it was dead code. We still need to report the monitor range
// to the VM in the GC info, so create a label at the very end so we have a marker for
// the monitor end range.
//
// Do this before cleaning the GC refs below; we don't want to create an IG that clears
// the `this` pointer for lvaKeepAliveAndReportThis.

if ((compiler->info.compFlags & CORINFO_FLG_SYNCH) && (compiler->syncEndEmitCookie == nullptr))
{
JITDUMP("Synchronized method with missing exit monitor call; adding final label\n");

// The GC liveness sets should all be empty.
compiler->syncEndEmitCookie =
GetEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur);
noway_assert(compiler->syncEndEmitCookie != nullptr);
}
#endif // !FEATURE_EH_FUNCLETS

// There could be variables alive at this point. For example see lvaKeepAliveAndReportThis.
// This call is for cleaning the GC refs
genUpdateLife(VarSetOps::MakeEmpty(compiler));

/* Finalize the spill tracking logic */

regSet.rsSpillEnd();
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2320,7 +2320,7 @@ inline void LclVarDsc::incRefCnts(weight_t weight, Compiler* comp, RefCountState

inline bool Compiler::lvaKeepAliveAndReportThis()
{
if (info.compIsStatic || lvaTable[0].TypeGet() != TYP_REF)
if (info.compIsStatic || (lvaTable[0].TypeGet() != TYP_REF))
{
return false;
}
Expand Down Expand Up @@ -2354,7 +2354,7 @@ inline bool Compiler::lvaKeepAliveAndReportThis()
// We keep it alive in the lookup scenario, even when the VM didn't ask us to,
// because collectible types need the generics context when gc-ing.
//
// Methoods that can inspire OSR methods must always report context as live
// Methods that can inspire OSR methods must always report context as live
//
if (genericsContextIsThis)
{
Expand Down

0 comments on commit fca4c50

Please sign in to comment.