Refactor NativeAOT helpers to align with CoreCLR patterns#121158
Merged
Refactor NativeAOT helpers to align with CoreCLR patterns#121158
Conversation
Co-authored-by: jkotas <[email protected]>
…e.cs Co-authored-by: jkotas <[email protected]>
Copilot
AI
changed the title
[WIP] Refactor ArrayHelpers and TypedReferenceHelpers files
Refactor NativeAOT helpers to align with CoreCLR patterns
Oct 29, 2025
jkotas
reviewed
Oct 29, 2025
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.NativeAot.cs
Show resolved
Hide resolved
jkotas
reviewed
Oct 29, 2025
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.NativeAot.cs
Show resolved
Hide resolved
jkotas
reviewed
Oct 29, 2025
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.NativeAot.cs
Outdated
Show resolved
Hide resolved
jkotas
reviewed
Oct 29, 2025
src/coreclr/nativeaot/System.Private.CoreLib/src/System/TypedReference.cs
Outdated
Show resolved
Hide resolved
jkotas
reviewed
Oct 29, 2025
src/coreclr/nativeaot/System.Private.CoreLib/src/System/TypedReference.cs
Outdated
Show resolved
Hide resolved
jkotas
reviewed
Oct 29, 2025
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs
Outdated
Show resolved
Hide resolved
jkotas
reviewed
Oct 29, 2025
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs
Outdated
Show resolved
Hide resolved
jkotas
reviewed
Oct 29, 2025
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs
Outdated
Show resolved
Hide resolved
…efAny, use GetCoreLibEntryPoint Co-authored-by: jkotas <[email protected]>
jkotas
reviewed
Oct 29, 2025
src/coreclr/System.Private.CoreLib/src/System/TypedReference.CoreCLR.cs
Outdated
Show resolved
Hide resolved
jkotas
reviewed
Oct 29, 2025
src/coreclr/nativeaot/System.Private.CoreLib/src/System/TypedReference.cs
Outdated
Show resolved
Hide resolved
jkotas
reviewed
Oct 29, 2025
src/coreclr/nativeaot/System.Private.CoreLib/src/System/TypedReference.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: jkotas <[email protected]>
jkotas
reviewed
Jan 1, 2026
jkotas
reviewed
Jan 1, 2026
src/coreclr/nativeaot/Test.CoreLib/src/System/RuntimeTypeHandle.cs
Outdated
Show resolved
Hide resolved
jkotas
reviewed
Jan 1, 2026
Co-authored-by: jkotas <[email protected]>
jkotas
reviewed
Jan 1, 2026
Member
|
@MichalStrehovsky @jkoritzinsky Incremental step to make NAOT and non-NAOT more similar |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors NativeAOT helper methods to align with CoreCLR patterns by moving helper implementations from dedicated helper classes (ArrayHelpers.cs and TypedReferenceHelpers.cs) into their appropriate target types. This makes the NativeAOT and CoreCLR code structures more similar and improves code organization.
Key changes:
- Consolidates array construction helpers from
ArrayHelpers.csintoSystem.ArrayasCtorandCtorRaremethods - Moves TypedReference-related helpers from
TypedReferenceHelpers.csintoSystem.TypedReference,System.Type, andSystem.RuntimeTypeHandle - Updates JIT compiler entry points and helper references across CoreCLR and NativeAOT to use the new method locations
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/qcallentrypoints.cpp | Renamed QCall entry point from Array_CreateInstanceMDArray to Array_Ctor |
| src/coreclr/vm/corelib.h | Updated method definition from CREATEINSTANCEMDARRAY to CTOR |
| src/coreclr/vm/arraynative.h | Changed function signature from Array_CreateInstanceMDArray to Array_Ctor with MethodTable* parameter |
| src/coreclr/vm/arraynative.cpp | Updated implementation to use MethodTable* directly instead of EnregisteredTypeHandle |
| src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs | Updated helper entry point mappings for GETSYNCFROMCLASSHANDLE and GETCLASSFROMMETHODPARAM |
| src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs | Updated dependency references to use new helper locations |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs | Updated all helper entry points to reference new method locations in System types |
| src/coreclr/nativeaot/Test.CoreLib/src/System/Type.cs | Added GetTypeFromMethodTable method implementation |
| src/coreclr/nativeaot/Test.CoreLib/src/System/RuntimeTypeHandle.cs | Added GetRuntimeTypeHandleFromMethodTable method and removed LdTokenHelpers class |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/TypedReference.cs | Added GetRefAny method and removed RawTargetTypeToken usage |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Type.NativeAot.cs | Added GetTypeFromMethodTableMaybeNull and updated GetTypeFromMethodTable documentation |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Monitor.NativeAot.cs | Removed GetSyncObjectFromClassHandle and GetClassHandleFromMethodParam methods |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs | Added GetRuntimeTypeHandleFromMethodTable implementation |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.NativeAot.cs | Added Ctor and CtorRare methods, moved NewMultiDimArray earlier, updated GetNormalizedIntegralArrayElementType call |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj | Removed ArrayHelpers.cs and TypedReferenceHelpers.cs from compilation |
| src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/TypedReferenceHelpers.cs | Deleted entire file - functionality moved to TypedReference |
| src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/SharedCodeHelpers.cs | Added GetClassHandleFromMethodParam method moved from Monitor |
| src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/LdTokenHelpers.cs | Removed GetRuntimeTypeHandle and GetRuntimeType methods |
| src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/ArrayHelpers.cs | Deleted entire file - functionality moved to Array |
| src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/TypeCast.cs | Made GetNormalizedIntegralArrayElementType internal and added overload for EETypeElementType |
| src/coreclr/inc/jithelpers.h | Updated method references from CREATEINSTANCEMDARRAY to CTOR |
| src/coreclr/System.Private.CoreLib/src/System/TypedReference.CoreCLR.cs | Moved GetRefAny method to end of file |
| src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs | Renamed CreateInstanceMDArray to Ctor with updated signature |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/TypedReference.cs
Show resolved
Hide resolved
...r/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/SharedCodeHelpers.cs
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Type.NativeAot.cs
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs
Show resolved
Hide resolved
MichalStrehovsky
approved these changes
Jan 2, 2026
This was referenced Jan 9, 2026
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Move helper methods from
ArrayHelpers.csandTypedReferenceHelpers.csto their appropriate target types and other changes to make NativeAOT and non-NativeAOT structure to be more similar.