Skip to content

Commit

Permalink
Cleanup comments and ifdefs around this_OFFSET_FLAG (#99092)
Browse files Browse the repository at this point in the history
Contributes to
#35748 (comment)
  • Loading branch information
jkotas authored Mar 1, 2024
1 parent 8806af9 commit 9863bf1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/coreclr/inc/gcinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@
#include "daccess.h"
#include "windef.h" // For BYTE

// Some declarations in this file are used on non-x86 platforms, but most are x86-specific.

// Use the lower 2 bits of the offsets stored in the tables
// to encode properties

const unsigned OFFSET_MASK = 0x3; // mask to access the low 2 bits

//
// Note for untracked locals the flags allowed are "pinned" and "byref"
// and for tracked locals the flags allowed are "this" and "byref"
// Note that these definitions should also match the definitions of
// GC_CALL_INTERIOR and GC_CALL_PINNED in VM/gc.h
//
const unsigned byref_OFFSET_FLAG = 0x1; // the offset is an interior ptr
const unsigned pinned_OFFSET_FLAG = 0x2; // the offset is a pinned ptr
#if !defined(TARGET_X86) || !defined(FEATURE_EH_FUNCLETS)
#if defined(TARGET_X86) && !defined(FEATURE_EH_FUNCLETS)
// JIT32_ENCODER has additional restriction on x86 without funclets:
// - for untracked locals the flags allowed are "pinned" and "byref"
// - for tracked locals the flags allowed are "this" and "byref"
const unsigned this_OFFSET_FLAG = 0x2; // the offset is "this"
#endif

Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8609,9 +8609,10 @@ void emitter::emitGCvarLiveSet(int offs, GCtype gcType, BYTE* addr, ssize_t disp

desc->vpdNext = nullptr;

#if !defined(JIT32_GCENCODER) || !defined(FEATURE_EH_FUNCLETS)
/* the lower 2 bits encode props about the stk ptr */
CLANG_FORMAT_COMMENT_ANCHOR;

#if defined(JIT32_GCENCODER) && !defined(FEATURE_EH_FUNCLETS)
if (offs == emitSyncThisObjOffs)
{
desc->vpdVarNum |= this_OFFSET_FLAG;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/gcencode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4698,7 +4698,7 @@ void GCInfo::gcMakeVarPtrTable(GcInfoEncoder* gcInfoEncoder, MakeRegPtrMode mode
// unused by alignment
C_ASSERT((OFFSET_MASK + 1) <= sizeof(int));

#ifdef DEBUG
#if defined(DEBUG) && defined(JIT32_GCENCODER) && !defined(FEATURE_EH_FUNCLETS)
if (mode == MAKE_REG_PTR_MODE_ASSIGN_SLOTS)
{
// Tracked variables can't be pinned, and the encoding takes
Expand All @@ -4712,7 +4712,7 @@ void GCInfo::gcMakeVarPtrTable(GcInfoEncoder* gcInfoEncoder, MakeRegPtrMode mode
assert((flags & this_OFFSET_FLAG) == 0);
}
}
#endif // DEBUG
#endif

// Only need to do this once, and only if we have EH.
if ((mode == MAKE_REG_PTR_MODE_ASSIGN_SLOTS) && compiler->ehAnyFunclets())
Expand Down

0 comments on commit 9863bf1

Please sign in to comment.