Skip to content

Host component import function parameters should take borrowed values #5050

Closed

Description

@pchickey

Feature

Host component import function parameters should take borrowed values.

Presently, the arguments to a host component import function (as provided to wasmtime::component::LinkerInstance::func_wrap) have to implement IntoComponentFunc, whose argument list is required to impl Lift. Lift does not allow borrowed values. So, these import functions are passed String or Vec<u8> when it would be better for them to accept &str or &[u8].

Benefit

Passing in a borrowed value will reduce the number of copies required to output lists. A borrowed value would be able to point to memory in a guest linear memory, whereas an owned value requires a copy out of linear memory.

The implementation of a synchronous fd_write would benefit from this optimization.

Activity

  1. added
    wasm-proposal:component-model
    on Oct 12, 2022
  2. pchickey commented on Oct 13, 2022

    @pchickey
    ContributorAuthor

    I got this wrong. Borrowed values are available in parameters to import funcs via WasmStr and WasmList. Wasmtime has what we need, so I'll file an issue on wit-bindgen to use them.

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

    wasm-proposal:component-model

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions