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

Add wasmtime-specific C APIs for tables #1654

Merged

Conversation

alexcrichton
Copy link
Member

This commit adds a suite of wasmtime_funcref_table_* APIs which mirror
the standard APIs but have a few differences:

  • More errors are returned. For example error messages are communicated
    through wasmtime_error_t and out-of-bounds vs load of null can be
    differentiated in the get API.

  • APIs take wasm_func_t instead of wasm_ref_t. Given the recent
    decision to remove subtyping from the anyref proposal it's not clear
    how the C API for tables will be affected, so for now these APIs are
    all specialized to only funcref tables.

  • Growth now allows access to the previous size of the table, if
    desired, which mirrors the table.grow instruction.

This was originally motivated by bytecodealliance/wasmtime-go#5 where
the current APIs we have for working with tables don't quite work. We
don't have a great way to take an anyref constructed from a Func and
get the Func back out, so for now this sidesteps those concerns while
we sort out the anyref story.

It's intended that once the anyref story has settled and the official C
API has updated we'll likely delete these wasmtime-specific APIs or
implement them as trivial wrappers around the official ones.

This commit adds a suite of `wasmtime_funcref_table_*` APIs which mirror
the standard APIs but have a few differences:

* More errors are returned. For example error messages are communicated
  through `wasmtime_error_t` and out-of-bounds vs load of null can be
  differentiated in the `get` API.

* APIs take `wasm_func_t` instead of `wasm_ref_t`. Given the recent
  decision to remove subtyping from the anyref proposal it's not clear
  how the C API for tables will be affected, so for now these APIs are
  all specialized to only funcref tables.

* Growth now allows access to the previous size of the table, if
  desired, which mirrors the `table.grow` instruction.

This was originally motivated by bytecodealliance/wasmtime-go#5 where
the current APIs we have for working with tables don't quite work. We
don't have a great way to take an anyref constructed from a `Func` and
get the `Func` back out, so for now this sidesteps those concerns while
we sort out the anyref story.

It's intended that once the anyref story has settled and the official C
API has updated we'll likely delete these wasmtime-specific APIs or
implement them as trivial wrappers around the official ones.
@alexcrichton
Copy link
Member Author

Also FWIW I've tested these through the Python/Go extensions (bindings written), so it should hopefully be working!

@github-actions github-actions bot added the wasmtime:c-api Issues pertaining to the C API. label May 4, 2020
@github-actions
Copy link

github-actions bot commented May 4, 2020

Subscribe to Label Action

cc @peterhuene

This issue or pull request has been labeled: "wasmtime:c-api"

Thus the following users have been cc'd because of the following labels:

  • peterhuene: wasmtime:c-api

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@sunfishcode
Copy link
Member

I agree; this feels like functionality that we won't want in wasmtime-specific APIs, but for now, this works.

@sunfishcode sunfishcode merged commit 1247f2b into bytecodealliance:master May 13, 2020
alexcrichton added a commit to bytecodealliance/wasmtime-go that referenced this pull request May 14, 2020
alexcrichton added a commit to bytecodealliance/wasmtime-go that referenced this pull request May 14, 2020
@alexcrichton alexcrichton deleted the wasmtime-func-table-apis branch September 9, 2021 15:13
X-leaf7 added a commit to X-leaf7/wasmtime-go that referenced this pull request Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:c-api Issues pertaining to the C API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants