Module dev_wasm.erl¶
A device that executes a WASM image on messages using the Memory-64 preview standard.
Description¶
In the backend, this device uses beamr
: An Erlang wrapper
for WAMR, the WebAssembly Micro Runtime.
The device has the following requirements and interface:
M1/Init ->
Assumes:
M1/process
M1/[Prefix]/image
Generates:
/priv/[Prefix]/instance
/priv/[Prefix]/import-resolver
Side-effects:
Creates a WASM executor loaded in memory of the HyperBEAM node.
M1/Compute ->
Assumes:
M1/priv/[Prefix]/instance
M1/priv/[Prefix]/import-resolver
M1/process
M2/message
M2/message/function OR M1/function
M2/message/parameters OR M1/parameters
Generates:
/results/[Prefix]/type
/results/[Prefix]/output
Side-effects:
Calls the WASM executor with the message and process.
M1/[Prefix]/state ->
Assumes:
M1/priv/[Prefix]/instance
Generates:
Raw binary WASM state
Function Index¶
basic_execution_64_test/0* | |
basic_execution_test/0* | |
benchmark_test/0* | |
cache_wasm_image/1 | |
cache_wasm_image/2 | |
compute/3 | Call the WASM executor with a message that has been prepared by a prior pass. |
default_import_resolver/3* | Take a BEAMR import call and resolve it using hb_ao . |
import/3 | Handle standard library calls by: 1. |
imported_function_test/0* | |
info/2 | Export all functions aside the instance/3 function. |
init/0* | |
init/3 | Boot a WASM image on the image stated in the process/image field of
the message. |
init_test/0* | |
input_prefix_test/0* | |
instance/3 | Get the WASM instance from the message. |
normalize/3 | Normalize the message to have an open WASM instance, but no literal
State key. |
process_prefixes_test/0* | Test that realistic prefixing for a dev_process works --
including both inputs (from Process/ ) and outputs (to the
Device-Key) work. |
snapshot/3 | Serialize the WASM state to a binary. |
state_export_and_restore_test/0* | |
terminate/3 | Tear down the WASM executor. |
test_run_wasm/4* | |
undefined_import_stub/3* | Log the call to the standard library as an event, and write the call details into the message. |
Function Details¶
basic_execution_64_test/0 *¶
basic_execution_64_test() -> any()
basic_execution_test/0 *¶
basic_execution_test() -> any()
benchmark_test/0 *¶
benchmark_test() -> any()
cache_wasm_image/1¶
cache_wasm_image(Image) -> any()
cache_wasm_image/2¶
cache_wasm_image(Image, Opts) -> any()
compute/3¶
compute(RawM1, M2, Opts) -> any()
Call the WASM executor with a message that has been prepared by a prior pass.
default_import_resolver/3 *¶
default_import_resolver(Msg1, Msg2, Opts) -> any()
Take a BEAMR import call and resolve it using hb_ao
.
import/3¶
import(Msg1, Msg2, Opts) -> any()
Handle standard library calls by:
1. Adding the right prefix to the path from BEAMR.
2. Adding the state to the message at the stdlib path.
3. Resolving the adjusted-path-Msg2 against the added-state-Msg1.
4. If it succeeds, return the new state from the message.
5. If it fails with not_found
, call the stub handler.
imported_function_test/0 *¶
imported_function_test() -> any()
info/2¶
info(Msg1, Opts) -> any()
Export all functions aside the instance/3
function.
init/0 *¶
init() -> any()
init/3¶
init(M1, M2, Opts) -> any()
Boot a WASM image on the image stated in the process/image
field of
the message.
init_test/0 *¶
init_test() -> any()
input_prefix_test/0 *¶
input_prefix_test() -> any()
instance/3¶
instance(M1, M2, Opts) -> any()
Get the WASM instance from the message. Note that this function is exported such that other devices can use it, but it is excluded from calls from AO-Core resolution directly.
normalize/3¶
normalize(RawM1, M2, Opts) -> any()
Normalize the message to have an open WASM instance, but no literal
State
key. Ensure that we do not change the hashpath during this process.
process_prefixes_test/0 *¶
process_prefixes_test() -> any()
Test that realistic prefixing for a dev_process
works --
including both inputs (from Process/
) and outputs (to the
Device-Key) work
snapshot/3¶
snapshot(M1, M2, Opts) -> any()
Serialize the WASM state to a binary.
state_export_and_restore_test/0 *¶
state_export_and_restore_test() -> any()
terminate/3¶
terminate(M1, M2, Opts) -> any()
Tear down the WASM executor.
test_run_wasm/4 *¶
test_run_wasm(File, Func, Params, AdditionalMsg) -> any()
undefined_import_stub/3 *¶
undefined_import_stub(Msg1, Msg2, Opts) -> any()
Log the call to the standard library as an event, and write the call details into the message.