-
Notifications
You must be signed in to change notification settings - Fork 60
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
ABI for syscall
and call
instructions
#685
Labels
kernels
Related to transaction, batch, or block kernels
refactoring
Code clean-ups, improvements, and refactoring
Milestone
Comments
This was referenced Aug 25, 2024
Closed by #971. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kernels
Related to transaction, batch, or block kernels
refactoring
Code clean-ups, improvements, and refactoring
The current ABI that we use for making
syscall
s andcall
s is quite confusing (I know I came up with it at some point, but after not thinking about it for a while, it is difficult even for me to figure out what's the right place to pad the stack etc.). So, I'm thinking we should adapt some simple rules - even if they are slightly less efficient.The core issue that creates complexity is that after a
syscall
or acall
from the callee's standpoint, the stack is only 16 elements deep, but the caller may have other data on the stack. So, for example, the below procedure when invoked viaexec
would just drop 4 elements from the stack, but ifcall
-ed orsyscall
-ed, it would also "shift-in" 4 elements at the end of the stack.To illustrate:
This creates an awkward situation when we need to compensate for this shifting in by doing something like:
Basically, the called procedure is responsible for maintaining the integrity of the stack for the caller.
Instead, I'm thinking we should have the following rule:
When invoking a procedure that is supposed to be
call
-ed orsyscall
-ed say that the elements at the top of the stack which are not return values should be assumed to be garbage upon return.For example:
So, the caller will be responsible for padding the top of the stack with extra zeros (or w/e other values), and the callee would be responsible for making sure that the stack is exactly 16 elements deep upon return without worrying about maintaining the values on the top of the stack.
This would result in some more push/drop operations for the caller - but would probably be slightly more efficient for the callee.
Another side-effect is that we may not be able to execute the same procedure using
call
/syscall
andexec
. Forsyscall
s that's not an issue, but for calls it may be. But I think this is probably fine as we should move away from allowing the same procedure to be bothcall
-able andexec
-able (and hopefully, soon we'll have annotations in MASM to support this).cc @bitwalker @greenhat
The text was updated successfully, but these errors were encountered: