-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Recover some lost EH performance on Unix amd64 #90033
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
Changes from all commits
2453a3e
65f3e4d
0b11601
d506672
9088b7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1880,3 +1880,29 @@ DBG_FlushInstructionCache( | |
| #endif | ||
| return TRUE; | ||
| } | ||
|
|
||
| #ifdef HOST_AMD64 | ||
| CONTEXT& CONTEXT::operator=(const CONTEXT& ctx) | ||
| { | ||
| size_t copySize; | ||
| if (ctx.ContextFlags & CONTEXT_XSTATE & CONTEXT_AREA_MASK) | ||
| { | ||
| if ((ctx.XStateFeaturesMask & XSTATE_MASK_AVX512) == XSTATE_MASK_AVX512) | ||
| { | ||
| copySize = sizeof(CONTEXT); | ||
| } | ||
| else | ||
| { | ||
| copySize = offsetof(CONTEXT, KMask0); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| copySize = offsetof(CONTEXT, XStateFeaturesMask); | ||
| } | ||
|
|
||
| memcpy(this, &ctx, copySize); | ||
|
Member
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. Would it have better performance characteristics to do
Member
Author
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. I had it that way originally (memcpy in each of the arms), but the compiler actually did compute the size first and then called memcpy once. I liked that, so I've transformed the source to the same way. |
||
|
|
||
| return *this; | ||
| } | ||
| #endif // HOST_AMD64 | ||
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.
This change goes against the spirit of the Win32 PAL. The Win32 PAL is meant to mirror the Windows SDK definitions. The Windows SDK definitions of this structure is POD struct without any C++. This makes it C++ struct and behave differently from the Windows SDK definitions that can lead to all sort of surprises.
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.
@jkotas the proper fix in the spirit of the Win32 PAL would be to implement
CopyContext(and maybeInitializeContexttoo) and modify the whole codebase to use that instead of pure assignments of theCONTEXTstructure. That sounded like too extensive change given the number of places we just assignCONTEXTstructs by value in the runtime and the time I had left before the RC1 snapshot.I'd be ok reverting this PR though and going for the cleaner solution if you prefer.
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.
If you are ok with this, I am ok with it too. I wanted to point this difference out since it is likely going to take somebody by surprise at some point.
If you would like to clean it up, it can wait for .NET 9.
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.
Great, I'll leave this checked in and clean it up in 9 then.