Move shadow space reservation to x86_64 makecontext #15434
Merged
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.
This has been puzzling me for a while, and working on #15409 I finally took the time to investigate.
The shadow space (or home space) is a requirement of the x64 call convention: we must reserve 32 bytes before the return address on the stack. It only applies to x64, not to arm64 for example.
We don't have to deal with this when creating the stack. This is a consideration for each individual
makecontext
to handle.Explanation:
The old version for win32:
The new version (actually the old non-win32 version):
In both versions
stack_ptr
point to thelastfirst (the stack grows down) addressableVoid*
in the stack and is aligned to 16 bytes.Then the new x86_64-microsoft variant of
makecontext
reserves 32 bytes of shadow space (still aligned to 16 bytes) and the rest ofmakecontext
is still aligned to 16 bytes.References: