Skip to content

Commit 50adb34

Browse files
committed
Partial re-revert of dotnet#104336. Only JIT fixes are included.
1 parent 1dffab5 commit 50adb34

File tree

5 files changed

+13
-32
lines changed

5 files changed

+13
-32
lines changed

src/coreclr/jit/codegencommon.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,29 +1517,6 @@ void CodeGen::genExitCode(BasicBlock* block)
15171517
if (compiler->getNeedsGSSecurityCookie())
15181518
{
15191519
genEmitGSCookieCheck(jmpEpilog);
1520-
1521-
if (jmpEpilog)
1522-
{
1523-
// Dev10 642944 -
1524-
// The GS cookie check created a temp label that has no live
1525-
// incoming GC registers, we need to fix that
1526-
1527-
unsigned varNum;
1528-
LclVarDsc* varDsc;
1529-
1530-
/* Figure out which register parameters hold pointers */
1531-
1532-
for (varNum = 0, varDsc = compiler->lvaTable; varNum < compiler->lvaCount && varDsc->lvIsRegArg;
1533-
varNum++, varDsc++)
1534-
{
1535-
noway_assert(varDsc->lvIsParam);
1536-
1537-
gcInfo.gcMarkRegPtrVal(varDsc->GetArgReg(), varDsc->TypeGet());
1538-
}
1539-
1540-
GetEmitter()->emitThisGCrefRegs = GetEmitter()->emitInitGCrefRegs = gcInfo.gcRegGCrefSetCur;
1541-
GetEmitter()->emitThisByrefRegs = GetEmitter()->emitInitByrefRegs = gcInfo.gcRegByrefSetCur;
1542-
}
15431520
}
15441521

15451522
genReserveEpilog(block);

src/coreclr/jit/emit.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10427,9 +10427,9 @@ regMaskTP emitter::emitGetGCRegsKilledByNoGCCall(CorInfoHelpFunc helper)
1042710427
// of the last instruction in the region makes GC safe again.
1042810428
// In particular - once the IP is on the first instruction, but not executed it yet,
1042910429
// it is still safe to do GC.
10430-
// The only special case is when NoGC region is used for prologs/epilogs.
10431-
// In such case the GC info could be incorrect until the prolog completes and epilogs
10432-
// may have unwindability restrictions, so the first instruction cannot have GC.
10430+
// The only special case is when NoGC region is used for prologs.
10431+
// In such case the GC info could be incorrect until the prolog completes, so the first
10432+
// instruction cannot have GC.
1043310433

1043410434
void emitter::emitDisableGC()
1043510435
{

src/coreclr/jit/emitinl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,7 @@ bool emitter::emitGenNoGCLst(Callback& cb)
594594
emitter::instrDesc* id = emitFirstInstrDesc(ig->igData);
595595
assert(id != nullptr);
596596
assert(id->idCodeSize() > 0);
597-
if (!cb(ig->igFuncIdx, ig->igOffs, ig->igSize, id->idCodeSize(),
598-
ig->igFlags & (IGF_FUNCLET_PROLOG | IGF_FUNCLET_EPILOG | IGF_EPILOG)))
597+
if (!cb(ig->igFuncIdx, ig->igOffs, ig->igSize, id->idCodeSize(), ig->igFlags & (IGF_FUNCLET_PROLOG)))
599598
{
600599
return false;
601600
}

src/coreclr/jit/gcencode.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4027,8 +4027,7 @@ class InterruptibleRangeReporter
40274027
// Report everything between the previous region and the current
40284028
// region as interruptible.
40294029

4030-
bool operator()(
4031-
unsigned igFuncIdx, unsigned igOffs, unsigned igSize, unsigned firstInstrSize, bool isInPrologOrEpilog)
4030+
bool operator()(unsigned igFuncIdx, unsigned igOffs, unsigned igSize, unsigned firstInstrSize, bool isInProlog)
40324031
{
40334032
if (igOffs < m_uninterruptibleEnd)
40344033
{
@@ -4042,9 +4041,9 @@ class InterruptibleRangeReporter
40424041
if (igOffs > m_uninterruptibleEnd)
40434042
{
40444043
// Once the first instruction in IG executes, we cannot have GC.
4045-
// But it is ok to have GC while the IP is on the first instruction, unless we are in prolog/epilog.
4044+
// But it is ok to have GC while the IP is on the first instruction, unless we are in prolog.
40464045
unsigned interruptibleEnd = igOffs;
4047-
if (!isInPrologOrEpilog)
4046+
if (!isInProlog)
40484047
{
40494048
interruptibleEnd += firstInstrSize;
40504049
}

src/coreclr/nativeaot/Runtime/thread.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,16 @@ void Thread::HijackCallback(NATIVE_CONTEXT* pThreadContext, void* pThreadToHijac
675675
if (runtime->IsConservativeStackReportingEnabled() ||
676676
codeManager->IsSafePoint(pvAddress))
677677
{
678+
// IsUnwindable is precise on arm64, but can give false negatives on other architectures.
679+
// (when IP is on the first instruction of an epilog, we still can unwind,
680+
// but we can tell if the instruction is the first only if we can navigate instructions backwards and check)
681+
// The preciseness of IsUnwindable is tracked in https://github.com/dotnet/runtime/issues/101932
682+
#if defined(TARGET_ARM64)
678683
// we may not be able to unwind in some locations, such as epilogs.
679684
// such locations should not contain safe points.
680685
// when scanning conservatively we do not need to unwind
681686
ASSERT(codeManager->IsUnwindable(pvAddress) || runtime->IsConservativeStackReportingEnabled());
687+
#endif
682688

683689
// if we are not given a thread to hijack
684690
// perform in-line wait on the current thread

0 commit comments

Comments
 (0)