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

call_indirect #114

Closed
kg opened this issue Oct 6, 2015 · 3 comments
Closed

call_indirect #114

kg opened this issue Oct 6, 2015 · 3 comments

Comments

@kg
Copy link
Contributor

kg commented Oct 6, 2015

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.

@lukewagner
Copy link
Member

As discussed in the meeting today, @titzer is going to file a design repo PR and then we'll update ml-proto to match.

@rossberg
Copy link
Member

rossberg commented Oct 7, 2015

FWIW, what's currently implemented was based on (my understanding of)
v8-prototype and AstSemantics as of 2 months ago. It's pretty
straightforward. Each table has to be homogeneously typed, and
call_indirect derives and checks its type statically based on the static
table index. It also takes a dynamic index, which is the index into this
table. An out-of-bounds static index is a static error, an out-of-bounds
dynamic index is a runtime error.

As for symbolic indices, when I introduced them I didn't bother with tables
because it already looked like their design was about to change.

The syntax for defining a function table appears to be (table

<table_number> ) where:

Not sure where you got that from. It's what the README says: (table <var>*), where every var is a function index.

@lukewagner
Copy link
Member

Resolved in #136.

alexcrichton pushed a commit to alexcrichton/spec that referenced this issue Nov 18, 2019
eqrion pushed a commit to eqrion/wasm-spec that referenced this issue Nov 25, 2019
Incorporate active/passive segments into instantiation. While doing so, drop the notion of segment types as well as initelem/initdata administrative instructions and express the latter in terms of table.init and memory.init instructions. Adjust interpreter accordingly.
Connicpu pushed a commit to Connicpu/wasm-spec that referenced this issue May 11, 2020
This tests the `WebAssembly.Memory` constructor and the `grow` method.

* Memory.buffer should be frozen and not extensible when shared
* Don't check isFrozen during grow (constructor test is sufficient)
* Don't check stray argument in shared memory detach test
dhil pushed a commit to dhil/webassembly-spec that referenced this issue Oct 3, 2023
rossberg added a commit that referenced this issue Apr 23, 2024
More fixes and tests around element segments
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