Skip to content

Remove support for WASI #168

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

Merged
merged 2 commits into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions src/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,6 @@ Some language features need support from the host environment to function, yield

The respective implementations of `abort`, `trace` and `seed` can be overridden with, for example, `--use abort=assembly/index/myAbort`, here redirecting calls to `abort` to a custom `myAbort` function in `assembly/index.ts`. Useful if an environment does not provide compatible implementations, or when the respective imports are not desired and custom implementations are sufficient.

#### Targeting WASI

AssemblyScript has experimental support for WASI, which can be targeted by adding `import "wasi"` to the entry file. Doing so will install WASI-aware implementations of `abort`, `trace` and `seed` for example, but will require a polyfill on the Web.

The following additional options may be useful depending on the kind of WASI module to create:

Kind | Command line options | Description
-------------|-----------------------------|-------------
WASI command | `--exportStart _start` | Executes top-level code when the command is invoked
WASI reactor | `--exportStart _initialize` | Executes top-level code when initialized, before other exports are invoked

When targeting WASI, command line options and environment variables can be accessed via the [`process`](/stdlib/process.md) namespace.

### Accessing memory during instantiation

One important edge case to be aware of is that top-level statements are executed as part of the WebAssembly module's implicit `(start ...)` function by default, which leads to a henn and egg problem when top-level statements already call out to external functionality that needs to access the module's memory instance (say, reading the contents of a logged string). Since instantiation did not yet complete, the module's exports, including exported memory, are not available yet and the access will fail.
Expand Down Expand Up @@ -252,12 +239,6 @@ In addition to module-level tree-shaking, the compiler ignores branches that it
}
```

* ```ts
const ASC_WASI: i32
```
A constant only being defined when WASI bindings are used via `import "wasi"`. Can be checked with `isDefined(ASC_WASI)`.


## Code annotations

Decorators work more like compiler annotations in AssemblyScript and are evaluated at compile time.
Expand Down
4 changes: 2 additions & 2 deletions src/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ It likely won't. While TypeScript adds typings to JavaScript, it is a superset a
Computation-heavy logic like image manipulation, hot game logic, specialized algorithms, emulators, compilers and the likes are great use cases for WebAssembly, and as such for AssemblyScript as well. In some situations it may also be preferable to ship bytecode instead of minified JS, or just the ability to utilize a TypeScript-like language may open up new opportunities, for example for embedded scripting or plugins.
:::

::: tip Can AssemblyScript be used outside of the browser?
Absolutely! AssemblyScript modules are self-contained and run anywhere where WebAssembly is supported. There is also the option to [target WASI](/concepts.md#targeting-wasi).
::: tip Can AssemblyScript be used in non-standard ways, say outside of the browser?
Absolutely! AssemblyScript modules are self-contained and run anywhere where WebAssembly is supported. In fact, any arbitrary host interface can be supported. Here is an [example of using WASI imports instead of Web APIs](https://github.com/AssemblyScript/wasi-shim).
:::

::: tip Why the strange name?
Expand Down
2 changes: 1 addition & 1 deletion src/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Some crucial language features rely on [future WebAssembly functionality](https:
| [Component model]<sup>2</sup> | | | <Badge text="harmful" type="error"/>
||
| ❔ **Quasi proposal**
| [WASI]<sup>3</sup> | <Xx/> <Xx/> <Xx/> <No/> <Wt/> <Ws/> | 🔨 | <Badge text="harmful" type="error"/>
| [WASI]<sup>3</sup> | <Xx/> <Xx/> <Xx/> <No/> <Wt/> <Ws/> | | <Badge text="harmful" type="error"/>

<Ch/> <a href="https://www.chromestatus.com/features#webassembly" target="_blank" rel="noopener">Chrome</a> &nbsp;
<Fi/> <a href="https://platform-status.mozilla.org" target="_blank" rel="noopener">Firefox</a> &nbsp;
Expand Down
2 changes: 1 addition & 1 deletion src/stdlib/console.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# console

An implementation of the `console` global. Works with generated [host bindings](../compiler.md#host-bindings) or when [targeting WASI](../concepts.md#targeting-wasi).
An implementation of the `console` global.

## Static members

Expand Down
2 changes: 1 addition & 1 deletion src/stdlib/crypto.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# crypto

An implementation of the `crypto` global. Works with generated [host bindings](../compiler.md#host-bindings) or when [targeting WASI](../concepts.md#targeting-wasi).
An implementation of the `crypto` global.

## Static members

Expand Down
2 changes: 1 addition & 1 deletion src/stdlib/process.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# process

An implementation of a Node.js-like `process` global. Works with generated [host bindings](../compiler.md#host-bindings) under Node.js or when [targeting WASI](../concepts.md#targeting-wasi).
An implementation of a Node.js-like `process` global.

## Static members

Expand Down