-
Notifications
You must be signed in to change notification settings - Fork 5.3k
JIT: support OSR for synchronized methods #61712
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
OSR methods share the "monitor acquired" flag with the original method. The monitor acquired flag is s bit of non-IL live state that must be tecorded in the patchpoint. Also, OSR methods only need to release the monitor as acquisition can only happen in the original method.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||||||||||||||||||||||||||
| // Licensed to the .NET Foundation under one or more agreements. | ||||||||||||||||||||||||||||||
| // The .NET Foundation licenses this file to you under the MIT license. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| using System; | ||||||||||||||||||||||||||||||
| using System.Runtime.CompilerServices; | ||||||||||||||||||||||||||||||
| using System.Threading; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| struct S | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| public long y; | ||||||||||||||||||||||||||||||
| public int x; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| class Z | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| virtual public S F() | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| S s = new S(); | ||||||||||||||||||||||||||||||
| s.x = 100; | ||||||||||||||||||||||||||||||
| s.y = -1; | ||||||||||||||||||||||||||||||
| return s; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| class X | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| Z z; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Synchronized)] | ||||||||||||||||||||||||||||||
| public S G() | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| S s = new S(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| for (int i = 0; i < 100_000; i++) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| s = z.F(); | ||||||||||||||||||||||||||||||
|
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. Does it make sense to verify
Member
Author
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. Sure, will add this. |
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return s; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public static int Main() | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| int result = Test(); | ||||||||||||||||||||||||||||||
| if (result == 100) { | ||||||||||||||||||||||||||||||
| Console.WriteLine("SUCCESS"); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||||||||
| Console.WriteLine("FAILURE"); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| if (result == 100) { | |
| Console.WriteLine("SUCCESS"); | |
| } | |
| else { | |
| Console.WriteLine("FAILURE"); | |
| } | |
| if (result == 100) | |
| { | |
| Console.WriteLine("SUCCESS"); | |
| } | |
| else | |
| { | |
| Console.WriteLine("FAILURE"); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <DebugType /> | ||
| <Optimize>True</Optimize> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="$(MSBuildProjectName).cs" /> | ||
| </ItemGroup> | ||
| <PropertyGroup> | ||
| <CLRTestBatchPreCommands><![CDATA[ | ||
| $(CLRTestBatchPreCommands) | ||
| set COMPlus_TieredCompilation=1 | ||
| set COMPlus_TC_QuickJitForLoops=1 | ||
| set COMPlus_TC_OnStackReplacement=1 | ||
| ]]></CLRTestBatchPreCommands> | ||
| <BashCLRTestPreCommands><![CDATA[ | ||
| $(BashCLRTestPreCommands) | ||
| export COMPlus_TieredCompilation=1 | ||
| export COMPlus_TC_QuickJitForLoops=1 | ||
| export COMPlus_TC_OnStackReplacement=1 | ||
| ]]></BashCLRTestPreCommands> | ||
| </PropertyGroup> | ||
| </Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the switch from
fgNewBBaftertofgSplitBlockAtEndrequired?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because in OSR methods
fgFirstBBmay not beBBJ_NONE.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even after calling
fgEnsureFirstBBisScratch()?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because
fgEnsureFirstBBisScratchwill just return if the first bb is already scratch.For OSR we've already called this and messed with the resulting flow. See
fgFixEntryFlowForOSR.