Skip to content

Dead-code cleanup: HandleTableMap multi-bucket / multi-AppDomain scaffolding#128646

Merged
max-charlamb merged 4 commits into
mainfrom
copilot/dead-code-cleanup-handle-table-map
May 28, 2026
Merged

Dead-code cleanup: HandleTableMap multi-bucket / multi-AppDomain scaffolding#128646
max-charlamb merged 4 commits into
mainfrom
copilot/dead-code-cleanup-handle-table-map

Conversation

Copilot AI commented May 27, 2026

Copy link
Copy Markdown
Contributor

Since dotnet/coreclr#23588 (April 2019) removed AppDomain-per-process support, g_HandleTableMap has had exactly one node and CreateHandleStore has had zero callers. The supporting scaffolding was never cleaned up.

Changes

Tier B.1 — ABI-preserving stubs (gchandletable.cpp)

  • GCHandleStore::Uproot, GCHandleStore::ContainsHandle, GCHandleManager::CreateHandleStore bodies replaced with assert(!"…dead path…"). Vtable slots preserved for GC_INTERFACE_MAJOR_VERSION 5 ABI compatibility with external standalone GC implementations. The #ifndef FEATURE_NATIVEAOT split in CreateHandleStore is unified into a single stub.

Tier A — internal removal (objecthandle.cpp, objecthandle.h)

  • Ref_InitializeHandleTableBucket removed (definition + header declaration); its only caller was CreateHandleStore.
  • HandleTableBucketHolder is retained — still used by Ref_Initialize.

Net ~90 lines removed, no behavior change. The assert stubs convert previously silent dead code into loud regression detection.

…B.1)

Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 27, 2026 13:57
Copilot AI removed the request for review from Copilot May 27, 2026 13:57
Copilot AI requested a review from max-charlamb May 27, 2026 13:58
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@max-charlamb max-charlamb marked this pull request as ready for review May 27, 2026 17:58
Copilot AI review requested due to automatic review settings May 27, 2026 17:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 removes now-unused multi-bucket / multi-AppDomain handle-table scaffolding in CoreCLR’s GC handle table implementation and replaces legacy, effectively-unreachable ABI surface with assert-based stubs to preserve vtable layout.

Changes:

  • Removes Ref_InitializeHandleTableBucket (declaration + definition) since it no longer has in-tree callers.
  • Replaces GCHandleStore::Uproot, GCHandleStore::ContainsHandle, and GCHandleManager::CreateHandleStore implementations with assert stubs (while keeping the vtable slots) and returns safe defaults (false / nullptr).
  • Simplifies CreateHandleStore by removing the FEATURE_NATIVEAOT split in favor of a single stub.

Reviewed changes

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

File Description
src/coreclr/gc/objecthandle.h Removes the unused Ref_InitializeHandleTableBucket declaration.
src/coreclr/gc/objecthandle.cpp Removes the unused Ref_InitializeHandleTableBucket implementation.
src/coreclr/gc/gchandletable.cpp Stubs out legacy virtual methods with asserts to keep ABI/vtable shape while making the path loudly unreachable in checked/debug builds.

Comment thread src/coreclr/gc/gchandletable.cpp Outdated
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>

@max-charlamb max-charlamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot , please address

Comment thread src/coreclr/gc/gchandletable.cpp Outdated
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 27, 2026 20:06

Copilot AI commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot , please address

Addressed in 03b551b. Updated CreateHandleStore to use the same dead-path comment/assert message style as the methods above.

Copilot AI requested a review from max-charlamb May 27, 2026 20:07
@max-charlamb max-charlamb requested a review from jkotas May 27, 2026 20:14

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@max-charlamb max-charlamb enabled auto-merge (squash) May 27, 2026 21:38
Copilot AI review requested due to automatic review settings May 28, 2026 13:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

@max-charlamb

Copy link
Copy Markdown
Member

/ba-g All test failures are known issues or caused by Helix issues on amd64 osx

@max-charlamb max-charlamb merged commit 267d0f4 into main May 28, 2026
109 of 114 checks passed
@max-charlamb max-charlamb deleted the copilot/dead-code-cleanup-handle-table-map branch May 28, 2026 19:07
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 17, 2026
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