wasmtime 0.3.0-x86_64-linux → 0.4.0-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -14
- data/ext/build.rs +8 -0
- data/lib/wasmtime/2.7/wasmtime_rb.so +0 -0
- data/lib/wasmtime/3.0/wasmtime_rb.so +0 -0
- data/lib/wasmtime/3.1/wasmtime_rb.so +0 -0
- data/lib/wasmtime/version.rb +1 -1
- data/lib/wasmtime.rb +25 -2
- metadata +9 -6
- data/lib/wasmtime/2.7/ext.so +0 -0
- data/lib/wasmtime/3.0/ext.so +0 -0
- data/lib/wasmtime/3.1/ext.so +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d4bbd6fe60e446c784f194aee2d1aa36473000237a06c1d87e7a06656ef591c
|
4
|
+
data.tar.gz: 472059120cc3f6959caebc4bca061fcd766c61ccfda4fcfbb1aa315818770b38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e781487208571c1c5fcb490db087953b597c20194abfa8a7653e7a108c0d1407971db1940ec5162a81ec29b24cb2d7fdd0da1eb48ae8ef55aee5613e7e82172
|
7
|
+
data.tar.gz: d8e07914fc9c09f2532a292406819bced2e356e7cb66893f028dde87536211fd92d9e97d344db24ea2282de4b14ab59076d984ada1faf4e5056018b49f740a2d
|
data/README.md
CHANGED
@@ -15,22 +15,39 @@
|
|
15
15
|
</p>
|
16
16
|
</div>
|
17
17
|
|
18
|
-
##
|
18
|
+
## Goal
|
19
19
|
|
20
|
-
|
20
|
+
`wasmtime-rb`'s goal is to expose the full power of Wasmtime in Ruby with
|
21
|
+
minimal overhead, serving as a foundation layer for other projects or gems.
|
21
22
|
|
22
23
|
## Installation
|
23
24
|
|
24
|
-
|
25
|
+
Add the `wasmtime` gem to your Gemfile and run `bundle install`:
|
25
26
|
|
26
|
-
```
|
27
|
+
```ruby
|
28
|
+
gem "wasmtime"
|
29
|
+
```
|
30
|
+
|
31
|
+
Alternatively, you can install the gem manually:
|
32
|
+
|
33
|
+
```sh
|
27
34
|
gem install wasmtime
|
28
35
|
```
|
29
36
|
|
30
|
-
|
37
|
+
### Precompiled gems
|
31
38
|
|
32
|
-
|
33
|
-
|
39
|
+
We recommend installing the `wasmtime` precompiled gems available for Linux, macOS, and Windows. Installing a precompiled gem avoids the need to compile from source code, which is generally slower and less reliable.
|
40
|
+
|
41
|
+
When installing the `wasmtime` gem for the first time using `bundle install`, Bundler will automatically download the precompiled gem for your current platform. However, you will need to inform Bundler of any additional platforms you plan to use.
|
42
|
+
|
43
|
+
To do this, lock your Bundle to the required platforms you will need from the list of supported platforms below:
|
44
|
+
|
45
|
+
```sh
|
46
|
+
bundle lock --add-platform x86_64-linux # Standard Linux (e.g. Heroku, GitHub Actions, etc.)
|
47
|
+
bundle lock --add-platform x86_64-linux-musl # MUSL Linux deployments (i.e. Alpine Linux)
|
48
|
+
bundle lock --add-platform aarch64-linux # ARM64 Linux deployments (i.e. AWS Graviton2)
|
49
|
+
bundle lock --add-platform x86_64-darwin # Intel MacOS (i.e. pre-M1)
|
50
|
+
bundle lock --add-platform arm64-darwin # Apple Silicon MacOS (i.e. M1)
|
34
51
|
```
|
35
52
|
|
36
53
|
## Usage
|
@@ -41,10 +58,10 @@ Example usage:
|
|
41
58
|
require "wasmtime"
|
42
59
|
|
43
60
|
# Create an engine. Generally, you only need a single engine and can
|
44
|
-
# re-use it
|
61
|
+
# re-use it throughout your program.
|
45
62
|
engine = Wasmtime::Engine.new
|
46
63
|
|
47
|
-
# Compile a Wasm module from either Wasm or WAT.
|
64
|
+
# Compile a Wasm module from either Wasm or WAT. The compiled module is
|
48
65
|
# specific to the Engine's configuration.
|
49
66
|
mod = Wasmtime::Module.new(engine, <<~WAT)
|
50
67
|
(module
|
@@ -57,19 +74,20 @@ WAT
|
|
57
74
|
store = Wasmtime::Store.new(engine, {count: 0})
|
58
75
|
|
59
76
|
# Define a Wasm function from Ruby code.
|
60
|
-
func = Wasmtime::Func.new(store,
|
77
|
+
func = Wasmtime::Func.new(store, [], []) do |caller|
|
61
78
|
puts "Hello from Func!"
|
62
|
-
|
79
|
+
caller.store_data[:count] += 1
|
80
|
+
puts "Ran #{caller.store_data[:count]} time(s)"
|
63
81
|
end
|
64
82
|
|
65
|
-
# Build the Wasm instance by providing its imports
|
83
|
+
# Build the Wasm instance by providing its imports.
|
66
84
|
instance = Wasmtime::Instance.new(store, mod, [func])
|
67
85
|
|
68
86
|
# Run the `run` export.
|
69
87
|
instance.invoke("run")
|
70
88
|
|
71
|
-
# Or: get the `run` export and call it
|
72
|
-
instance.export("run").call
|
89
|
+
# Or: get the `run` export and call it.
|
90
|
+
instance.export("run").to_func.call
|
73
91
|
```
|
74
92
|
|
75
93
|
For more, see [examples](https://github.com/bytecodealliance/wasmtime-rb/tree/main/examples)
|
data/ext/build.rs
ADDED
Binary file
|
Binary file
|
Binary file
|
data/lib/wasmtime/version.rb
CHANGED
data/lib/wasmtime.rb
CHANGED
@@ -5,18 +5,25 @@ require_relative "wasmtime/version"
|
|
5
5
|
# Tries to require the extension for the given Ruby version first
|
6
6
|
begin
|
7
7
|
RUBY_VERSION =~ /(\d+\.\d+)/
|
8
|
-
require "wasmtime/#{Regexp.last_match(1)}/
|
8
|
+
require "wasmtime/#{Regexp.last_match(1)}/wasmtime_rb"
|
9
9
|
rescue LoadError
|
10
|
-
require "wasmtime/
|
10
|
+
require "wasmtime/wasmtime_rb"
|
11
11
|
end
|
12
12
|
|
13
13
|
module Wasmtime
|
14
14
|
class Error < StandardError; end
|
15
15
|
|
16
|
+
# Raised when failing to convert the return value of a Ruby-backed Func to
|
17
|
+
# Wasm types.
|
18
|
+
class ResultError < Error; end
|
19
|
+
|
20
|
+
# Raised when converting an {Extern} to its concrete type fails.
|
16
21
|
class ConversionError < Error; end
|
17
22
|
|
23
|
+
# Raised on Wasm trap.
|
18
24
|
class Trap < Error
|
19
25
|
STACK_OVERFLOW = :stack_overflow
|
26
|
+
MEMORY_OUT_OF_BOUNDS = :memory_out_of_bounds
|
20
27
|
HEAP_MISALIGNED = :heap_misaligned
|
21
28
|
TABLE_OUT_OF_BOUNDS = :table_out_of_bounds
|
22
29
|
INDIRECT_CALL_TO_NULL = :indirect_call_to_null
|
@@ -27,6 +34,22 @@ module Wasmtime
|
|
27
34
|
UNREACHABLE_CODE_REACHED = :unreachable_code_reached
|
28
35
|
INTERRUPT = :interrupt
|
29
36
|
ALWAYS_TRAP_ADAPTER = :always_trap_adapter
|
37
|
+
OUT_OF_FUEL = :out_of_fuel
|
30
38
|
UNKNOWN = :unknown
|
31
39
|
end
|
40
|
+
|
41
|
+
# Raised when a WASI program terminates early by calling +exit+.
|
42
|
+
class WasiExit < Error
|
43
|
+
# @return [Integer] The system exit code.
|
44
|
+
attr_reader(:code)
|
45
|
+
|
46
|
+
def initialize(code)
|
47
|
+
@code = code
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [String]
|
51
|
+
def message
|
52
|
+
"WASI exit with code #{code}"
|
53
|
+
end
|
54
|
+
end
|
32
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wasmtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: x86_64-linux
|
6
6
|
authors:
|
7
7
|
- The Wasmtime Project Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby binding for Wasmtime, a WebAssembly runtime.
|
14
14
|
email:
|
@@ -19,10 +19,11 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- LICENSE
|
21
21
|
- README.md
|
22
|
+
- ext/build.rs
|
22
23
|
- lib/wasmtime.rb
|
23
|
-
- lib/wasmtime/2.7/
|
24
|
-
- lib/wasmtime/3.0/
|
25
|
-
- lib/wasmtime/3.1/
|
24
|
+
- lib/wasmtime/2.7/wasmtime_rb.so
|
25
|
+
- lib/wasmtime/3.0/wasmtime_rb.so
|
26
|
+
- lib/wasmtime/3.1/wasmtime_rb.so
|
26
27
|
- lib/wasmtime/version.rb
|
27
28
|
homepage: https://github.com/BytecodeAlliance/wasmtime-rb
|
28
29
|
licenses:
|
@@ -33,7 +34,9 @@ metadata:
|
|
33
34
|
cargo_crate_name: ext
|
34
35
|
changelog_uri: https://github.com/bytecodealliance/wasmtime-rb/blob/main/CHANGELOG.md
|
35
36
|
post_install_message:
|
36
|
-
rdoc_options:
|
37
|
+
rdoc_options:
|
38
|
+
- "--exclude"
|
39
|
+
- vendor
|
37
40
|
require_paths:
|
38
41
|
- lib
|
39
42
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/lib/wasmtime/2.7/ext.so
DELETED
Binary file
|
data/lib/wasmtime/3.0/ext.so
DELETED
Binary file
|
data/lib/wasmtime/3.1/ext.so
DELETED
Binary file
|