-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[mono] Perform the class init at runtime when static fields of BEFORE_FIELD_INIT type are accessed #86787
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
Closed
Closed
[mono] Perform the class init at runtime when static fields of BEFORE_FIELD_INIT type are accessed #86787
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f383984
Removed beforefieldinit check
e331b34
Added 1 testcase which tests the behaviour of beforefieldinit for sta…
49fdbfd
Ignore another before_field_init check to delay the initialization of…
4dcbf8d
Merge branch 'dotnet:main' into beforefieldinit
LeVladIonescu b8e2bef
Remove properties from test's .csproj
17e5867
Merge branch 'dotnet:main' into beforefieldinit
LeVladIonescu 4896388
Merge branch 'dotnet:main' into beforefieldinit
LeVladIonescu bad8f96
Merge branch 'dotnet:main' into beforefieldinit
LeVladIonescu a998abf
Merge branch 'dotnet:main' into beforefieldinit
LeVladIonescu 9f2ad1b
Merge branch 'dotnet:main' into beforefieldinit
LeVladIonescu a509dcd
Changed to Fact instead of having an entry point for the testcase ins…
LeVladIonescu 599d935
Reenable beforefieldinit check for static fields access
LeVladIonescu 62babc5
Merge branch 'dotnet:main' into beforefieldinit
LeVladIonescu 9b3699e
Merge branch 'dotnet:main' into beforefieldinit
LeVladIonescu 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 hidden or 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
42 changes: 42 additions & 0 deletions
42
src/tests/JIT/Methodical/beforefieldinit/StaticFieldInit.cs
This file contains hidden or 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,42 @@ | ||
| // 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; | ||
|
|
||
| static class C | ||
| { | ||
| public static int retVal = 100; | ||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public static int TestMethod(bool cond) | ||
| { | ||
| if (cond) | ||
| { | ||
| // never invoked in this program | ||
| return ClassB.X; | ||
| } | ||
| // always taken | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| public class ClassB | ||
| { | ||
| public static readonly int X = GetX(); | ||
|
|
||
| static int GetX() | ||
| { | ||
| Console.WriteLine("GetX call!..."); // not expected to be invoked in this program | ||
| C.retVal = 42; | ||
| return 42; | ||
| } | ||
| } | ||
|
|
||
| public class StaticFieldInit | ||
| { | ||
| public static int Main () { | ||
| C.TestMethod(false); | ||
|
|
||
| return C.retVal; | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
src/tests/JIT/Methodical/beforefieldinit/StaticFieldInit.csproj
This file contains hidden or 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> | ||
| <RequiresProcessIsolation>true</RequiresProcessIsolation> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <DebugType>PdbOnly</DebugType> | ||
| <Optimize>True</Optimize> | ||
| </PropertyGroup> | ||
lambdageek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <ItemGroup> | ||
| <Compile Include="StaticFieldInit.cs" /> | ||
| </ItemGroup> | ||
| </Project> | ||
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.
Uh oh!
There was an error while loading. Please reload this page.