Skip to content

Commit 47068a4

Browse files
[main] Source code updates from dotnet/runtime (#8571)
[main] Source code updates from dotnet/runtime
1 parent e19fc45 commit 47068a4

17 files changed

Lines changed: 59 additions & 344 deletions

File tree

‎src/runtime/.config/dotnet-tools.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
]
1616
},
1717
"microsoft.dotnet.xharness.cli": {
18-
"version": "11.0.0-prerelease.26368.1",
18+
"version": "11.0.0-prerelease.26413.1",
1919
"commands": [
2020
"xharness"
2121
]

‎src/runtime/eng/Version.Details.props‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ This file should be imported by eng/Versions.props
4949
<SystemReflectionMetadataLoadContextPackageVersion>11.0.0-rc.1.26411.119</SystemReflectionMetadataLoadContextPackageVersion>
5050
<SystemTextJsonPackageVersion>11.0.0-rc.1.26411.119</SystemTextJsonPackageVersion>
5151
<!-- dotnet-icu dependencies -->
52-
<MicrosoftNETCoreRuntimeICUTransportPackageVersion>11.0.0-alpha.1.26364.1</MicrosoftNETCoreRuntimeICUTransportPackageVersion>
52+
<MicrosoftNETCoreRuntimeICUTransportPackageVersion>11.0.0-alpha.1.26418.1</MicrosoftNETCoreRuntimeICUTransportPackageVersion>
5353
<!-- dotnet-llvm-project dependencies -->
5454
<runtimelinuxarm64MicrosoftNETCoreRuntimeJITToolsPackageVersion>23.1.0-alpha.1.26411.2</runtimelinuxarm64MicrosoftNETCoreRuntimeJITToolsPackageVersion>
5555
<runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMLibclangPackageVersion>23.1.0-alpha.1.26411.2</runtimelinuxarm64MicrosoftNETCoreRuntimeMonoLLVMLibclangPackageVersion>
@@ -114,9 +114,9 @@ This file should be imported by eng/Versions.props
114114
<SystemTextRegularExpressionsTestDataPackageVersion>11.0.0-beta.26403.1</SystemTextRegularExpressionsTestDataPackageVersion>
115115
<SystemWindowsExtensionsTestDataPackageVersion>11.0.0-beta.26403.1</SystemWindowsExtensionsTestDataPackageVersion>
116116
<!-- dotnet-xharness dependencies -->
117-
<MicrosoftDotNetXHarnessCLIPackageVersion>11.0.0-prerelease.26368.1</MicrosoftDotNetXHarnessCLIPackageVersion>
118-
<MicrosoftDotNetXHarnessTestRunnersCommonPackageVersion>11.0.0-prerelease.26368.1</MicrosoftDotNetXHarnessTestRunnersCommonPackageVersion>
119-
<MicrosoftDotNetXHarnessTestRunnersXunitPackageVersion>11.0.0-prerelease.26368.1</MicrosoftDotNetXHarnessTestRunnersXunitPackageVersion>
117+
<MicrosoftDotNetXHarnessCLIPackageVersion>11.0.0-prerelease.26413.1</MicrosoftDotNetXHarnessCLIPackageVersion>
118+
<MicrosoftDotNetXHarnessTestRunnersCommonPackageVersion>11.0.0-prerelease.26413.1</MicrosoftDotNetXHarnessTestRunnersCommonPackageVersion>
119+
<MicrosoftDotNetXHarnessTestRunnersXunitPackageVersion>11.0.0-prerelease.26413.1</MicrosoftDotNetXHarnessTestRunnersXunitPackageVersion>
120120
</PropertyGroup>
121121
<!--Property group for alternate package version names-->
122122
<PropertyGroup>

‎src/runtime/eng/Version.Details.xml‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Dependencies>
22
<Source Uri="https://github.com/dotnet/dotnet" Mapping="runtime" Sha="7cdb217445905f3342bbb0266a4497b9a014389a" BarId="326717" />
33
<ProductDependencies>
4-
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="11.0.0-alpha.1.26364.1">
4+
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="11.0.0-alpha.1.26418.1">
55
<Uri>https://github.com/dotnet/icu</Uri>
6-
<Sha>6cfb6605cf78bc12164284ec6cc7afbafb52d64e</Sha>
6+
<Sha>c6131fd7b7cebcef44c17f381b2fe325cb331964</Sha>
77
</Dependency>
88
<Dependency Name="runtime.linux-arm64.Microsoft.NETCore.Runtime.JIT.Tools" Version="23.1.0-alpha.1.26411.2">
99
<Uri>https://github.com/dotnet/llvm-project</Uri>
@@ -287,17 +287,17 @@
287287
<Uri>https://github.com/dotnet/dotnet</Uri>
288288
<Sha>7cdb217445905f3342bbb0266a4497b9a014389a</Sha>
289289
</Dependency>
290-
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="11.0.0-prerelease.26368.1">
290+
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="11.0.0-prerelease.26413.1">
291291
<Uri>https://github.com/dotnet/xharness</Uri>
292-
<Sha>acc639bea6c5720abf118b8808e18f9cabe90568</Sha>
292+
<Sha>f10844a1593bd12a5b59046798831ead3eeef2e0</Sha>
293293
</Dependency>
294-
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="11.0.0-prerelease.26368.1">
294+
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="11.0.0-prerelease.26413.1">
295295
<Uri>https://github.com/dotnet/xharness</Uri>
296-
<Sha>acc639bea6c5720abf118b8808e18f9cabe90568</Sha>
296+
<Sha>f10844a1593bd12a5b59046798831ead3eeef2e0</Sha>
297297
</Dependency>
298-
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="11.0.0-prerelease.26368.1">
298+
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="11.0.0-prerelease.26413.1">
299299
<Uri>https://github.com/dotnet/xharness</Uri>
300-
<Sha>acc639bea6c5720abf118b8808e18f9cabe90568</Sha>
300+
<Sha>f10844a1593bd12a5b59046798831ead3eeef2e0</Sha>
301301
</Dependency>
302302
<Dependency Name="Microsoft.DotNet.PackageTesting" Version="11.0.0-beta.26411.119">
303303
<Uri>https://github.com/dotnet/dotnet</Uri>

‎src/runtime/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs‎

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,9 @@ public sealed partial class Thread
3939
internal WaitSubsystem.ThreadWaitInfo? _waitInfo;
4040
#endif
4141

42-
/*=========================================================================
43-
** The base implementation of Thread is all native. The following fields
44-
** should never be used in the C# code. They are here to define the proper
45-
** space so the thread object may be allocated. DON'T CHANGE THESE UNLESS
46-
** YOU MODIFY ThreadBaseObject in vm\object.h
47-
=========================================================================*/
48-
#pragma warning disable CA1823, 169 // These fields are not used from managed.
49-
// IntPtrs need to be together, and before ints, because IntPtrs are 64-bit
50-
// fields on 64-bit platforms, where they will be sorted together.
51-
52-
private IntPtr _DONT_USE_InternalThread; // Pointer
53-
private int _priority; // INT32
54-
55-
// The following field is required for interop with the VS Debugger
56-
// Prior to making any changes to this field, please reach out to the VS Debugger
57-
// team to make sure that your changes are not going to prevent the debugger
58-
// from working.
59-
private int _managedThreadId; // INT32
60-
#pragma warning restore CA1823, 169
42+
private IntPtr _DONT_USE_InternalThread;
43+
private int _priority;
44+
private int _managedThreadId; // Debugger depends on the exact name of this field.
6145

6246
// This is used for a quick check on thread pool threads after running a work item to determine if the name, background
6347
// state, or priority were changed by the work item, and if so to reset it. Other threads may also change some of those,
@@ -315,30 +299,22 @@ public ThreadState ThreadState
315299
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_GetThreadState")]
316300
private static partial int GetThreadState(ThreadHandle t);
317301

318-
internal void SetWaitSleepJoinState()
302+
internal unsafe void SetWaitSleepJoinState()
319303
{
320304
// This method is called when the thread is about to enter a wait, sleep, or join state.
321305
// It sets the state in the native layer to indicate that the thread is waiting.
322-
SetWaitSleepJoinState(GetNativeHandle());
323-
GC.KeepAlive(this);
306+
NativeThread* nativeThread = GetNativeThreadForCurrentThread();
307+
Interlocked.Or(ref nativeThread->m_State, NativeThread.ThreadState.TS_WaitSleepJoin);
324308
}
325309

326-
internal void ClearWaitSleepJoinState()
310+
internal unsafe void ClearWaitSleepJoinState()
327311
{
328312
// This method is called when the thread is no longer in a wait, sleep, or join state.
329313
// It clears the state in the native layer to indicate that the thread is no longer waiting.
330-
ClearWaitSleepJoinState(GetNativeHandle());
331-
GC.KeepAlive(this);
314+
NativeThread* nativeThread = GetNativeThreadForCurrentThread();
315+
Interlocked.And(ref nativeThread->m_State, ~NativeThread.ThreadState.TS_WaitSleepJoin);
332316
}
333317

334-
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_SetWaitSleepJoinState")]
335-
[SuppressGCTransition]
336-
private static partial void SetWaitSleepJoinState(ThreadHandle t);
337-
338-
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_ClearWaitSleepJoinState")]
339-
[SuppressGCTransition]
340-
private static partial void ClearWaitSleepJoinState(ThreadHandle t);
341-
342318
/// <summary>
343319
/// An unstarted thread can be marked to indicate that it will host a
344320
/// single-threaded or multi-threaded apartment.
@@ -611,30 +587,24 @@ private static unsafe void OnThreadExited(Thread* pThread, Exception* pException
611587
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_ReentrantWaitAny")]
612588
internal static unsafe partial int ReentrantWaitAny([MarshalAs(UnmanagedType.Bool)] bool alertable, int timeout, int count, IntPtr* handles);
613589

614-
internal static void CheckForPendingInterrupt()
615-
{
616-
CheckForPendingInterrupt(CurrentThread.GetNativeHandle());
617-
GC.KeepAlive(CurrentThread);
618-
}
619-
620590
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_CheckForPendingInterrupt")]
621-
private static partial void CheckForPendingInterrupt(ThreadHandle t);
591+
internal static partial void CheckForPendingInterrupt();
622592

623-
[StructLayout(LayoutKind.Sequential)]
624-
private struct NativeThreadClass
593+
private unsafe NativeThread* GetNativeThreadForCurrentThread()
625594
{
626-
public NativeThreadState m_State;
595+
Debug.Assert(this == CurrentThread);
596+
return (NativeThread*)_DONT_USE_InternalThread;
627597
}
628598

629-
private enum NativeThreadState
599+
[StructLayout(LayoutKind.Sequential)]
600+
private struct NativeThread
630601
{
631-
None = 0,
632-
TS_AbortRequested = 0x00000001, // Abort the thread
633-
TS_DebugSuspendPending = 0x00000008, // Is the debugger suspending threads?
634-
TS_GCOnTransitions = 0x00000010, // Force a GC on stub transitions (GCStress only)
602+
public ThreadState m_State;
635603

636-
// We require (and assert) that the following bits are less than 0x100.
637-
TS_CatchAtSafePoint = (TS_AbortRequested | TS_DebugSuspendPending | TS_GCOnTransitions),
638-
};
604+
internal enum ThreadState
605+
{
606+
TS_WaitSleepJoin = 0x02000000, // Thread is waiting, sleeping or joining
607+
}
608+
}
639609
}
640610
}

‎src/runtime/src/coreclr/md/compiler/emit.cpp‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,10 +2751,6 @@ HRESULT RegMeta::DefineProperty(
27512751
IfFailGo(_SetPropertyProps(*pmdProp, dwPropFlags, dwCPlusTypeFlag, pValue, cchValue, mdSetter,
27522752
mdGetter, rmdOtherMethods));
27532753

2754-
// Add the <property token, typedef token> to the lookup table
2755-
if (m_pStgdb->m_MiniMd.HasIndirectTable(TBL_Property))
2756-
IfFailGo( m_pStgdb->m_MiniMd.AddPropertyToLookUpTable(*pmdProp, td) );
2757-
27582754
ErrExit:
27592755
SetCallerExternal();
27602756

‎src/runtime/src/coreclr/md/compiler/regmeta_emit.cpp‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,10 +1333,6 @@ HRESULT RegMeta::_DefineEvent( // Return hresult.
13331333
IfFailGo(m_pStgdb->m_MiniMd.PutString(TBL_Event, EventRec::COL_Name, pEventRec, szUTF8Event));
13341334
IfFailGo(_SetEventProps1(*pmdEvent, dwEventFlags, tkEventType));
13351335

1336-
// Add the <Event token, typedef token> to the lookup table
1337-
if (m_pStgdb->m_MiniMd.HasIndirectTable(TBL_Event))
1338-
IfFailGo( m_pStgdb->m_MiniMd.AddEventToLookUpTable(*pmdEvent, td) );
1339-
13401336
IfFailGo(UpdateENCLog(*pmdEvent));
13411337

13421338
ErrExit:

‎src/runtime/src/coreclr/vm/comsynchronizable.cpp‎

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -427,32 +427,6 @@ extern "C" INT32 QCALLTYPE ThreadNative_GetThreadState(QCall::ThreadHandle threa
427427
return res;
428428
}
429429

430-
extern "C" void QCALLTYPE ThreadNative_SetWaitSleepJoinState(QCall::ThreadHandle thread)
431-
{
432-
CONTRACTL
433-
{
434-
QCALL_CHECK_NO_GC_TRANSITION;
435-
PRECONDITION(thread != NULL);
436-
}
437-
CONTRACTL_END;
438-
439-
// Set the state bits.
440-
thread->SetThreadState(Thread::TS_WaitSleepJoin);
441-
}
442-
443-
extern "C" void QCALLTYPE ThreadNative_ClearWaitSleepJoinState(QCall::ThreadHandle thread)
444-
{
445-
CONTRACTL
446-
{
447-
QCALL_CHECK_NO_GC_TRANSITION;
448-
PRECONDITION(thread != NULL);
449-
}
450-
CONTRACTL_END;
451-
452-
// Clear the state bits.
453-
thread->ResetThreadState(Thread::TS_WaitSleepJoin);
454-
}
455-
456430
#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT
457431

458432
// Return whether the thread hosts an STA, is a member of the MTA or is not
@@ -543,14 +517,17 @@ extern "C" HANDLE QCALLTYPE ThreadNative_GetOSHandle(QCall::ThreadHandle t)
543517
HANDLE currentHandle = t->GetThreadHandle();
544518
if (currentHandle != INVALID_HANDLE_VALUE)
545519
{
546-
DuplicateHandle(
520+
if (!DuplicateHandle(
547521
GetCurrentProcess(),
548522
currentHandle,
549523
GetCurrentProcess(),
550524
&retVal,
551525
0,
552526
FALSE,
553-
DUPLICATE_SAME_ACCESS);
527+
DUPLICATE_SAME_ACCESS))
528+
{
529+
COMPlusThrowWin32();
530+
}
554531
}
555532

556533
END_QCALL;
@@ -766,13 +743,13 @@ extern "C" void QCALLTYPE ThreadNative_Interrupt(QCall::ThreadHandle thread)
766743
END_QCALL;
767744
}
768745

769-
extern "C" void QCALLTYPE ThreadNative_CheckForPendingInterrupt(QCall::ThreadHandle thread)
746+
extern "C" void QCALLTYPE ThreadNative_CheckForPendingInterrupt()
770747
{
771748
QCALL_CONTRACT;
772749

773750
BEGIN_QCALL;
774751

775-
thread->HandleThreadInterrupt();
752+
GetThread()->HandleThreadInterrupt();
776753

777754
END_QCALL;
778755
}

‎src/runtime/src/coreclr/vm/comsynchronizable.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ extern "C" void QCALLTYPE ThreadNative_PollGC();
5959
extern "C" UINT64 QCALLTYPE ThreadNative_GetCurrentOSThreadId();
6060
extern "C" void QCALLTYPE ThreadNative_Initialize(QCall::ObjectHandleOnStack t);
6161
extern "C" INT32 QCALLTYPE ThreadNative_GetThreadState(QCall::ThreadHandle thread);
62-
extern "C" void QCALLTYPE ThreadNative_SetWaitSleepJoinState(QCall::ThreadHandle thread);
63-
extern "C" void QCALLTYPE ThreadNative_ClearWaitSleepJoinState(QCall::ThreadHandle thread);
6462
extern "C" INT32 QCALLTYPE ThreadNative_ReentrantWaitAny(BOOL alertable, INT32 timeout, INT32 count, HANDLE *handles);
6563
#ifdef TARGET_WINDOWS
6664
extern "C" void QCALLTYPE ThreadNative_Interrupt(QCall::ThreadHandle thread);
67-
extern "C" void QCALLTYPE ThreadNative_CheckForPendingInterrupt(QCall::ThreadHandle thread);
65+
extern "C" void QCALLTYPE ThreadNative_CheckForPendingInterrupt();
6866
#endif // TARGET_WINDOWS
6967

7068
#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT
@@ -87,4 +85,3 @@ extern "C" void QCALLTYPE ObjectHeader_GetOrCreateLockObject(QCall::ObjectHandle
8785

8886
FCDECL1(OBJECTHANDLE, ObjectHeader_GetLockHandleIfExists, Object* obj);
8987
#endif // _COMSYNCHRONIZABLE_H
90-

‎src/runtime/src/coreclr/vm/qcallentrypoints.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,6 @@ static const Entry s_QCall[] =
307307
DllImportEntry(ThreadNative_GetCurrentOSThreadId)
308308
DllImportEntry(ThreadNative_Initialize)
309309
DllImportEntry(ThreadNative_GetThreadState)
310-
DllImportEntry(ThreadNative_SetWaitSleepJoinState)
311-
DllImportEntry(ThreadNative_ClearWaitSleepJoinState)
312310
DllImportEntry(ThreadNative_ReentrantWaitAny)
313311
#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT
314312
DllImportEntry(ThreadNative_GetApartmentState)

‎src/runtime/src/coreclr/vm/threads.cpp‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ HRESULT Thread::DetachThread(BOOL inTerminationCallback)
899899
// We can not call __SwitchToThread since we can not go back to host.
900900
ClrSleepEx(10, FALSE);
901901
}
902-
if (m_WeOwnThreadHandle && m_ThreadHandleForClose == INVALID_HANDLE_VALUE)
902+
if (m_ThreadHandleForClose == INVALID_HANDLE_VALUE)
903903
{
904904
m_ThreadHandleForClose = hThread;
905905
}
@@ -1238,7 +1238,6 @@ Thread::Thread()
12381238
m_ThreadHandle = INVALID_HANDLE_VALUE;
12391239
m_ThreadHandleForClose = INVALID_HANDLE_VALUE;
12401240
m_ThreadHandleForResume = INVALID_HANDLE_VALUE;
1241-
m_WeOwnThreadHandle = FALSE;
12421241

12431242
#ifdef _DEBUG
12441243
m_ThreadId = UNINITIALIZED_THREADID;
@@ -1515,7 +1514,6 @@ void Thread::InitThread()
15151514
_ASSERTE(hDup != INVALID_HANDLE_VALUE);
15161515

15171516
SetThreadHandle(hDup);
1518-
m_WeOwnThreadHandle = TRUE;
15191517
}
15201518
else
15211519
{
@@ -1982,7 +1980,6 @@ BOOL Thread::CreateNewOSThread(SIZE_T sizeToCommitOrReserve, LPTHREAD_START_ROUT
19821980
_ASSERTE(!m_fPreemptiveGCDisabled); // leave in preemptive until HasStarted.
19831981

19841982
SetThreadHandle(h);
1985-
m_WeOwnThreadHandle = TRUE;
19861983

19871984
// Before we do the resume, we need to take note of the new ThreadId. This
19881985
// is necessary because -- before the thread starts executing at KickofThread --
@@ -2116,7 +2113,7 @@ int Thread::DecExternalCount(BOOL holdingLock)
21162113
}
21172114
// Can not assert like this. We have already removed the Unstarted bit.
21182115
//_ASSERTE (IsUnstarted() || h != INVALID_HANDLE_VALUE);
2119-
if (h != INVALID_HANDLE_VALUE && m_WeOwnThreadHandle)
2116+
if (h != INVALID_HANDLE_VALUE)
21202117
{
21212118
::CloseHandle(h);
21222119
SetThreadHandle(INVALID_HANDLE_VALUE);
@@ -2259,8 +2256,8 @@ Thread::~Thread()
22592256

22602257
// Normally we shouldn't get here with a valid thread handle; however if SetupThread
22612258
// failed (due to an OOM for example) then we need to CloseHandle the thread
2262-
// handle if we own it.
2263-
if (m_WeOwnThreadHandle && (GetThreadHandle() != INVALID_HANDLE_VALUE))
2259+
// handle.
2260+
if (GetThreadHandle() != INVALID_HANDLE_VALUE)
22642261
{
22652262
CloseHandle(GetThreadHandle());
22662263
}

0 commit comments

Comments
 (0)