Use NoSafepointVerifier + avoid extra safepoint in Unsafe_CopySwapMemory0#2
Merged
fisk merged 4 commits intofisk:8310644_panama_async_handshake_closefrom Nov 24, 2023
Conversation
fisk
pushed a commit
that referenced
this pull request
Dec 8, 2025
1. Misc test fixes 2. Removed HeapShared::orig_to_scratch_object(), which is not GC safe and doesn't work with ZGC 3. Removed AOTCacheAccess::test_heap_access_api(), which depends on #2; this is no longer needed as the AOT code compiler makes extensive use of heap access APIs in AOTCacheAccess.
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
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.
Use
NoSafepointVerifierto verify that we don't actually get a safepoint after checking for async exception handshake. Not every unsafe function is compatible with this, so I've introduced a newUNSAFE_ENTRY_SCOPEDmacro that can be used for unsafe functions called in the context of@Scopedmethods (from ScopedMemoryAccess).Unsafe_CopySwapMemory0was actually polling for safepoint halfway into the function. This function tries to stay in the native thread state for off-heap -> off-heap copies, to avoid blocking the GC, and then lazily transitions to VM state when heap memory is involved. I've flipped this around so that we instead lazily transition to native state when we do a pure off-heap copy. I believe this is also required for safely checking for async exception handshakes, as we potentially take a lock for that, so should be in VM mode (I think?). Unfortunately, this means that we will now have 2 thread state transitions for the purely off-heap case: one from native to VM when the function is entered, and one from VM to native just before the copy. While unfortunate, I don't see a good way around this, as we need to check for async exception handshakes upon entering the method in case of any previous safepoint poll having installed a handshake. The additional state transitions could be avoided by intrinsifying the method, similar to how Unsafe_CopyMemory0 is already intrinsified.