From 4ee0f2533c104480dbdde27ee1c30464fd416d90 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 17 Oct 2025 10:54:24 -0700 Subject: [PATCH 1/2] Remote unused bitmask types --- src/coreclr/inc/bitmask.h | 102 ------------- src/coreclr/inc/bitmask.inl | 291 ------------------------------------ src/coreclr/vm/ceeload.h | 1 - 3 files changed, 394 deletions(-) delete mode 100644 src/coreclr/inc/bitmask.h delete mode 100644 src/coreclr/inc/bitmask.inl diff --git a/src/coreclr/inc/bitmask.h b/src/coreclr/inc/bitmask.h deleted file mode 100644 index f8dddb313398eb..00000000000000 --- a/src/coreclr/inc/bitmask.h +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// - -// -------------------------------------------------------------------------------- -// BitMask.h -// -------------------------------------------------------------------------------- - -// -------------------------------------------------------------------------------- -// BitMask is an arbitrarily large sized bitfield which has optimal storage -// for 32 bits or less. -// Storage is proportional to the highest index which is set. -// -------------------------------------------------------------------------------- - - -#include - -#ifndef _BITMASK_H_ -#define _BITMASK_H_ - -class BitMask -{ - public: - - BitMask(); - ~BitMask(); - - BOOL TestBit(int bit); - void SetBit(int bit); - void ClearBit(int bit); - - // returns true if any bit is set - BOOL TestAnyBit(); - - void ClearAllBits(); - - // Allocation exposed for ngen save/fixup - size_t GetAllocatedBlockOffset(); - void *GetAllocatedBlock(); - COUNT_T GetAllocatedBlockSize(); - - private: - - static const int BIT_SIZE_SHIFT = 5; - static const int BIT_SIZE = (1<writer so be very careful - // when taking this lock else you might deadlock your own thread! - SimpleRWLock m_bitMaskLock; -}; - -#include - -#endif // _BITMASK_H_ diff --git a/src/coreclr/inc/bitmask.inl b/src/coreclr/inc/bitmask.inl deleted file mode 100644 index 9bdd60827f4f5d..00000000000000 --- a/src/coreclr/inc/bitmask.inl +++ /dev/null @@ -1,291 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// - -// -------------------------------------------------------------------------------- -// BitMask.inl -// -------------------------------------------------------------------------------- - -#include - -#ifndef _BITMASK_INL_ -#define _BITMASK_INL_ - -inline BOOL BitMask::IsArray() -{ - LIMITED_METHOD_CONTRACT; - return (m_mask&1) == 0; -} - -// Indexing computations -inline COUNT_T BitMask::BitToIndex(int bit) -{ - LIMITED_METHOD_CONTRACT; - // First word has one less bit due to tag - return (bit+1) >> BIT_SIZE_SHIFT; -} - -inline COUNT_T BitMask::BitToShift(int bit) -{ - LIMITED_METHOD_CONTRACT; - // First word has one less bit due to tag - return (bit+1) & BIT_SIZE_MASK; -} - -// Array access. Note the first array element is the count of the -// rest of the elements - -inline COUNT_T *BitMask::GetMaskArray() -{ - LIMITED_METHOD_CONTRACT; - if (IsArray()) - { - CONSISTENCY_CHECK(CheckPointer(m_maskArray)); - return m_maskArray+1; - } - else - return &m_mask; -} - -inline COUNT_T BitMask::GetMaskArraySize() -{ - LIMITED_METHOD_CONTRACT; - if (IsArray()) - return *m_maskArray; - else - return 1; -} - -inline void BitMask::GrowArray(COUNT_T newSize) -{ - CONTRACTL - { - THROWS; - } - CONTRACTL_END; - - // Ensure we don't grow too often - - COUNT_T oldSize = GetMaskArraySize(); - if (newSize <= oldSize) - return; - - if (newSize < oldSize*2) - newSize = oldSize*2; - if (newSize < MIN_ARRAY_ALLOCATION) - newSize = MIN_ARRAY_ALLOCATION; - - // Allocate new array - - COUNT_T *newArray = new COUNT_T [newSize+1]; - *newArray = newSize; - - CopyMemory(newArray+1, GetMaskArray(), oldSize * sizeof(COUNT_T)); - ZeroMemory(newArray+oldSize+1, (newSize - oldSize) * sizeof(COUNT_T)); - - if (IsArray()) - delete [] m_maskArray; - - m_maskArray = newArray; -} - -inline BitMask::BitMask() - : m_mask(1) -{ - LIMITED_METHOD_CONTRACT; -} - -inline BitMask::~BitMask() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - delete [] m_maskArray; -} - -inline BOOL BitMask::TestBit(int bit) -{ - LIMITED_METHOD_CONTRACT; - - COUNT_T index = BitToIndex(bit); - - if (index >= GetMaskArraySize()) - return FALSE; - - return ( GetMaskArray()[index] >> BitToShift(bit) ) & 1; -} - -inline void BitMask::SetBit(int bit) -{ - CONTRACTL - { - THROWS; - } - CONTRACTL_END; - - COUNT_T index = BitToIndex(bit); - - if (index >= GetMaskArraySize()) - GrowArray(index+1); - - GetMaskArray()[index] |= (1 << BitToShift(bit)); -} - -inline void BitMask::ClearBit(int bit) -{ - LIMITED_METHOD_CONTRACT; - - COUNT_T index = BitToIndex(bit); - - if (index >= GetMaskArraySize()) - return; - - GetMaskArray()[index] &= ~(1 << BitToShift(bit)); -} - -inline BOOL BitMask::TestAnyBit() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - { - COUNT_T *mask = m_maskArray+1; - COUNT_T *maskEnd = mask + m_maskArray[0]; - - while (mask < maskEnd) - { - if (*mask != 0) - return TRUE; - mask++; - } - - return FALSE; - } - else - return m_mask != (COUNT_T) 1; -} - -inline void BitMask::ClearAllBits() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - delete [] m_maskArray; - - m_mask = 1; -} - -inline size_t BitMask::GetAllocatedBlockOffset() -{ - LIMITED_METHOD_CONTRACT; - - return offsetof(BitMask, m_maskArray); -} - -inline void *BitMask::GetAllocatedBlock() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - return m_maskArray; - else - return NULL; -} - -inline COUNT_T BitMask::GetAllocatedBlockSize() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - return (GetMaskArraySize()+1) * sizeof(COUNT_T); - else - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////// - -inline SynchronizedBitMask::SynchronizedBitMask() - : m_bitMaskLock(PREEMPTIVE, LOCK_TYPE_DEFAULT) -{ - LIMITED_METHOD_CONTRACT; -} - -inline BOOL SynchronizedBitMask::TestBit(int bit) -{ - CONTRACTL - { - NOTHROW; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleReadLockHolder holder(&m_bitMaskLock); - - return m_bitMask.TestBit(bit); -} - -inline void SynchronizedBitMask::SetBit(int bit) -{ - CONTRACTL - { - THROWS; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleWriteLockHolder holder(&m_bitMaskLock); - - m_bitMask.SetBit(bit); -} - -inline void SynchronizedBitMask::ClearBit(int bit) -{ - CONTRACTL - { - NOTHROW; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleWriteLockHolder holder(&m_bitMaskLock); - - m_bitMask.ClearBit(bit); -} - -inline BOOL SynchronizedBitMask::TestAnyBit() -{ - CONTRACTL - { - NOTHROW; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleReadLockHolder holder(&m_bitMaskLock); - - return m_bitMask.TestAnyBit(); -} - -inline void SynchronizedBitMask::ClearAllBits() -{ - CONTRACTL - { - NOTHROW; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleWriteLockHolder holder(&m_bitMaskLock); - - m_bitMask.ClearAllBits(); -} - -#endif // _BITMASK_INL_ - diff --git a/src/coreclr/vm/ceeload.h b/src/coreclr/vm/ceeload.h index ddd8d9f6b65284..92f08d687578cb 100644 --- a/src/coreclr/vm/ceeload.h +++ b/src/coreclr/vm/ceeload.h @@ -22,7 +22,6 @@ #include "peassembly.h" #include "typehash.h" #include "contractimpl.h" -#include "bitmask.h" #include "instmethhash.h" #include "eetwain.h" // For EnumGCRefs (we should probably move that somewhere else, but can't // find anything better (modulo common or vars.hpp) From 3295d5accf00d827db2f83910caafe31c1ded010 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 17 Oct 2025 10:57:26 -0700 Subject: [PATCH 2/2] Remove unused special-statics header --- src/coreclr/vm/common.h | 1 - src/coreclr/vm/object.h | 1 - src/coreclr/vm/specialstatics.h | 37 --------------------------------- src/coreclr/vm/threads.cpp | 8 ------- 4 files changed, 47 deletions(-) delete mode 100644 src/coreclr/vm/specialstatics.h diff --git a/src/coreclr/vm/common.h b/src/coreclr/vm/common.h index bf6f41d7e33927..e63f2edde63be7 100644 --- a/src/coreclr/vm/common.h +++ b/src/coreclr/vm/common.h @@ -278,7 +278,6 @@ namespace Loader #include "fcall.h" #include "syncblk.h" #include "gcdesc.h" -#include "specialstatics.h" #include "object.h" // We should not really need to put this so early... #include "gchelpers.h" #include "peassembly.h" diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index 7b0e21e2c4437d..d8f22dadb119c4 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -15,7 +15,6 @@ #include "util.hpp" #include "syncblk.h" #include "gcdesc.h" -#include "specialstatics.h" #include "sstring.h" #include "daccess.h" #include "fcall.h" diff --git a/src/coreclr/vm/specialstatics.h b/src/coreclr/vm/specialstatics.h deleted file mode 100644 index aa6c1b6f08c00c..00000000000000 --- a/src/coreclr/vm/specialstatics.h +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*=========================================================================== -** -** File: SpecialStatics.h -** -** -** Purpose: Defines the data structures for context relative statics. -** -** -** -=============================================================================*/ -#ifndef _H_SPECIALSTATICS_ -#define _H_SPECIALSTATICS_ - -// Data structure for storing special context relative static data. -typedef struct _STATIC_DATA -{ - DWORD cElem; - PTR_VOID dataPtr[0]; - -#ifdef DACCESS_COMPILE - static ULONG32 DacSize(TADDR addr) - { - DWORD cElem = *PTR_DWORD(addr); - return offsetof(struct _STATIC_DATA, dataPtr) + - cElem * sizeof(TADDR); - } - - void EnumMemoryRegions(CLRDataEnumMemoryFlags flags); -#endif - -} STATIC_DATA; -typedef SPTR(STATIC_DATA) PTR_STATIC_DATA; - -#endif diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 509f5215747d46..45cb8ff328ef05 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -7778,14 +7778,6 @@ PTR_GCFrame Thread::GetGCFrame() #ifdef DACCESS_COMPILE -void -STATIC_DATA::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) -{ - WRAPPER_NO_CONTRACT; - - DAC_ENUM_STHIS(STATIC_DATA); -} - void Thread::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) {