Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
945e059
WIP: Move Monitor impl from unmanaged code to managed in CoreCLR
jkoritzinsky Aug 1, 2025
424d0bb
Clean up the build
jkoritzinsky Aug 5, 2025
4d24c00
Unify Condition implementation
jkoritzinsky Aug 5, 2025
5c0fc6d
Fix Mono and CoreCLR builds
jkoritzinsky Aug 7, 2025
1e75f44
Assert index for sync block
jkoritzinsky Aug 7, 2025
fe8e4c4
More ifdefs for mono
jkoritzinsky Aug 7, 2025
8c0d783
Add back ExitIfLockTaken for JIT helper
jkoritzinsky Aug 7, 2025
1b4807b
Fix GC mode
jkoritzinsky Aug 8, 2025
ddffcac
Fix musl build and make gc modes explicit
jkoritzinsky Aug 8, 2025
72d563f
Split GetLockObject's implementation into a fast FCall and a slow QCall
jkoritzinsky Aug 8, 2025
bf4f5b0
Fix some asserts
jkoritzinsky Aug 11, 2025
b5eafc5
Lock uses 0-based recursion count. Also, only read the thin-lock memb…
jkoritzinsky Aug 13, 2025
85b759f
Fix musl build
jkoritzinsky Aug 13, 2025
1a9a833
FIx one more musl problem
jkoritzinsky Aug 13, 2025
6a9b762
Refactor out the object header spinlocking so we can use it on the th…
jkoritzinsky Aug 14, 2025
5d71628
Only make the spinlock GC_NOTRIGGER for the object header and only go…
jkoritzinsky Aug 14, 2025
da3f2c8
Don't switch to the spinlock mechanism. Didn't solve the problem I th…
jkoritzinsky Aug 15, 2025
8d66eff
Handle the case where an object is given a syncblock index and not ha…
jkoritzinsky Aug 15, 2025
c3cbe1a
Don't allow a syncblock to be collected if it has thinlock data.
jkoritzinsky Aug 15, 2025
9eacce2
Reset thin-lock data on GC, give back an empty enumerable for GetBloc…
jkoritzinsky Aug 18, 2025
445b29e
Fix arg passing on win-x86
jkoritzinsky Aug 19, 2025
095eddf
Don't let our syncblock get cleaned up out from under us after SyncTa…
jkoritzinsky Aug 19, 2025
efc158e
Send wait events from the managed side for monitor waits to avoid hav…
jkoritzinsky Aug 19, 2025
8052520
Respect the syncblock spin lock used in thin header->syncblock upgrad…
jkoritzinsky Aug 20, 2025
9f6dcc4
Update comment
jkoritzinsky Aug 21, 2025
c603060
Flip condition check
jkoritzinsky Aug 21, 2025
a0b8cc4
Update expected parameter name
jkoritzinsky Aug 21, 2025
fdf197a
Track the OS thread ID so diagnostics can pick it up
jkoritzinsky Aug 22, 2025
a129d66
Don't track the OS thread ID, just use the managed thread ID
jkoritzinsky Aug 28, 2025
4ab7eb1
Force no-inlining for cases with P/Invokes (they're all a rare path)
jkoritzinsky Aug 29, 2025
4766513
Fix debug assert in dbi
jkoritzinsky Aug 29, 2025
ccdd3db
Remove remnants of TBI from the runtime (it's not needed there any more)
jkoritzinsky Sep 2, 2025
7087133
Merge branch 'main' of https://github.com/dotnet/runtime into monitor…
jkoritzinsky Sep 4, 2025
b01250c
Exit the thin-lock spinning when there's a sync-block index added.
jkoritzinsky Sep 4, 2025
cde14e2
Switch debug check to use TryGetLockInfo
jkoritzinsky Sep 4, 2025
ba1d13b
Construct the lock object in managed code so we can hit the optimized…
jkoritzinsky Sep 4, 2025
0bc0143
Don't force EnterSlow to not be inlined.
jkoritzinsky Sep 4, 2025
64510c6
Manually inline away the *Slow variants
jkoritzinsky Sep 4, 2025
e16bee3
Remove SyncTable class. It isn't worth having a separate type at this…
jkoritzinsky Sep 4, 2025
6bfc0b5
Fix naming issues
jkoritzinsky Sep 4, 2025
8255446
Flip condition to skip out on the thin lock spin logic.
jkoritzinsky Sep 5, 2025
5bc026c
Don't try to do a quick-loop for release. Just go to the slow path li…
jkoritzinsky Sep 5, 2025
02a6a06
Rewrite IsEntered implementation to match how Enter and Exit are impl…
jkoritzinsky Sep 8, 2025
6eaa48f
Actually fix the DBI asserts
jkoritzinsky Sep 8, 2025
d3ac8bd
Try-Enter with a timeout should do the slow path if there's a timeout
jkoritzinsky Sep 8, 2025
5211992
Check for syncblk index first. Thread-id is only valid if this bit is…
jkoritzinsky Sep 8, 2025
21bd0c3
Unify enum definitions
jkoritzinsky Sep 8, 2025
db27b5a
Port over the lazy statics initialization to avoid cctor deadlocks.
jkoritzinsky Sep 16, 2025
74cfe31
Merge branch 'main' of https://github.com/dotnet/runtime into monitor…
jkoritzinsky Sep 16, 2025
0d4852b
Merge branch 'main' of https://github.com/dotnet/runtime into monitor…
jkoritzinsky Oct 15, 2025
6962f94
Merge branch 'main' into monitor-managed
jkotas Oct 25, 2025
f460387
Unify System.Threading.Lock type implementation and define split Mana…
jkoritzinsky Oct 28, 2025
9d7a781
Remove PulseAllHelper (matches dotnet/runtime#121132)
jkoritzinsky Oct 28, 2025
25cb8b3
PR feedback.
jkoritzinsky Oct 28, 2025
ba9ec39
PR feedback
jkoritzinsky Oct 29, 2025
36ad615
Remove ThreadId abstraction
jkoritzinsky Oct 29, 2025
9448ace
Remove SynchronizedMethodHelpers, fix up NativeAOT build.
jkoritzinsky Oct 29, 2025
cfc129d
Add missing parameter
jkoritzinsky Oct 29, 2025
c8ab809
Add missing cast
jkoritzinsky Oct 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@
<Compile Include="$(BclSourcesRoot)\System\StubHelpers.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\StringBuilder.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Interlocked.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\ManagedThreadId.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Monitor.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\ObjectHeader.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\SynchronizationContext.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Thread.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\WaitHandle.CoreCLR.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static unsafe string[] InitializeCommandLineArgs(char* exePath, int argc
}

[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "Environment_GetProcessorCount")]
private static partial int GetProcessorCount();
internal static partial int GetProcessorCount();

// Used by VM
internal static string? GetResourceStringLocal(string key) => SR.GetResourceString(key);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;

namespace System.Threading
{
internal static class ManagedThreadId
{
// This will be initialized by the runtime.
[ThreadStatic]
private static int t_currentManagedThreadId;
internal static int CurrentManagedThreadIdUnchecked => t_currentManagedThreadId;

public static int Current => t_currentManagedThreadId;
}
}
Loading
Loading