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

Describe a primitive reactor ABI. #256

Merged
merged 3 commits into from
Apr 20, 2020

Conversation

sunfishcode
Copy link
Member

This adds a new reactor ABI, indicated by exporting the function
"_activate". For now, a reactor is just a module which doesn't have
a lifetime scoped by a "_start" or "main" function, though it may
evolve to include other semantics in the future.

This adds a new reactor ABI, indicated by exporting the function
"_activate". For now, a reactor is just a module which doesn't have
a lifetime scoped by a "_start" or "main" function, though it may
evolve to include other semantics in the future.
@sunfishcode
Copy link
Member Author

I should also mention, a lot of people are already effectively using reactor-style modules in practice. This change just allows us to support this use case properly, as it allows the C++ and libc runtimes to initialize themselves.

design/application-abi.md Outdated Show resolved Hide resolved
design/application-abi.md Show resolved Hide resolved
Copy link
Member

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

sunfishcode added a commit to sunfishcode/wasmtime that referenced this pull request Apr 15, 2020
This adds support for the WASI reactor ABI proposed in
WebAssembly/WASI#256, as well as the existing
_start ABI for commands.

This also implements the semantics that command instances should not
persist after their _start function is called. As a safety measure,
this includes a check that the instance refcount is 1, so that other
references to the instance don't hold it live.

Implementing that prompted a change to how the main Instance API works.
Instead having instances eagerly compute a Vec of Externs, and bumping
the refcount for each Extern, compute Externs on demand.

This also means that the closure returned by `get0` and friends now
holds an `InstanceHandle` to dynamically hold the instance live rather
than being scoped to a lifetime.

- `_start` - the program entry point
- `memory` - linear memory used by the program
- A *command* exports a function named `_start`, with no arguments and no return

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially off topic, but why not pass some configuration data to _start?

For example, the function could receive the command line args, the allowed paths, etc. These would be through interface types, of course.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. There are a lot of things we could do here, but we need interface types to do them well. The current argv/environ interfaces we have now aren't super amazing, and _start isn't a great name, and so on, but at the moment it all works well enough that it doesn't seem worth breaking compatibility until we have a big reason for it, like interface types.

@sunfishcode
Copy link
Member Author

As I mentioned in this comment, this ABI is expected to change in the future, so this won't be the final word here, but it is simple solution to a present problem, so let's move forward.

@sunfishcode sunfishcode merged commit d8b286c into WebAssembly:master Apr 20, 2020
@sunfishcode sunfishcode deleted the reactor-crt branch April 20, 2020 22:52
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

Successfully merging this pull request may close these issues.

3 participants