WebAssembly / WebAssembly/component-model

Add Canonical ABI option for opposite of `post-return`

Open
#289 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The post-return canonopt provides a way for components to clean up allocated result values after the caller has read them.

It would also be valuable to provide components a way to set things up before the arguments are allocated and copied in. This could be achieved by adding another canonopt (named e.g. pre-param, pre-call, pre-alloc) which allows Components to specify a core function that is called at the beginning of a Component function call before parameters are allocated.

As a specific use case, toolchains may want to use a bump allocator whose lifecycle is tied to a single Component function call for function parameters, internal data, and return values. Using this new canonopt, it would be trivial to set it up before params are allocated and tear it down using post-return after return values have been consumed.

You can implement this currently by creating a bump allocator at startup time and then resetting it at post-return but I believe that when concurrency using async (and potentially threads/shared?) comes in and multiple calls (and as a result multiple bump allocators) are alive at the same time this simple pattern will no longer work.

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

The issue does not name files, tests, or entry points. Start by locating the Canonical ABI specification and the existing post-return canonopt handling; done means specifying and implementing a pre-call allocation hook whose lifecycle complements post-return, including behavior for concurrent calls.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.