Skip to content

Define function signatures #127

Closed
Closed

Description

@steveluc

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.

Activity

  1. sunfishcode commented on Jun 9, 2015

    @sunfishcode
    Member

    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.

  2. steveluc commented on Jun 9, 2015

    @steveluc
    Author

    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?

  3. sunfishcode commented on Jun 9, 2015

    @sunfishcode
    Member

    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.

  4. jfbastien commented on Jun 9, 2015

    @jfbastien
    Member

    We've punted ABI discussion to later: there currently isn't any way that this is meaningfully exposed through wasm. Once dynamic linking is available we'll need to figure something out, but even then it isn't clear it'll be an issue. See #98 and #53 for further discussion.

  5. sunfishcode commented on Jul 22, 2015

    @sunfishcode
    Member

    #278 is a pull request which defines function signatures.

  6. added this to the MVP milestone on Jul 28, 2015
  7. sunfishcode commented on Aug 21, 2015

    @sunfishcode
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions