Skip to content
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

Stack alignment #40

Closed
Amanieu opened this issue Sep 2, 2016 · 3 comments
Closed

Stack alignment #40

Amanieu opened this issue Sep 2, 2016 · 3 comments

Comments

@Amanieu
Copy link
Collaborator

Amanieu commented Sep 2, 2016

Some platforms have requirements regarding stack alignment on function entry (16 bytes for x86, x86_64 and aarch64, 8 bytes for arm). Should it be the Stack's responsibility to ensure alignment or should the context initialization perform a suitable alignment (by aligning the address returned by Stack::base)?

@Amanieu
Copy link
Collaborator Author

Amanieu commented Sep 2, 2016

As a side note, we should probably be using the "alignstack" inline asm modifier on all platforms since it is specifically designed for asm that performs function calls.

@whitequark
Copy link
Contributor

Should it be the Stack's responsibility to ensure alignment or should the context initialization perform a suitable alignment (by aligning the address returned by Stack::base)?

Stack's. The less complexity in per-platform code, the better; and 16 bytes is at the moment the highest common alignment. This should be documented as Stack's contract.

@whitequark
Copy link
Contributor

As a side note, we should probably be using the "alignstack" inline asm modifier on all platforms since it is specifically designed for asm that performs function calls.

Using it where exactly and why?

  • We definitely shouldn't be using it in the swap itself, because that forces creation of a frame pointer.
  • There's no point in using it in the swap trampoline.
  • Even if you use it in the init trampoline, you still have to calculate CFI offsets towards the top of the stack, so it brings you no benefit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants