WebAssembly / WebAssembly/component-model

Working with GC types without copy

Open
#305 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pre-1.0
Dominant language
WebAssembly
Stars
1.4k
Forks
130
Avg merge
2d 1h
Merged PRs (30d)
15

Description

I'm having some trouble switching to wasi preview 2.

For example, the following interface:

package wasi:random@0.2.0;
interface random {
    get-random-bytes: func(len: u64) -> list<u8>;
}

The function signature is func (u64) -> (list<u8>)

But its lower type is core func (i64, i32) -> (), which is very difficult to use.

If I want to convert it to core type (array (mut u8)), a very long glue code is required.


I hope to add a GC mode canon option that can make the lower type similar to core func (i64) -> (array u8).

For complex nested types, getting the specified data requires very complex pointer algebra, whereas if using array it only requires multiple array.get.

I think this helps simplify the use of some external interfaces, such as:

package wasi:filesystem@0.2.0;
interface preopens {
    get-directories: func() -> list<tuple<descriptor, string>>;
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the issue's WASI Preview 2 WIT examples and the stated lower signatures for random and preopens. Investigate how the proposed GC mode canon option would affect list and nested list<tuple<descriptor, string>> lowering. Done should be a clearly specified, reviewed design for the option and its compatibility with these examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.