-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: import entire method for OSR, prune unneeded parts later (#83910)
For OSR compiles, always import from the original entry point in addition to the OSR entry point. This gives the OSR compiler a chance to see all of the method and so properly compute address exposure, instead of relying on the Tier0 analysis. Once address exposure has been determined, revoke special protection for the original entry and try and prune away blocks that are no longer needed (we actually wait until morph). Fixes #83783. May also fix some of the cases where OSR perf is lagging (though don't expect this to fix them all).
- Loading branch information
1 parent
8ae68db
commit f1f9fde
Showing
11 changed files
with
152 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// 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; | ||
|
||
// Runtime 83738: need to ensure that 's' in 'Foo' | ||
// is marked as address exposed during OSR compiles. | ||
|
||
public class Exposure1 | ||
{ | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void Bar() | ||
{ | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static bool Foo(int n) | ||
{ | ||
S s = new S { F = 1234 }; | ||
ref int foo = ref s.F; | ||
|
||
for (int i = 0; i < n; i++) | ||
{ | ||
Bar(); | ||
} | ||
|
||
int abc = s.F * 3 + 4; | ||
foo = 25; | ||
int def = s.F * 3 + 4; | ||
|
||
int eabc = 1234 * 3 + 4; | ||
int edef = 25 * 3 + 4; | ||
Console.WriteLine("abc = {0} (expected {1}), def = {2} (expected {3})", abc, eabc, def, edef); | ||
return (abc == eabc && def == edef); | ||
} | ||
|
||
public static int Main() | ||
{ | ||
return Foo(50000) ? 100 : -1; | ||
} | ||
|
||
public struct S | ||
{ | ||
public int F; | ||
} | ||
} |
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<DebugType /> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
<CLRTestEnvironmentVariable Include="DOTNET_TieredCompilation" Value="1" /> | ||
<CLRTestEnvironmentVariable Include="DOTNET_TC_QuickJitForLoops" Value="1" /> | ||
<CLRTestEnvironmentVariable Include="DOTNET_TC_OnStackReplacement" Value="1" /> | ||
</ItemGroup> | ||
</Project> |
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,47 @@ | ||
// 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; | ||
|
||
// Runtime 83738: need to ensure that 's' in 'Foo' | ||
// is marked as address exposed during OSR compiles. | ||
|
||
public class Exposure2 | ||
{ | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void Bar() | ||
{ | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static bool Foo(int n) | ||
{ | ||
S s = new S { F = 1234 }; | ||
ref S foo = ref s; | ||
|
||
for (int i = 0; i < n; i++) | ||
{ | ||
Bar(); | ||
} | ||
|
||
int abc = s.F * 3 + 4; | ||
foo.F = 25; | ||
int def = s.F * 3 + 4; | ||
|
||
int eabc = 1234 * 3 + 4; | ||
int edef = 25 * 3 + 4; | ||
Console.WriteLine("abc = {0} (expected {1}), def = {2} (expected {3})", abc, eabc, def, edef); | ||
return (abc == eabc && def == edef); | ||
} | ||
|
||
public static int Main() | ||
{ | ||
return Foo(50000) ? 100 : -1; | ||
} | ||
|
||
public struct S | ||
{ | ||
public int F; | ||
} | ||
} |
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<DebugType /> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
<CLRTestEnvironmentVariable Include="DOTNET_TieredCompilation" Value="1" /> | ||
<CLRTestEnvironmentVariable Include="DOTNET_TC_QuickJitForLoops" Value="1" /> | ||
<CLRTestEnvironmentVariable Include="DOTNET_TC_OnStackReplacement" Value="1" /> | ||
</ItemGroup> | ||
</Project> |