-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[NativeAOT] thread suspension on Unix #71187
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
Merged
Merged
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
363dbee
missing pieces
VSadov 8ad2f99
fixes
VSadov 0e8ef45
pThreadToHijack
VSadov c393715
NATIVE_CONTEXT
VSadov 815cfb2
at safe point
VSadov 09af4f1
enable TestConcurrentIsBackgroundProperty
VSadov 22851f4
couple tweaks
VSadov 349f25f
fixes after rebasing
VSadov 819706d
temporarily do not handle multireg returns
VSadov d808039
support single reg return hijack
VSadov 0154a90
disable return hijacking for ARM64
VSadov 2499330
enable safe point suspend
VSadov 8406314
enable multireg
VSadov 9c7c9ab
make gcc happy
VSadov c3c3f1a
fixws for win-x64
VSadov 464f3a9
Do not wait for Unhijack.
VSadov cf113a5
crude check for VirtualUnwind issue in inline suspend and some tweaks
VSadov 88adef7
disable hijacking on ARM64/UNIX
VSadov a16f63e
preserve xmm1
VSadov 59b9b0b
IsUnwindable check
VSadov d9af8d6
detect not-unwindable code, at least the most common cases.
VSadov ee8a3d4
IsUnwindable tweaks
VSadov c78a93d
detect epilogs
VSadov 21bcb53
hijack in epilogues.
VSadov e23afbb
PR feedback (refactoring)
VSadov a477f94
Check the trap flag in `HijackCallback` (optimization)
VSadov e3c7ad4
Apply suggestions from code review
VSadov 626a983
PR feedback (refactor/renames)
VSadov 460a3ce
handle "int 3" as not unwindable, not hijackable.
VSadov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ enum GCRefKind : unsigned char | |
| GCRK_Scalar = 0x00, | ||
| GCRK_Object = 0x01, | ||
| GCRK_Byref = 0x02, | ||
| #ifdef TARGET_ARM64 | ||
| #ifdef TARGET_64BIT | ||
| // Composite return kinds for value types returned in two registers (encoded with two bits per register) | ||
| GCRK_Scalar_Obj = (GCRK_Object << 2) | GCRK_Scalar, | ||
| GCRK_Obj_Obj = (GCRK_Object << 2) | GCRK_Object, | ||
|
|
@@ -66,20 +66,54 @@ inline GCRefKind TransitionFrameFlagsToReturnKind(uint64_t transFrameFlags) | |
| return returnKind; | ||
| } | ||
|
|
||
| // Extract individual GCRefKind components from a composite return kind | ||
| inline GCRefKind ExtractReg0ReturnKind(GCRefKind returnKind) | ||
| inline GCRefKind ExtractReg1ReturnKind(GCRefKind returnKind) | ||
| { | ||
| ASSERT(returnKind <= GCRK_LastValid); | ||
| return (GCRefKind)(returnKind & (GCRK_Object | GCRK_Byref)); | ||
| return (GCRefKind)(returnKind >> 2); | ||
| } | ||
|
|
||
| #elif defined(TARGET_AMD64) | ||
|
|
||
| // Verify that we can use bitwise shifts to convert from GCRefKind to PInvokeTransitionFrameFlags and back | ||
| C_ASSERT(PTFF_RAX_IS_GCREF == ((uint64_t)GCRK_Object << 16)); | ||
| C_ASSERT(PTFF_RAX_IS_BYREF == ((uint64_t)GCRK_Byref << 16)); | ||
| C_ASSERT(PTFF_RDX_IS_GCREF == ((uint64_t)GCRK_Scalar_Obj << 16)); | ||
| C_ASSERT(PTFF_RDX_IS_BYREF == ((uint64_t)GCRK_Scalar_Byref << 16)); | ||
|
|
||
| inline uint64_t ReturnKindToTransitionFrameFlags(GCRefKind returnKind) | ||
| { | ||
| if (returnKind == GCRK_Scalar) | ||
| return 0; | ||
|
|
||
| return PTFF_SAVE_RAX | PTFF_SAVE_RDX | ((uint64_t)returnKind << 16); | ||
| } | ||
|
|
||
| inline GCRefKind TransitionFrameFlagsToReturnKind(uint64_t transFrameFlags) | ||
| { | ||
| GCRefKind returnKind = (GCRefKind)((transFrameFlags & (PTFF_RAX_IS_GCREF | PTFF_RAX_IS_BYREF | PTFF_RDX_IS_GCREF | PTFF_RDX_IS_BYREF)) >> 16); | ||
| #if defined(TARGET_UNIX) | ||
| ASSERT((returnKind == GCRK_Scalar) || ((transFrameFlags & PTFF_SAVE_RAX) && (transFrameFlags & PTFF_SAVE_RDX))); | ||
| #else | ||
| ASSERT((returnKind == GCRK_Scalar) || (transFrameFlags & PTFF_SAVE_RAX)); | ||
| #endif | ||
| return returnKind; | ||
| } | ||
|
|
||
| inline GCRefKind ExtractReg1ReturnKind(GCRefKind returnKind) | ||
| { | ||
| ASSERT(returnKind <= GCRK_LastValid); | ||
| return (GCRefKind)(returnKind >> 2); | ||
| } | ||
|
|
||
| #endif // TARGET_ARM64 | ||
|
|
||
| // Extract individual GCRefKind components from a composite return kind | ||
| inline GCRefKind ExtractReg0ReturnKind(GCRefKind returnKind) | ||
| { | ||
| ASSERT(returnKind <= GCRK_LastValid); | ||
| return (GCRefKind)(returnKind & (GCRK_Object | GCRK_Byref)); | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ExtractReg1ReturnKind can be moved here as well. |
||
| // | ||
| // MethodInfo is placeholder type used to allocate space for MethodInfo. Maximum size | ||
| // of the actual method should be less or equal to the placeholder size. | ||
|
|
@@ -162,6 +196,8 @@ class ICodeManager | |
| virtual uintptr_t GetConservativeUpperBoundForOutgoingArgs(MethodInfo * pMethodInfo, | ||
| REGDISPLAY * pRegisterSet) = 0; | ||
|
|
||
| virtual bool IsUnwindable(PTR_VOID pvAddress) = 0; | ||
|
|
||
| virtual bool GetReturnAddressHijackInfo(MethodInfo * pMethodInfo, | ||
| REGDISPLAY * pRegisterSet, // in | ||
| PTR_PTR_VOID * ppvRetAddrLocation, // out | ||
|
|
||
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.