Skip to content

call_indirect #114

@kg

Description

@kg

It's unclear how to use call_indirect and it doesn't seem to align well with the design repo.

As far as I can tell, call_indirect has roughly this syntax in spec right now:
(call_indirect <table_number> <function_index> <args>), where:

  • table_number is an integer literal - symbols don't work for some non-obvious reason
  • function_index is an expression that evaluates to an integer
  • args is obvious

The addressof primitive expected for getting function indices does not appear to exist. My assumption is that the code generator is expected to hard-code an index as it exists in the tables defined by the module.

The syntax for defining a function table appears to be (table <table_number> <function> <function>) where:

  • table_number is an integer literal - symbols fail to parse, as do bare words and quoted strings
  • function is just a symbol or function index, like in export.
    Presumably this generates a function table with id table_number containing the provided functions in order, starting at 0 (1?)

Various questions remain that I can't easily figure out from reading the source:

  • What happens if the signature of call_indirect is a mismatch from the signature of the function the pointer is aimed at?
  • Are tables allowed to be heterogeneous?
  • Why do we have multiple tables in a single module to begin with?

I am probably wrong about some of this since I still haven't managed to write a functioning module that uses call_indirect, but I'll update once I do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions