-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Refactor lock upgrade logic #122571
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
Refactor lock upgrade logic #122571
Changes from 6 commits
7bf6476
01bb0c0
9012d7d
183af37
4bc6c3a
c4ab2dd
d98cfa1
d26ade6
59df8b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,27 @@ | |
| [MethodImpl(MethodImplOptions.InternalCall)] | ||
| private static extern int CompareExchange32(ref int location1, int value, int comparand); | ||
|
|
||
| // This is used internally in cases where having a managed | ||
| // ref to the location is unsafe (Ex: it is the syncblock of a pinned object). | ||
| // The intrinsic expansion for this overload is exactly the same as for the `ref int` | ||
| // variant and will go on the same path since expansion is triggered by the name and | ||
| // return type of the method. | ||
| // The important part is avoiding `ref *location` in the unexpanded scenario, like | ||
| // in a case when compiling the Debug flavor of the app. | ||
| [Intrinsic] | ||
| internal static unsafe int CompareExchange(int* location1, int value, int comparand) | ||
| { | ||
| #if TARGET_X86 || TARGET_AMD64 || TARGET_ARM64 || TARGET_RISCV64 | ||
| return CompareExchange(location1, value, comparand); // Must expand intrinsic | ||
| #else | ||
| Debug.Assert(location1 != null); | ||
|
Check failure on line 143 in src/coreclr/System.Private.CoreLib/src/System/Threading/Interlocked.CoreCLR.cs
|
||
jkoritzinsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return RuntimeImports.InterlockedCompareExchange(location1, value, comparand); | ||
|
Check failure on line 144 in src/coreclr/System.Private.CoreLib/src/System/Threading/Interlocked.CoreCLR.cs
|
||
| #endif | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.InternalCall)] | ||
| private static unsafe extern int CompareExchange32Pointer(int* location1, int value, int comparand); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. osx-arm64 build is failing, fix: #122753.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was it not detected by the CI?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Analyzers should run for all build flavors by default. I do not think we have any conditions that enable them for debug builds only. Also, I am not able to reproduce the error on Windows (tried |
||
|
|
||
| /// <summary>Compares two 64-bit signed integers for equality and, if they are equal, replaces the first value.</summary> | ||
| /// <param name="location1">The destination, whose value is compared with <paramref name="comparand"/> and possibly replaced.</param> | ||
| /// <param name="value">The value that replaces the destination value if the comparison results in equality.</param> | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.