Skip to content

Commit

Permalink
no need to search for safepoints when asked only for interruptibility
Browse files Browse the repository at this point in the history
  • Loading branch information
VSadov committed Dec 19, 2023
1 parent 14ef9e1 commit 05b269b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/inc/gcinfotypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ inline UINT32 CeilOfLog2(size_t x)
return (UINT32)result;
#else // _MSC_VER
// LZCNT returns index starting from MSB, whereas BSR gives the index from LSB.
// 63 ^ BSR here is equivalent to 63 - BSR since the BSR result is always between 0 and 63.
// 63 ^ LZCNT here is equivalent to 63 - LZCNT since the LZCNT result is always between 0 and 63.
// This saves an instruction, as subtraction from constant requires either MOV/SUB or NEG/ADD.
return (UINT32)63 ^ (UINT32)__builtin_clzl((unsigned long)x);
#endif // _MSC_VER
Expand Down
9 changes: 3 additions & 6 deletions src/coreclr/vm/gcinfodecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ GcInfoDecoder::GcInfoDecoder(

#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED
m_NumSafePoints = (UINT32) DENORMALIZE_NUM_SAFE_POINTS(m_Reader.DecodeVarLengthUnsigned(NUM_SAFE_POINTS_ENCBASE));
m_SafePointIndex = m_NumSafePoints;
#endif

if (slimHeader)
Expand All @@ -362,18 +363,14 @@ GcInfoDecoder::GcInfoDecoder(
}

#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED
if(flags & (DECODE_INTERRUPTIBILITY | DECODE_GC_LIFETIMES))
if(flags & (DECODE_GC_LIFETIMES))
{
if(m_NumSafePoints)
{
m_SafePointIndex = FindSafePoint(m_InstructionOffset);
}
else
{
m_SafePointIndex = 0;
}
}
else if(flags & DECODE_FOR_RANGES_CALLBACK)
else if(flags & (DECODE_FOR_RANGES_CALLBACK | DECODE_INTERRUPTIBILITY))
{
// Note that normalization as a code offset can be different than
// normalization as code length
Expand Down

0 comments on commit 05b269b

Please sign in to comment.