Skip to content

Reapply "Inline CORINFO_HELP_ARRADDR_ST helper call, remove WriteBarr… …ier FCall" (#126530)#126547

Draft
EgorBo wants to merge 4 commits intodotnet:mainfrom
EgorBo:reapply-stelemref-inlining
Draft

Reapply "Inline CORINFO_HELP_ARRADDR_ST helper call, remove WriteBarr… …ier FCall" (#126530)#126547
EgorBo wants to merge 4 commits intodotnet:mainfrom
EgorBo:reapply-stelemref-inlining

Conversation

@EgorBo
Copy link
Copy Markdown
Member

@EgorBo EgorBo commented Apr 4, 2026

CI test

Copilot AI review requested due to automatic review settings April 4, 2026 17:43
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reintroduces JIT inlining for CORINFO_HELP_ARRADDR_ST and replaces the old CastHelpers.WriteBarrier FCall plumbing with a managed RuntimeHelpers.WriteBarrier intrinsic that the JIT expands into an explicit heap store/write-barrier operation.

Changes:

  • Introduces RuntimeHelpers.WriteBarrier(ref object? dst, object? obj) as an intrinsic and updates stelem-ref paths to use it instead of an InternalCall/FCall-based helper.
  • Updates the JIT to (a) recognize/expand the new WriteBarrier intrinsic and (b) convert CORINFO_HELP_ARRADDR_ST helper calls into managed user-call equivalents to enable inlining (with fallback handling in morphing).
  • Removes JIT_WriteBarrier_Callable and associated mapping/exports across multiple architectures (arm/arm64/amd64/i386/riscv64/loongarch64/wasm) and removes the corresponding ecall list entries.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs Adds intrinsic RuntimeHelpers.WriteBarrier in CoreLib.
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs Removes InternalCall WriteBarrier and switches stelem-ref writes to RuntimeHelpers.WriteBarrier; adds AggressiveInlining on StelemRef.
src/coreclr/vm/ecalllist.h Removes CastHelpers.WriteBarrier FCFunc/FCClass registration.
src/coreclr/vm/jitinterface.h Removes JIT_WriteBarrier_Callable declaration and WriteBarrier_Helper macro.
src/coreclr/vm/amd64/jithelpers_fast.S Removes JIT_WriteBarrier_Callable stub.
src/coreclr/vm/amd64/JitHelpers_Fast.asm Removes JIT_WriteBarrier_Callable stub.
src/coreclr/vm/i386/jithelp.S Removes JIT_WriteBarrier_Callable stub.
src/coreclr/vm/i386/jithelp.asm Removes JIT_WriteBarrier_Callable stub.
src/coreclr/vm/arm/asmhelpers.S Removes JIT_WriteBarrier_Callable stub.
src/coreclr/vm/arm64/asmhelpers.S Removes JIT_WriteBarrier_Callable stub.
src/coreclr/vm/arm64/asmhelpers.asm Removes JIT_WriteBarrier_Callable stub.
src/coreclr/vm/riscv64/asmhelpers.S Removes JIT_WriteBarrier_Callable stub.
src/coreclr/vm/loongarch64/asmhelpers.S Removes JIT_WriteBarrier_Callable stub.
src/coreclr/vm/wasm/helpers.cpp Removes unimplemented JIT_WriteBarrier_Callable stub for wasm.
src/coreclr/jit/namedintrinsiclist.h Adds NI_System_Runtime_CompilerServices_RuntimeHelpers_WriteBarrier.
src/coreclr/jit/importercalls.cpp Adds intrinsic expansion for WriteBarrier and introduces impConvertToUserCallAndMarkForInlining.
src/coreclr/jit/importer.cpp Converts CORINFO_HELP_ARRADDR_ST helper call to user call and marks for inlining during import.
src/coreclr/jit/morph.cpp Adjusts ARRADDR_ST morphing to accept helper or user-equivalent calls; converts back to helper if not inlined.
src/coreclr/jit/gentree.h Declares IsHelperCallOrUserEquivalent.
src/coreclr/jit/gentree.cpp Implements IsHelperCallOrUserEquivalent; updates tree display for new intrinsic.
src/coreclr/jit/compiler.h Adds HelperToManagedMap storage/accessors for helper-to-managed call mapping.
src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CompilerServices/RuntimeHelpers.cs Adds intrinsic RuntimeHelpers.WriteBarrier for NativeAOT Runtime.Base.
src/coreclr/nativeaot/Test.CoreLib/src/System/Runtime/RuntimeHelpers.cs Adds intrinsic RuntimeHelpers.WriteBarrier for Test.CoreLib.
src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/InternalCalls.cs Removes InternalCalls.RhpAssignRef import.
src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/TypeCast.cs Switches stelem-ref write barrier calls from InternalCalls.RhpAssignRef to RuntimeHelpers.WriteBarrier.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 4, 2026 22:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

@EgorBo EgorBo closed this Apr 5, 2026
@EgorBo EgorBo reopened this Apr 5, 2026
@EgorBo
Copy link
Copy Markdown
Member Author

EgorBo commented Apr 5, 2026

ugh.. I guess CI is totally dead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants