Skip to content

Commit affd75e

Browse files
Remove unused members on runtime Thread (#105158)
* Remove unused members on runtime Thread * Use SOleTlsData definition from public doc * Remove forward declaration * Update src/coreclr/vm/oletls.h Co-authored-by: Aaron Robinson <[email protected]> --------- Co-authored-by: Aaron Robinson <[email protected]>
1 parent 08d8070 commit affd75e

File tree

5 files changed

+11
-244
lines changed

5 files changed

+11
-244
lines changed

src/coreclr/inc/contract.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,21 +1981,6 @@ inline ClrDebugState *GetClrDebugState(BOOL fAlloc)
19811981
#define LOCK_RELEASED_MULTIPLE(dbgStateLockType, cExits, pvLock) \
19821982
::GetClrDebugState()->LockReleased((dbgStateLockType), (cExits), (void*) (pvLock))
19831983

1984-
// Use these only if you need to force multiple entrances or exits in a single
1985-
// line (e.g., to restore the lock to a previous state). CRWLock in vm\rwlock.cpp does this
1986-
#define EE_LOCK_TAKEN_MULTIPLE(cEntrances, pvLock) \
1987-
LOCK_TAKEN_MULTIPLE(kDbgStateLockType_EE, cEntrances, pvLock)
1988-
#define EE_LOCK_RELEASED_MULTIPLE(cExits, pvLock) \
1989-
LOCK_RELEASED_MULTIPLE(kDbgStateLockType_EE, cExits, pvLock)
1990-
#define HOST_BREAKABLE_CRST_TAKEN_MULTIPLE(cEntrances, pvLock) \
1991-
LOCK_TAKEN_MULTIPLE(kDbgStateLockType_HostBreakableCrst, cEntrances, pvLock)
1992-
#define HOST_BREAKABLE_CRST_RELEASED_MULTIPLE(cExits, pvLock) \
1993-
LOCK_RELEASED_MULTIPLE(kDbgStateLockType_HostBreakableCrst, cExits, pvLock)
1994-
#define USER_LOCK_TAKEN_MULTIPLE(cEntrances, pvLock) \
1995-
LOCK_TAKEN_MULTIPLE(kDbgStateLockType_User, cEntrances, pvLock)
1996-
#define USER_LOCK_RELEASED_MULTIPLE(cExits, pvLock) \
1997-
LOCK_RELEASED_MULTIPLE(kDbgStateLockType_User, cExits, pvLock)
1998-
19991984
// These are most typically used
20001985
#define EE_LOCK_TAKEN(pvLock) \
20011986
LOCK_TAKEN_MULTIPLE(kDbgStateLockType_EE, 1, pvLock)
@@ -2014,12 +1999,6 @@ inline ClrDebugState *GetClrDebugState(BOOL fAlloc)
20141999

20152000
#define LOCK_TAKEN_MULTIPLE(dbgStateLockType, cEntrances, pvLock)
20162001
#define LOCK_RELEASED_MULTIPLE(dbgStateLockType, cExits, pvLock)
2017-
#define EE_LOCK_TAKEN_MULTIPLE(cEntrances, pvLock)
2018-
#define EE_LOCK_RELEASED_MULTIPLE(cExits, pvLock)
2019-
#define HOST_BREAKABLE_CRST_TAKEN_MULTIPLE(cEntrances, pvLock)
2020-
#define HOST_BREAKABLE_CRST_RELEASED_MULTIPLE(cExits, pvLock)
2021-
#define USER_LOCK_TAKEN_MULTIPLE(cEntrances, pvLock)
2022-
#define USER_LOCK_RELEASED_MULTIPLE(cExits, pvLock)
20232002
#define EE_LOCK_TAKEN(pvLock)
20242003
#define EE_LOCK_RELEASED(pvLock)
20252004
#define HOST_BREAKABLE_CRST_TAKEN(pvLock)

src/coreclr/vm/olecontexthelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ LPVOID SetupOleContext()
5151
SOleTlsData* _pData = (SOleTlsData *) ClrTeb::GetOleReservedPtr();
5252
if (_pData && _pData->pCurrentCtx == NULL)
5353
{
54-
_pData->pCurrentCtx = (CObjectContext*)pObjCtx; // no release !!!!
54+
_pData->pCurrentCtx = pObjCtx; // no release !!!!
5555
}
5656
else
5757
{

src/coreclr/vm/oletls.h

Lines changed: 10 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
3-
//+---------------------------------------------------------------------------
4-
//
5-
// File: oletls.h
6-
//
7-
8-
//
9-
// Purpose: manage thread local storage for OLE
10-
//
11-
// Notes: The gTlsIndex is initialized at process attach time.
12-
// The per-thread data is allocated in CoInitialize in
13-
// single-threaded apartments or on first use in
14-
// multi-threaded apartments.
15-
//
16-
//----------------------------------------------------------------------------
173

184
#ifndef _OLETLS_H_
195
#define _OLETLS_H_
@@ -22,188 +8,15 @@
228
#error FEATURE_COMINTEROP_APARTMENT_SUPPORT is required for this file
239
#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
2410

25-
//+---------------------------------------------------------------------------
26-
//
27-
// forward declarations (in order to avoid type casting when accessing
28-
// data members of the SOleTlsData structure).
29-
//
30-
//+---------------------------------------------------------------------------
31-
32-
class CAptCallCtrl; // see callctrl.hxx
33-
class CSrvCallState; // see callctrl.hxx
34-
class CObjServer; // see sobjact.hxx
35-
class CSmAllocator; // see stg\h\smalloc.hxx
36-
class CMessageCall; // see call.hxx
37-
class CClientCall; // see call.hxx
38-
class CAsyncCall; // see call.hxx
39-
class CClipDataObject; // see ole232\clipbrd\clipdata.h
40-
class CSurrogatedObjectList; // see com\inc\comsrgt.hxx
41-
class CCtxCall; // see PSTable.hxx
42-
class CPolicySet; // see PSTable.hxx
43-
class CObjectContext; // see context.hxx
44-
class CComApartment; // see aprtmnt.hxx
45-
46-
//+-------------------------------------------------------------------
47-
//
48-
// Struct: CallEntry
49-
//
50-
// Synopsis: Call Table Entry.
51-
//
52-
//+-------------------------------------------------------------------
53-
typedef struct tagCallEntry
54-
{
55-
void *pNext; // ptr to next entry
56-
void *pvObject; // Entry object
57-
} CallEntry;
58-
59-
60-
61-
//+---------------------------------------------------------------------------
62-
//
63-
// Enum: OLETLSFLAGS
64-
//
65-
// Synopsys: bit values for dwFlags field of SOleTlsData. If you just want
66-
// to store a BOOL in TLS, use this enum and the dwFlag field.
67-
//
68-
//+---------------------------------------------------------------------------
69-
typedef enum tagOLETLSFLAGS
70-
{
71-
OLETLS_LOCALTID = 0x01, // This TID is in the current process.
72-
OLETLS_UUIDINITIALIZED = 0x02, // This Logical thread is init'd.
73-
OLETLS_INTHREADDETACH = 0x04, // This is in thread detach. Needed
74-
// due to NT's special thread detach
75-
// rules.
76-
OLETLS_CHANNELTHREADINITIALZED = 0x08,// This channel has been init'd
77-
OLETLS_WOWTHREAD = 0x10, // This thread is a 16-bit WOW thread.
78-
OLETLS_THREADUNINITIALIZING = 0x20, // This thread is in CoUninitialize.
79-
OLETLS_DISABLE_OLE1DDE = 0x40, // This thread can't use a DDE window.
80-
OLETLS_APARTMENTTHREADED = 0x80, // This is an STA apartment thread
81-
OLETLS_MULTITHREADED = 0x100, // This is an MTA apartment thread
82-
OLETLS_IMPERSONATING = 0x200, // This thread is impersonating
83-
OLETLS_DISABLE_EVENTLOGGER = 0x400, // Prevent recursion in event logger
84-
OLETLS_INNEUTRALAPT = 0x800, // This thread is in the NTA
85-
OLETLS_DISPATCHTHREAD = 0x1000, // This is a dispatch thread
86-
OLETLS_HOSTTHREAD = 0x2000, // This is a host thread
87-
OLETLS_ALLOWCOINIT = 0x4000, // This thread allows inits
88-
OLETLS_PENDINGUNINIT = 0x8000, // This thread has pending uninit
89-
OLETLS_FIRSTMTAINIT = 0x10000,// First thread to attempt an MTA init
90-
OLETLS_FIRSTNTAINIT = 0x20000,// First thread to attempt an NTA init
91-
OLETLS_APTINITIALIZING = 0x40000 // Apartment Object is initializing
92-
} OLETLSFLAGS;
93-
94-
95-
//+---------------------------------------------------------------------------
96-
//
97-
// Structure: SOleTlsData
98-
//
99-
// Synopsis: structure holding per thread state needed by OLE32
100-
//
101-
//+---------------------------------------------------------------------------
102-
typedef struct tagSOleTlsData
103-
{
104-
#if !defined(_CHICAGO_)
105-
// Docfile multiple allocator support
106-
void *pvThreadBase; // per thread base pointer
107-
CSmAllocator *pSmAllocator; // per thread docfile allocator
108-
#endif
109-
DWORD dwApartmentID; // Per thread "process ID"
110-
DWORD dwFlags; // see OLETLSFLAGS above
111-
112-
LONG TlsMapIndex; // index in the global TLSMap
113-
void **ppTlsSlot; // Back pointer to the thread tls slot
114-
DWORD cComInits; // number of per-thread inits
115-
DWORD cOleInits; // number of per-thread OLE inits
116-
117-
DWORD cCalls; // number of outstanding calls
118-
CMessageCall *pCallInfo; // channel call info
119-
CAsyncCall *pFreeAsyncCall; // ptr to available call object for this thread.
120-
CClientCall *pFreeClientCall; // ptr to available call object for this thread.
121-
122-
CObjServer *pObjServer; // Activation Server Object for this apartment.
123-
DWORD dwTIDCaller; // TID of current calling app
124-
CObjectContext *pCurrentCtx; // Current context
125-
CObjectContext *pEmptyCtx; // Empty context
126-
127-
CObjectContext *pNativeCtx; // Native context
128-
CComApartment *pNativeApt; // Native apartment for the thread.
129-
IUnknown *pCallContext; // call context object
130-
CCtxCall *pCtxCall; // Context call object
131-
132-
CPolicySet *pPS; // Policy set
133-
PVOID pvPendingCallsFront;// Per Apt pending async calls
134-
PVOID pvPendingCallsBack;
135-
CAptCallCtrl *pCallCtrl; // call control for RPC for this apartment
136-
137-
CSrvCallState *pTopSCS; // top server-side callctrl state
138-
IMessageFilter *pMsgFilter; // temp storage for App MsgFilter
139-
HWND hwndSTA; // STA server window same as poxid->hServerSTA
140-
// ...needed on Win95 before oxid registration
141-
LONG cORPCNestingLevel; // call nesting level (DBG only)
142-
143-
DWORD cDebugData; // count of bytes of debug data in call
144-
ULONG cPreRegOidsAvail; // count of server-side OIDs avail
145-
unsigned hyper *pPreRegOids; // ptr to array of pre-reg OIDs
146-
147-
UUID LogicalThreadId; // current logical thread id
148-
149-
HANDLE hThread; // Thread handle used for cancel
150-
HANDLE hRevert; // Token before first impersonate.
151-
IUnknown *pAsyncRelease; // Controlling unknown for async release
152-
// DDE data
153-
HWND hwndDdeServer; // Per thread Common DDE server
154-
155-
HWND hwndDdeClient; // Per thread Common DDE client
156-
ULONG cServeDdeObjects; // non-zero if objects DDE should serve
157-
// ClassCache data
158-
LPVOID pSTALSvrsFront; // Chain of LServers registers in this thread if STA
159-
// upper layer data
160-
HWND hwndClip; // Clipboard window
161-
162-
IDataObject *pDataObjClip; // Current Clipboard DataObject
163-
DWORD dwClipSeqNum; // Clipboard Sequence # for the above DataObject
164-
DWORD fIsClipWrapper; // Did we hand out the wrapper Clipboard DataObject?
165-
IUnknown *punkState; // Per thread "state" object
166-
// cancel data
167-
DWORD cCallCancellation; // count of CoEnableCallCancellation
168-
// async sends data
169-
DWORD cAsyncSends; // count of async sends outstanding
170-
171-
CAsyncCall* pAsyncCallList; // async calls outstanding
172-
CSurrogatedObjectList *pSurrogateList; // Objects in the surrogate
173-
174-
LockEntry lockEntry; // Locks currently held by the thread
175-
CallEntry CallEntry; // client-side call chain for this thread
176-
177-
#ifdef WX86OLE
178-
IUnknown *punkStateWx86; // Per thread "state" object for Wx86
179-
#endif
180-
void *pDragCursors; // Per thread drag cursor table.
181-
182-
#ifdef _CHICAGO_
183-
LPVOID pWcstokContext; // Scan context for wcstok
184-
#endif
185-
186-
IUnknown *punkError; // Per thread error object.
187-
ULONG cbErrorData; // Maximum size of error data.
188-
189-
#if(_WIN32_WINNT >= 0x0500)
190-
IUnknown *punkActiveXSafetyProvider;
191-
#endif //(_WIN32_WINNT >= 0x0500)
192-
193-
#if DBG==1
194-
LONG cTraceNestingLevel; // call nesting level for OLETRACE
195-
#endif
196-
197-
} SOleTlsData;
198-
199-
#ifdef INITGUID
200-
#include "initguid.h"
201-
#endif
202-
203-
#define DEFINE_OLEGUID(name, l, w1, w2) \
204-
DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
205-
206-
DEFINE_OLEGUID(IID_IStdIdentity, 0x0000001bL, 0, 0);
207-
DEFINE_OLEGUID(IID_IStdWrapper, 0x000001caL, 0, 0);
11+
// See https://learn.microsoft.com/previous-versions/windows/desktop/legacy/ms690269(v=vs.85)
12+
typedef struct _SOleTlsData {
13+
void *pvReserved0[2];
14+
DWORD dwReserved0[3];
15+
void *pvReserved1[1];
16+
DWORD dwReserved1[3];
17+
void *pvReserved2[4];
18+
DWORD dwReserved2[1];
19+
void *pCurrentCtx;
20+
} SOleTlsData, *PSOleTlsData;
20821

20922
#endif // _OLETLS_H_

src/coreclr/vm/threads.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,14 +1330,6 @@ Thread::Thread()
13301330

13311331
m_dwForbidSuspendThread = 0;
13321332

1333-
// Initialize lock state
1334-
m_pHead = &m_embeddedEntry;
1335-
m_embeddedEntry.pNext = m_pHead;
1336-
m_embeddedEntry.pPrev = m_pHead;
1337-
m_embeddedEntry.dwLLockID = 0;
1338-
m_embeddedEntry.dwULockID = 0;
1339-
m_embeddedEntry.wReaderLevel = 0;
1340-
13411333
m_pBlockingLock = NULL;
13421334

13431335
m_pRuntimeThreadLocals = nullptr;

src/coreclr/vm/threads.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ class EECodeInfo;
139139
class DebuggerPatchSkip;
140140
class FaultingExceptionFrame;
141141
enum BinderMethodID : int;
142-
class CRWLock;
143-
struct LockEntry;
144142
class PrepareCodeConfig;
145143
class NativeCodeVersion;
146144

@@ -379,16 +377,6 @@ EXTERN_C void ThrowControlForThread(
379377
#endif // FEATURE_EH_FUNCLETS
380378
);
381379

382-
// RWLock state inside TLS
383-
struct LockEntry
384-
{
385-
LockEntry *pNext; // next entry
386-
LockEntry *pPrev; // prev entry
387-
LONG dwULockID;
388-
LONG dwLLockID; // owning lock
389-
WORD wReaderLevel; // reader nesting level
390-
};
391-
392380
#if defined(_DEBUG)
393381
BOOL MatchThreadHandleToOsId ( HANDLE h, DWORD osId );
394382
#endif
@@ -952,11 +940,6 @@ class Thread
952940
// in the object header to store it.
953941
DWORD m_ThreadId;
954942

955-
956-
// RWLock state
957-
LockEntry *m_pHead;
958-
LockEntry m_embeddedEntry;
959-
960943
#ifndef DACCESS_COMPILE
961944
Frame* NotifyFrameChainOfExceptionUnwind(Frame* pStartFrame, LPVOID pvLimitSP);
962945
#endif // DACCESS_COMPILE

0 commit comments

Comments
 (0)