Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pangoraw/wasmtime.jl
🏃♀️🏃♂️ ⏳ A Julia wrapper for wasmtime
https://github.com/pangoraw/wasmtime.jl
julia-package wasm
Last synced: 26 days ago
JSON representation
🏃♀️🏃♂️ ⏳ A Julia wrapper for wasmtime
- Host: GitHub
- URL: https://github.com/pangoraw/wasmtime.jl
- Owner: Pangoraw
- License: mit
- Created: 2021-05-20T19:40:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-03T21:51:30.000Z (about 1 year ago)
- Last Synced: 2024-07-09T19:11:29.243Z (4 months ago)
- Topics: julia-package, wasm
- Language: Julia
- Homepage:
- Size: 135 KB
- Stars: 11
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wasmtime.jl
A Julia wrapper around the wasmtime runtime to run Web Assembly blobs and libraries from Julia.
## Examples
```julia
julia> using Wasmtimejulia> code = wat"""
(module
(memory 1);; adds two consecutive f32 located at
;; address $ptr in memory
(func $sum (param $ptr i32)
(result f32)
local.get $ptr
f32.load
local.get 0
i32.const 4
i32.add
f32.load
f32.add
)(export "sum" (func $sum))
(export "memory" (memory 0))
)
""";julia> engine = WasmEngine(); store = Wasmtime.WasmtimeStore(engine);
julia> module_ = Wasmtime.WasmtimeModule(engine, code);
julia> instance = Wasmtime.WasmtimeInstance(store, module_);
julia> (; memory, sum) = exports(instance);
julia> buf = reinterpret(Float32, memory); # memory is an AbstractVector{UInt8}
julia> buf[1] = 32.5f0; buf[2] = 3f0;
julia> sum(Int32(0))
35.5f0julia> buf[1] + buf[2]
35.5f0
```## Usage
Wastime exposes two C api. The first one is the common Web Assembly runtime C api with names starting with `Wasm` in Wasmtime.jl.
The second one is a wasmtime specific api which provides more functionality like WASI imports, fine-grained configuration
of the store features like fuel.See the [`test` folder](https://github.com/Pangoraw/Wasmtime.jl/tree/main/test) for usage examples.