-
Notifications
You must be signed in to change notification settings - Fork 565
[NativeAOT] Move GC bridge processing from C++ to C# #10748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
8
commits into
main
Choose a base branch
from
copilot/move-gc-bridge-to-csharp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+539
−698
Conversation
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
- Add BridgeProcessing.cs with managed implementation of bridge processing - Add new native methods for managed processing mode - Update ManagedValueManager to use managed processing loop - Update gc-bridge.hh with new managed processing APIs Co-authored-by: simonrozsival <[email protected]>
Removed files: - src/native/clr/host/bridge-processing.cc - src/native/clr/include/host/bridge-processing.hh - src/native/clr/include/host/bridge-processing-shared.hh - src/native/nativeaot/host/bridge-processing.cc - src/native/nativeaot/include/host/bridge-processing.hh Updated files to remove references to deleted files: - src/native/clr/host/CMakeLists.txt - src/native/nativeaot/host/CMakeLists.txt - src/native/clr/host/gc-bridge.cc - src/native/nativeaot/host/host.cc Co-authored-by: simonrozsival <[email protected]>
Co-authored-by: simonrozsival <[email protected]>
Co-authored-by: simonrozsival <[email protected]>
Copilot
AI
changed the title
[WIP] Move GC bridge code from C++ to C#
[NativeAOT] Move GC bridge processing from C++ to C#
Jan 30, 2026
- Remove clr_initialize_gc_bridge P/Invoke (old callback mode never used) - Remove initialize_callback() function from gc-bridge.hh - Remove bridge_processing() function (native background thread loop) - Remove bridge_processing_started_callback and bridge_processing_finished_callback - Remove bridge_processing_thread and managed_processing_mode flag - Remove unused includes (thread, shared_mutex, unordered_map) - Remove BridgeProcessingStartedFtn and BridgeProcessingFinishedFtn typedefs This eliminates 2 reverse p/invokes per GC cycle that were never used. Co-authored-by: simonrozsival <[email protected]>
Co-authored-by: simonrozsival <[email protected]>
…idge The autogenerated file was out of sync with the source after removing clr_initialize_gc_bridge and adding the new managed processing mode functions. Co-authored-by: simonrozsival <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Moves GC bridge processing logic from native C++ to managed C#, reducing native code complexity and eliminating reverse p/invokes.
Changes
New C# Implementation
BridgeProcessing.cs: Port ofbridge-processing.cchandling SCC preparation, cross-reference setup, weak/global ref conversionManagedValueManager.cs: Managed background thread replaces native thread, callsBridgeProcessing.Process()directlyRemoved C++ Files
src/native/clr/host/bridge-processing.ccsrc/native/clr/include/host/bridge-processing.hhsrc/native/clr/include/host/bridge-processing-shared.hhsrc/native/nativeaot/host/bridge-processing.ccsrc/native/nativeaot/include/host/bridge-processing.hhSimplified
gc-bridge.hh/ccinitialize_callback(),bridge_processing(), callback pointers, thread managementclr_initialize_gc_bridgeP/Invokepinvoke-tables.includeP/Invoke Changes
New forward p/invokes:
The native
mark_cross_referencescallback remains in C++ as required by the runtime.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.