-
Notifications
You must be signed in to change notification settings - Fork 5k
Replace Win32 PAL implementation with minipal implementation #115858
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
base: main
Are you sure you want to change the base?
Replace Win32 PAL implementation with minipal implementation #115858
Conversation
Remove PALCEnterCriticalSection and PALCLeaveCriticalSection
Delete unused debugging APIs in PAL CS code
Get native AOT to build.
Tagging subscribers to this area: @mangod9 |
FWIW, I tested |
Remove any non-running tests requiring CRITICAL_SECTION Remove unused PAL header referencing CRITICAL_SECTION (internal.h)
It isn't just because of
clang on macOS doesn't support C11 threads. It isn't an option in any case. |
If the implementation is shared between:
This PR is mixing the existing pattern. |
|
If there is a plan to share this impl. with other subsets, then it makes sense. Otherwise, choosing among |
@@ -490,7 +487,7 @@ LONG WINAPI RhpVectoredExceptionHandler(PEXCEPTION_POINTERS pExPtrs) | |||
|
|||
// Do not use ASSERT_UNCONDITIONALLY here. It will crash because of it consumes too much stack. | |||
PalPrintFatalError("\nProcess is terminating due to StackOverflowException.\n"); | |||
RaiseFailFastException(pExPtrs->ExceptionRecord, pExPtrs->ContextRecord, 0); | |||
PalRaiseFailFastException(pExPtrs->ExceptionRecord, pExPtrs->ContextRecord, 0); |
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 is Windows-specific code calling Windows-specific API. There is no point going through a PAL layer in cases like these.
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.
I see. The problem with this model is there is an odd consistency in files. It isn't obvious/clear on when we can avoid the PAL. If this file was clearly in a "windows" directory it would be obvious. In this case though we have 100s of lines of code that are defined/included in complex ways that make it tricky to know. If we instead just implement a PAL consistently we can use the simple rule of "only use PAL APIs". I'll change it, but I don't think this is a helpful way of writing code in a file that isn't defined as being platform specific.
See the other "Pal" functions in the same block.
This PR removes the PAL Win32 emulation of
CRITICAL_SECTION
. The emulation logic is unnecessarily complicated and used both a pthread mutex and condition variable. For CoreCLR purposes a mutex is sufficient.A new minipal API was introduced,
minipal_critsect
. This uses the Win32CRITICAL_SECTION
on the Windows platform andpthread_mutex_t
on all other platforms. This implementation aligns with a private "critical section" defined for the GC and native AOT. All now use this new API.The
CRITICAL_SECTION
associated APIs and tests in the CoreCLR PAL have been removed.