-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[mono][jit] Emit a null check when storing to valuetype fields. #82663
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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
131 changes: 131 additions & 0 deletions
131
src/tests/JIT/Regression/JitBlue/Runtime_82535/Runtime_82535.cs
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,131 @@ | ||
// 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; | ||
|
||
public class Program | ||
{ | ||
public Program() | ||
{ | ||
} | ||
|
||
static int Main(string[] args) | ||
{ | ||
Foo currentFoo; | ||
|
||
Bacon defaultBacon = new Bacon(-180, 180, true, false, 300f, 0.1f, 0.1f, "Foo", false); | ||
currentFoo = new Foo(); | ||
try { | ||
currentFoo.GetBar().m_Bacon = defaultBacon; | ||
} catch (NullReferenceException) { | ||
return 100; | ||
} | ||
return 101; | ||
} | ||
} | ||
|
||
public class Foo | ||
{ | ||
private Bar m_Bar; | ||
public Bar GetBar() | ||
{ | ||
return m_Bar; | ||
} | ||
} | ||
|
||
|
||
public class Bar | ||
{ | ||
public Bacon m_Bacon = new Bacon(-180, 180, true, false, 300f, 0.1f, 0.1f, "Foo", false); | ||
} | ||
|
||
public struct Bacon | ||
{ | ||
public float Value; | ||
public enum FooEnum | ||
{ | ||
One, | ||
Two | ||
}; | ||
|
||
public FooEnum m_FooEnum; | ||
public float m_f1; | ||
public float m_f2; | ||
public float m_f3; | ||
public string m_s1; | ||
public float m_f8; | ||
public bool m_bool1; | ||
public float m_f4; | ||
public float m_f5; | ||
public bool m_bool2; | ||
public FooBar m_FooBar; | ||
|
||
float m_f6; | ||
float m_f7; | ||
int m_i1; | ||
|
||
public bool bool3 { get; set; } | ||
|
||
public bool bool4 { get; set; } | ||
|
||
public interface IFooInterface | ||
{ | ||
float GetFooValue(int foo); | ||
} | ||
|
||
IFooInterface m_FooProvider; | ||
int m_i2; | ||
|
||
public Bacon( | ||
float minValue, float maxValue, bool wrap, bool rangeLocked, | ||
float maxSpeed, float accelTime, float decelTime, | ||
string name, bool invert) | ||
{ | ||
m_f4 = minValue; | ||
m_f5 = maxValue; | ||
m_bool2 = wrap; | ||
bool3 = rangeLocked; | ||
|
||
bool4 = false; | ||
m_FooBar = new FooBar(false, 1, 2); | ||
|
||
m_FooEnum = FooEnum.One; | ||
m_f1 = maxSpeed; | ||
m_f2 = accelTime; | ||
m_f3 = decelTime; | ||
Value = (minValue + maxValue) / 2; | ||
m_s1 = name; | ||
m_f8 = 0; | ||
m_bool1 = invert; | ||
|
||
m_f6 = 0f; | ||
m_FooProvider = null; | ||
m_i2 = 0; | ||
m_f7 = 0; | ||
m_i1 = 0; | ||
} | ||
|
||
public struct FooBar | ||
{ | ||
public bool m_FooBar_bool1; | ||
public float m_FooBar_f1; | ||
public float m_FooBar_f2; | ||
|
||
float m_FooBar_f3; | ||
float m_FooBar_f4; | ||
float m_FooBar_f5; | ||
int m_FooBar_i1; | ||
int m_FooBar_i2; | ||
|
||
public FooBar(bool b1, float f1, float f2) | ||
{ | ||
m_FooBar_bool1 = b1; | ||
m_FooBar_f1 = f1; | ||
m_FooBar_f2 = f2; | ||
m_FooBar_f4 = 0; | ||
m_FooBar_f5 = 0; | ||
m_FooBar_i1 = m_FooBar_i2 = -1; | ||
m_FooBar_f3 = 0; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/tests/JIT/Regression/JitBlue/Runtime_82535/Runtime_82535.csproj
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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<Optimize>True</Optimize> | ||
<RequiresProcessIsolation>true</RequiresProcessIsolation> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</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 |
---|---|---|
|
@@ -66,6 +66,9 @@ | |
<ExcludeList Include="$(XunitTestBinBase)/GC/Regressions/Github/Runtime_76219/Runtime_76219/*"> | ||
<Issue>https://github.com/dotnet/runtime/issues/78899</Issue> | ||
</ExcludeList> | ||
<ExcludeList Include="$(XunitTestBinBase)/JIT/Regression/JitBlue/Runtime_82535/*"> | ||
<Issue>https://github.com/dotnet/runtime/pull/82663</Issue> | ||
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. 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. Will make one. |
||
</ExcludeList> | ||
</ItemGroup> | ||
|
||
<!-- All Unix targets on all runtimes --> | ||
|
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.
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 does this require process isolation?
RequiresProcessIsolation
adds extra costs that the JIT team is actively working on reducing right now. Throwing and catching a nullref doesn't sounds like something that would need it.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.
It caused a process crash on CI, which doesn't seem to happen any more.