-
Notifications
You must be signed in to change notification settings - Fork 695
Define function signatures #127
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
Comments
Variable-length parameter lists in C are lowered by the compiler. The caller allocates a stack buffer, stores the variable-length arguments into it, and then passes a pointer to the buffer to the callee. This has the advantage of not requiring any special platform support. Arrays on the stack are allocated on the "addressable stack", which is a convention of using part of the application heap in a stack-like manner for variables that need to be addressable. |
How is it decided how big the addressable stack should be? What does a function signature look like? Is there a variable-length list of local variable indices given as part of the CallDirect function? |
Applications can decide for themselves how big to make the addressable stack. The WebAssembly platform itself doesn't impose any restrictions on the addressable stack. Addressable stack conventions will certainly need to be part of any common ABI though. Multiple return value calls are not yet specified, but they likely will be eventually, in which case a function signature will essentially be just a pair of sequences of local types. The first sequence is for the return values, and the second sequence is for the argument values. A CallDirect function will have an operand for each local type in the argument portion of the signature of the called function. |
#278 is a pull request which defines function signatures. |
Function signatures are defined in #307, which is now merged, along with a note about C varargs. There are also some example functions in the spec test directory. |
It would be helpful in reasoning about ABIs if the Call section of the AST document could give some examples of function signature specifications.
How would this proposal handle variable-length parameter lists?
How do compilers place arrays on the stack? Looks like all of the local variable types are scalar.
The text was updated successfully, but these errors were encountered: