forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: support OSR for synchronized methods (dotnet#61712)
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 recorded in the patchpoint. Also, OSR methods only need to release the monitor as acquisition can only happen in the original method.
- Loading branch information
1 parent
cc44d43
commit dc43e19
Showing
10 changed files
with
176 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,83 @@ | ||
// 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++) | ||
{ | ||
if (!Monitor.IsEntered(this)) | ||
{ | ||
throw new Exception(); | ||
} | ||
s = z.F(); | ||
} | ||
|
||
return s; | ||
} | ||
|
||
public static int Main() | ||
{ | ||
int result = -1; | ||
try | ||
{ | ||
result = Test(); | ||
} | ||
catch (Exception) | ||
{ | ||
Console.WriteLine("EXCEPTION"); | ||
} | ||
|
||
if (result == 100) | ||
{ | ||
Console.WriteLine("SUCCESS"); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("FAILURE"); | ||
} | ||
return result; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static int Test() | ||
{ | ||
var x = new X(); | ||
x.z = new Z(); | ||
|
||
for (int i = 0; i < 100; i++) | ||
{ | ||
_ = x.G(); | ||
Thread.Sleep(15); | ||
} | ||
|
||
return x.G().x; | ||
} | ||
} |
This file contains 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,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> |