Skip to content

Use CodeRangeMapRangeList for callcounting stubs and remove unneeded StubManagers#126521

Merged
rcj1 merged 4 commits intodotnet:mainfrom
rcj1:refactor-callcounting-rangelist
Apr 9, 2026
Merged

Use CodeRangeMapRangeList for callcounting stubs and remove unneeded StubManagers#126521
rcj1 merged 4 commits intodotnet:mainfrom
rcj1:refactor-callcounting-rangelist

Conversation

@rcj1
Copy link
Copy Markdown
Contributor

@rcj1 rcj1 commented Apr 3, 2026

In order to figure out if a specific address is a callcounting stub, we currently have to iterate through the call counting stub allocators to figure out which one, if any, owns the address. If we switch call counting stubs to use CodeRangeMapRangeList, the type of the code can easily be looked up from the cDAC in the RangeSectionMap.

Removed EnumMem of the call counting stub heap. We now have the same enumeration as other CodeRangeMapRangeList users. That is, the RangeSection metadata allows lookup of the code type etc, but the actual bytes of the stubs are not explicitly included in a heap dump.

Relevant for

pStubManager = StubManager::FindStubManager(TO_TADDR(address));

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 migrates call-counting stubs to be tracked via CodeRangeMapRangeList so the stub kind can be identified directly from the RangeSectionMap (including via cDAC), avoiding iteration over call-counting stub allocators. It also aligns call-counting stub enumeration behavior with other CodeRangeMapRangeList users by no longer explicitly EnumMem-enumerating the stub heap bytes.

Changes:

  • Add a new stub kind (STUB_CODE_BLOCK_CALLCOUNTING) and route RangeSection-based stub identification/tracing to CallCountingStubManager.
  • Switch call-counting stub allocation tracking from RangeList to CodeRangeMapRangeList.
  • Adjust includes/forward-decls to break prior header dependencies and support the new range list type.

Reviewed changes

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

Show a summary per file
File Description
src/coreclr/vm/stubmgr.cpp Recognizes call-counting stubs via RangeSectionStubManager and forwards tracing/name lookups accordingly.
src/coreclr/vm/loaderallocator.hpp Removes direct include of callcounting.h; adds forward decl/DPTR for CallCountingManager.
src/coreclr/vm/common.h Adds callcounting.h include to preserve transitive visibility of call-counting types.
src/coreclr/vm/codeman.h Introduces STUB_CODE_BLOCK_CALLCOUNTING and string mapping for RangeSection-reported stub kinds.
src/coreclr/vm/callcounting.h Switches allocator tracking to CodeRangeMapRangeList; adjusts visibility for RangeSection forwarding.
src/coreclr/vm/callcounting.cpp Initializes CodeRangeMapRangeList for call-counting stub heaps; removes old stub-range checks and DAC heap range enumeration.

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@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.

@rcj1 rcj1 changed the title Use CodeRangeMapRangeList for callcounting stubs Use CodeRangeMapRangeList for callcounting stubs and remove unneeded StubManagers Apr 5, 2026
Copilot AI review requested due to automatic review settings April 6, 2026 16:55
Copy link
Copy Markdown
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks

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 11 out of 11 changed files in this pull request and generated 4 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 6, 2026 18:03
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 11 out of 11 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

Nice simplification 👍

@rcj1 rcj1 merged commit 62b476b into dotnet:main Apr 9, 2026
113 of 115 checks passed
@rcj1 rcj1 deleted the refactor-callcounting-rangelist branch April 9, 2026 14:33
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.

4 participants