From 6be685a99df65317c03e552ff8dc008400ecfbd1 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Wed, 24 Jun 2020 19:45:03 -0500 Subject: [PATCH] wasi: add reactor support PR-URL: https://github.com/nodejs/node/pull/34046 Reviewed-By: Guy Bedford Reviewed-By: Colin Ihrig --- doc/api/wasi.md | 17 ++ lib/wasi.js | 90 ++++++--- test/wasi/test-wasi-initialize-validation.js | 195 +++++++++++++++++++ test/wasi/test-wasi-start-validation.js | 9 +- 4 files changed, 278 insertions(+), 33 deletions(-) create mode 100644 test/wasi/test-wasi-initialize-validation.js diff --git a/doc/api/wasi.md b/doc/api/wasi.md index 46673af9e7fb34..9fe004ea599cfc 100644 --- a/doc/api/wasi.md +++ b/doc/api/wasi.md @@ -132,6 +132,23 @@ Attempt to begin execution of `instance` as a WASI command by invoking its If `start()` is called more than once, an exception is thrown. +### `wasi.initialize(instance)` + + +* `instance` {WebAssembly.Instance} + +Attempt to initialize `instance` as a WASI reactor by invoking its +`_initialize()` export, if it is present. If `instance` contains a `_start()` +export, then an exception is thrown. + +`initialize()` requires that `instance` exports a [`WebAssembly.Memory`][] named +`memory`. If `instance` does not have a `memory` export an exception is thrown. + +If `initialize()` is called more than once, an exception is thrown. + ### `wasi.wasiImport`