From fdf7062b630b1b6f92b6acdafef3d7a3db0f90d3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Oct 2025 14:35:34 +0000 Subject: [PATCH 1/2] Initial plan From edc28f5f562c0436fe4ce9479b8fe4f4c8bce379 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Oct 2025 15:00:13 +0000 Subject: [PATCH 2/2] Fix issue 121066: Update HelperCallProperties for INITCLASS and add test case Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com> --- src/coreclr/jit/utils.cpp | 2 +- .../JitBlue/Runtime_121066/Runtime_121066.cs | 100 ++++++++++++++++++ .../Runtime_121066/Runtime_121066.csproj | 12 +++ 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_121066/Runtime_121066.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_121066/Runtime_121066.csproj diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index ac7674d70ca7d9..98e11c71ff371b 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -1727,7 +1727,7 @@ void HelperCallProperties::init() case CORINFO_HELP_INITCLASS: case CORINFO_HELP_INITINSTCLASS: - isPure = true; + mutatesHeap = true; mayRunCctor = true; break; diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_121066/Runtime_121066.cs b/src/tests/JIT/Regression/JitBlue/Runtime_121066/Runtime_121066.cs new file mode 100644 index 00000000000000..5b8426c2e0ea80 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_121066/Runtime_121066.cs @@ -0,0 +1,100 @@ +// 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 Xunit; + +public class Runtime_121066 +{ + public static int preciseInitCctorsRun = 0; + + class MyPreciseInitClass + { + static MyPreciseInitClass() + { + preciseInitCctorsRun++; + } + + public static void TriggerCctorClass() + { + } + + public static void TriggerCctorMethod() + { } + } + + class MyClass + { + static Type staticVarType = typeof(MyClass); + public Type GetTypeOf() + { + return typeof(MyClass); + } + public static Type GetTypeOfStatic() + { + return typeof(MyClass); + } + + public static Type GetTypeThroughStaticVar() + { + return staticVarType; + } + } + + [Fact] + public static void TestEntryPoint() + { + Assert.True(TestPreciseInitCctors()); + } + + public static bool TestPreciseInitCctors() + { + if (preciseInitCctorsRun != 0) + { + Console.WriteLine("preciseInitCctorsRun should be 0, but is {0}", preciseInitCctorsRun); + return false; + } + MyPreciseInitClass.TriggerCctorClass(); + if (preciseInitCctorsRun != 1) + { + Console.WriteLine("preciseInitCctorsRun should be 1, but is {0}", preciseInitCctorsRun); + return false; + } + MyPreciseInitClass.TriggerCctorMethod(); + if (preciseInitCctorsRun != 2) + { + Console.WriteLine("TriggerCctorClass should return 2, but is {0}", preciseInitCctorsRun); + return false; + } + + object o = new MyPreciseInitClass(); + if (preciseInitCctorsRun != 3) + { + Console.WriteLine("TriggerCctorClass should return 3, but is {0}", preciseInitCctorsRun); + return false; + } + + MyPreciseInitClass.TriggerCctorClass(); + if (preciseInitCctorsRun != 4) + { + Console.WriteLine("preciseInitCctorsRun should be 4 but is {0}", preciseInitCctorsRun); + return false; + } + MyPreciseInitClass.TriggerCctorMethod(); + if (preciseInitCctorsRun != 5) + { + Console.WriteLine("TriggerCctorClass should return 5, but is {0}", preciseInitCctorsRun); + return false; + } + + o = new MyPreciseInitClass(); + if (preciseInitCctorsRun != 6) + { + Console.WriteLine("TriggerCctorClass should return 6, but is {0}", preciseInitCctorsRun); + return false; + } + + return true; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_121066/Runtime_121066.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_121066/Runtime_121066.csproj new file mode 100644 index 00000000000000..7488f34a9b11ac --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_121066/Runtime_121066.csproj @@ -0,0 +1,12 @@ + + + None + True + + true + + + + + +