-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Move the implementation of Monitor to managed in CoreCLR #118371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,330
−5,266
Merged
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 424d0bb
Clean up the build
jkoritzinsky 4d24c00
Unify Condition implementation
jkoritzinsky 5c0fc6d
Fix Mono and CoreCLR builds
jkoritzinsky 1e75f44
Assert index for sync block
jkoritzinsky fe8e4c4
More ifdefs for mono
jkoritzinsky 8c0d783
Add back ExitIfLockTaken for JIT helper
jkoritzinsky 1b4807b
Fix GC mode
jkoritzinsky ddffcac
Fix musl build and make gc modes explicit
jkoritzinsky 72d563f
Split GetLockObject's implementation into a fast FCall and a slow QCall
jkoritzinsky bf4f5b0
Fix some asserts
jkoritzinsky b5eafc5
Lock uses 0-based recursion count. Also, only read the thin-lock memb…
jkoritzinsky 85b759f
Fix musl build
jkoritzinsky 1a9a833
FIx one more musl problem
jkoritzinsky 6a9b762
Refactor out the object header spinlocking so we can use it on the th…
jkoritzinsky 5d71628
Only make the spinlock GC_NOTRIGGER for the object header and only go…
jkoritzinsky da3f2c8
Don't switch to the spinlock mechanism. Didn't solve the problem I th…
jkoritzinsky 8d66eff
Handle the case where an object is given a syncblock index and not ha…
jkoritzinsky c3cbe1a
Don't allow a syncblock to be collected if it has thinlock data.
jkoritzinsky 9eacce2
Reset thin-lock data on GC, give back an empty enumerable for GetBloc…
jkoritzinsky 445b29e
Fix arg passing on win-x86
jkoritzinsky 095eddf
Don't let our syncblock get cleaned up out from under us after SyncTa…
jkoritzinsky efc158e
Send wait events from the managed side for monitor waits to avoid hav…
jkoritzinsky 8052520
Respect the syncblock spin lock used in thin header->syncblock upgrad…
jkoritzinsky 9f6dcc4
Update comment
jkoritzinsky c603060
Flip condition check
jkoritzinsky a0b8cc4
Update expected parameter name
jkoritzinsky fdf197a
Track the OS thread ID so diagnostics can pick it up
jkoritzinsky a129d66
Don't track the OS thread ID, just use the managed thread ID
jkoritzinsky 4ab7eb1
Force no-inlining for cases with P/Invokes (they're all a rare path)
jkoritzinsky 4766513
Fix debug assert in dbi
jkoritzinsky ccdd3db
Remove remnants of TBI from the runtime (it's not needed there any more)
jkoritzinsky 7087133
Merge branch 'main' of https://github.com/dotnet/runtime into monitor…
jkoritzinsky b01250c
Exit the thin-lock spinning when there's a sync-block index added.
jkoritzinsky cde14e2
Switch debug check to use TryGetLockInfo
jkoritzinsky ba1d13b
Construct the lock object in managed code so we can hit the optimized…
jkoritzinsky 0bc0143
Don't force EnterSlow to not be inlined.
jkoritzinsky 64510c6
Manually inline away the *Slow variants
jkoritzinsky e16bee3
Remove SyncTable class. It isn't worth having a separate type at this…
jkoritzinsky 6bfc0b5
Fix naming issues
jkoritzinsky 8255446
Flip condition to skip out on the thin lock spin logic.
jkoritzinsky 5bc026c
Don't try to do a quick-loop for release. Just go to the slow path li…
jkoritzinsky 02a6a06
Rewrite IsEntered implementation to match how Enter and Exit are impl…
jkoritzinsky 6eaa48f
Actually fix the DBI asserts
jkoritzinsky d3ac8bd
Try-Enter with a timeout should do the slow path if there's a timeout
jkoritzinsky 5211992
Check for syncblk index first. Thread-id is only valid if this bit is…
jkoritzinsky 21bd0c3
Unify enum definitions
jkoritzinsky db27b5a
Port over the lazy statics initialization to avoid cctor deadlocks.
jkoritzinsky 74cfe31
Merge branch 'main' of https://github.com/dotnet/runtime into monitor…
jkoritzinsky 0d4852b
Merge branch 'main' of https://github.com/dotnet/runtime into monitor…
jkoritzinsky 6962f94
Merge branch 'main' into monitor-managed
jkotas f460387
Unify System.Threading.Lock type implementation and define split Mana…
jkoritzinsky 9d7a781
Remove PulseAllHelper (matches dotnet/runtime#121132)
jkoritzinsky 25cb8b3
PR feedback.
jkoritzinsky ba9ec39
PR feedback
jkoritzinsky 36ad615
Remove ThreadId abstraction
jkoritzinsky 9448ace
Remove SynchronizedMethodHelpers, fix up NativeAOT build.
jkoritzinsky cfc129d
Add missing parameter
jkoritzinsky c8ab809
Add missing cast
jkoritzinsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/coreclr/System.Private.CoreLib/src/System/Threading/ManagedThreadId.CoreCLR.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.