Skip to content

Comments

Remove unused PInvokeTransitionFrame_MAX_SIZE and PInvokeTransitionFrame_SaveRegs_count macros#124627

Merged
MichalStrehovsky merged 2 commits intomainfrom
copilot/remove-dead-macro-pinvoke-transition-frame
Feb 20, 2026
Merged

Remove unused PInvokeTransitionFrame_MAX_SIZE and PInvokeTransitionFrame_SaveRegs_count macros#124627
MichalStrehovsky merged 2 commits intomainfrom
copilot/remove-dead-macro-pinvoke-transition-frame

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

PInvokeTransitionFrame_MAX_SIZE and its dependency PInvokeTransitionFrame_SaveRegs_count (defined conditionally for AMD64/x86/ARM) in src/coreclr/nativeaot/Runtime/inc/rhbinder.h are never referenced anywhere else in the repository.

Description

Removes 12 lines of dead code from rhbinder.h:

  • PInvokeTransitionFrame_SaveRegs_count — the three platform-conditional definitions (TARGET_AMD64=9, TARGET_X86=6, TARGET_ARM=9)
  • PInvokeTransitionFrame_MAX_SIZE — the macro consuming the above
Original prompt

Summary

The macro PInvokeTransitionFrame_MAX_SIZE is defined in src/coreclr/nativeaot/Runtime/inc/rhbinder.h but is never referenced or used anywhere else in the repository. It should be removed as dead code.

Details

Definition location

src/coreclr/nativeaot/Runtime/inc/rhbinder.h

#define PInvokeTransitionFrame_MAX_SIZE (sizeof(PInvokeTransitionFrame) + (POINTER_SIZE * PInvokeTransitionFrame_SaveRegs_count))

This macro depends on PInvokeTransitionFrame_SaveRegs_count, which is itself only defined for TARGET_AMD64, TARGET_X86, and TARGET_ARM — meaning PInvokeTransitionFrame_MAX_SIZE is only conditionally meaningful for those three targets.

A code search across the entire dotnet/runtime repository confirms that PInvokeTransitionFrame_MAX_SIZE is never used outside of its definition.

Task

  • Remove the #define PInvokeTransitionFrame_MAX_SIZE ... line from src/coreclr/nativeaot/Runtime/inc/rhbinder.h.
  • Also remove the PInvokeTransitionFrame_SaveRegs_count definitions (for TARGET_AMD64, TARGET_X86, and TARGET_ARM) immediately above it, if they are also not used anywhere else in the repository.
  • Verify no other files reference either macro before removing them.

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ame_SaveRegs_count macros

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove unused PInvokeTransitionFrame_MAX_SIZE macro Remove unused PInvokeTransitionFrame_MAX_SIZE and PInvokeTransitionFrame_SaveRegs_count macros Feb 20, 2026
@dotnet-policy-service
Copy link
Contributor

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

@MichalStrehovsky MichalStrehovsky marked this pull request as ready for review February 20, 2026 07:01
Copilot AI review requested due to automatic review settings February 20, 2026 07:01
@MichalStrehovsky MichalStrehovsky merged commit ab11a45 into main Feb 20, 2026
103 of 105 checks passed
@MichalStrehovsky MichalStrehovsky deleted the copilot/remove-dead-macro-pinvoke-transition-frame branch February 20, 2026 07:01
Copy link
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

Removes dead, unused macros from the NativeAOT runtime binder header (rhbinder.h) to reduce unused platform-conditional code and avoid maintaining unused ABI-related constants.

Changes:

  • Remove PInvokeTransitionFrame_SaveRegs_count platform-conditional macro definitions.
  • Remove PInvokeTransitionFrame_MAX_SIZE macro that depended on PInvokeTransitionFrame_SaveRegs_count.

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.

3 participants