-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Implement GC bridge VM support in NativeAOT #117738
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
Conversation
b165d80
to
1562a55
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Port CoreCLR’s Java GC bridge support into the NativeAOT runtime and enable related tests and build logic across both runtimes.
- Remove the NativeAotIncompatible flag from the GC bridge test project to allow NativeAOT runs.
- Add managed QCall stubs and NativeAOT implementations in JavaMarshal.NativeAot.cs, RuntimeImports.cs, and associated interop code.
- Update CMakeLists and project files to conditionally include JavaMarshal/CoreCLR and NativeAOT sources under
FEATURE_JAVAMARSHAL
.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
src/tests/Interop/GCBridge/BridgeTest.csproj | Remove <NativeAotIncompatible> so tests can run under NativeAOT |
src/libraries/System.Private.CoreLib/.../JavaMarshal.Unsupported.cs | Add unsupported-platform stubs throwing PlatformNotSupportedException |
src/libraries/System.Private.CoreLib/...Shared.projitems | Conditionally include JavaMarshal.cs when FeatureJavaMarshal is false |
src/coreclr/vm/interoplibinterface_java.cpp | Switch from free to delete[] /delete for GC bridge arguments |
src/coreclr/nativeaot/System.Private.CoreLib/...RuntimeImports.cs | Introduce new RuntimeImport QCalls for cross-reference handle APIs |
src/coreclr/nativeaot/System.Private.CoreLib/...JavaMarshal.NativeAot.cs | Implement JavaMarshal methods for NativeAOT with argument checks and QCalls |
src/coreclr/nativeaot/System.Private.CoreLib/...GCHandle.NativeAot.cs | Hook GCHandle into the GC bridge wait logic via JavaMarshal |
src/coreclr/nativeaot/System.Private.CoreLib/...System.Private.CoreLib.csproj | Include JavaMarshal.NativeAot.cs only when FeatureJavaMarshal is true |
src/coreclr/nativeaot/Runtime/interoplibinterface_java.cpp | Full NativeAOT GC bridge implementation and event coordination |
src/coreclr/nativeaot/Runtime/interoplibinterface.h | Declare JavaMarshalNative::TriggerClientBridgeProcessing under FEATURE_JAVAMARSHAL |
src/coreclr/nativeaot/Runtime/gcenv.ee.cpp | Forward GCToEEInterface::TriggerClientBridgeProcessing to the new NativeAOT code |
src/coreclr/nativeaot/Runtime/HandleTableHelpers.cpp | Implement RhpHandleAllocCrossReference and context lookup in the handle table |
src/coreclr/nativeaot/Runtime/CMakeLists.txt | Add interoplibinterface_java.cpp and gcbridge.cpp to nativeaot sources |
src/coreclr/nativeaot/CMakeLists.txt | Define and propagate the FEATURE_JAVAMARSHAL compile flag |
src/coreclr/System.Private.CoreLib/...JavaMarshal.CoreCLR.cs | Remove old NATIVEAOT/FEATURE_JAVAMARSHAL #if blocks to unify implementation |
src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj | Conditionally include JavaMarshal.CoreCLR.cs based on FeatureJavaMarshal |
Comments suppressed due to low confidence (2)
src/tests/Interop/GCBridge/BridgeTest.csproj:6
- [nitpick] You’ve enabled the test project for NativeAOT by removing the incompatibility flag—please add or update tests in BridgeTest to cover the new JavaMarshal GC bridge behavior under NativeAOT.
<GCStressIncompatible>true</GCStressIncompatible>
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.NativeAot.cs:19
- [nitpick] InternalGetBridgeWait calls JavaMarshal.WaitForGCBridgeFinish without any SupportedOSPlatform annotation. Consider adding [SupportedOSPlatform("android")] (or another appropriate attribute) to this method rather than suppressing CA1416, so platform compatibility requirements are explicit.
internal static object? InternalGetBridgeWait(IntPtr handle)
1562a55
to
4b84e8b
Compare
...eaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Java/JavaMarshal.NativeAot.cs
Show resolved
Hide resolved
...lr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.NativeAot.cs
Outdated
Show resolved
Hide resolved
...oreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Java/JavaMarshal.CoreCLR.cs
Show resolved
Hide resolved
...lr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.NativeAot.cs
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs
Outdated
Show resolved
Hide resolved
The build failures are all either known issues or timeouts. Can we get this merged? I'd like to test it but it would be significantly easier to do so once it flows through the arcade so I only need to rebuild the Android workload and not the whole stack. |
/ba-g wasm timeouts |
🙏🏿 |
Port over the CoreCLR VM implementation to NativeAOT.