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

[power] Why is reserved_stack_space added twice when computing slot_offset? #9084

Closed
gretay-js opened this issue Oct 30, 2019 · 2 comments
Closed

Comments

@gretay-js
Copy link
Contributor

reserved_stack_space is already taken into account by frame_size, and then added on explicitly again for Incoming in slot_offset.

| Incoming n -> frame_size() + reserved_stack_space + n

@stedolan
Copy link
Contributor

stedolan commented Nov 4, 2019

After some confused googling, this code turns out to be correct. In the power ABI, there's a reserved area at the bottom of the stack, so stack layouts look like this (growing downwards):

   |          |
   |  locals  |
   |          |
   +----------+
   |          |
   |   args   |
   |          |
   +----------+
   |          |
   | reserved |
   |          |
   +----------+ <-- caller SP
   |          |
   |  locals  |
   |          |
   +----------+
   |          |
   | reserved |
   |          |
   +----------+ <-- callee SP

For the caller to access its incoming arguments, it must add to SP its own frame size (its reserved space + its locals) and then add the callers reserved space. There are two reserved spaces between the callee's stack pointer and the callee's incoming stack arguments!

@stedolan stedolan closed this as completed Nov 4, 2019
@lpw25
Copy link
Contributor

lpw25 commented Nov 4, 2019

Maybe a comment in the code is in order?

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