wasmer 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Cargo.lock +16 -15
- data/Cargo.toml +3 -3
- data/README.md +55 -30
- data/lib/wasmer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95ded27d0123f00e65407dae42df437be93ae305eaaa7de573d4e4e57f3f96a3
|
4
|
+
data.tar.gz: b623747a94aff21d1e3724f6f9d459ae7b904c3275596761e423a02c4b7f2977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9caa34babdc601de3e9575b47be3b5d79cc0a22f15b1b4a2648fcaba04c085894eee87ca0e0c764d4bd1c9aa17e3b1a80e30875d5fb592f5a1b63ca897c4f726
|
7
|
+
data.tar.gz: 509927b40b42ea16c929544d4aa35c540c646748f97cf90c67185a246acd37619715170bfde2567405d1b7142605833e4ca0227eeb2dc487ff50e69c90908517
|
data/Cargo.lock
CHANGED
@@ -746,8 +746,8 @@ version = "0.1.1"
|
|
746
746
|
dependencies = [
|
747
747
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
748
748
|
"rutie 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
749
|
-
"wasmer-runtime 0.
|
750
|
-
"wasmer-runtime-core 0.
|
749
|
+
"wasmer-runtime 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
750
|
+
"wasmer-runtime-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
751
751
|
]
|
752
752
|
|
753
753
|
[[package]]
|
@@ -959,7 +959,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
959
959
|
|
960
960
|
[[package]]
|
961
961
|
name = "wasmer-clif-backend"
|
962
|
-
version = "0.
|
962
|
+
version = "0.4.0"
|
963
963
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
964
964
|
dependencies = [
|
965
965
|
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
@@ -976,26 +976,26 @@ dependencies = [
|
|
976
976
|
"serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
977
977
|
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
978
978
|
"target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
979
|
-
"wasmer-runtime-core 0.
|
980
|
-
"wasmer-win-exception-handler 0.
|
979
|
+
"wasmer-runtime-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
980
|
+
"wasmer-win-exception-handler 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
981
981
|
"wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
982
982
|
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
983
983
|
]
|
984
984
|
|
985
985
|
[[package]]
|
986
986
|
name = "wasmer-runtime"
|
987
|
-
version = "0.
|
987
|
+
version = "0.4.0"
|
988
988
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
989
989
|
dependencies = [
|
990
990
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
991
991
|
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
992
|
-
"wasmer-clif-backend 0.
|
993
|
-
"wasmer-runtime-core 0.
|
992
|
+
"wasmer-clif-backend 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
993
|
+
"wasmer-runtime-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
994
994
|
]
|
995
995
|
|
996
996
|
[[package]]
|
997
997
|
name = "wasmer-runtime-core"
|
998
|
-
version = "0.
|
998
|
+
version = "0.4.0"
|
999
999
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1000
1000
|
dependencies = [
|
1001
1001
|
"blake2b_simd 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
@@ -1014,20 +1014,21 @@ dependencies = [
|
|
1014
1014
|
"serde-bench 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
1015
1015
|
"serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
1016
1016
|
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
1017
|
+
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
1017
1018
|
"wasmparser 0.29.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
1018
1019
|
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
1019
1020
|
]
|
1020
1021
|
|
1021
1022
|
[[package]]
|
1022
1023
|
name = "wasmer-win-exception-handler"
|
1023
|
-
version = "0.
|
1024
|
+
version = "0.4.0"
|
1024
1025
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1025
1026
|
dependencies = [
|
1026
1027
|
"bindgen 0.46.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
1027
1028
|
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
1028
1029
|
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
1029
1030
|
"regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
1030
|
-
"wasmer-runtime-core 0.
|
1031
|
+
"wasmer-runtime-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
1031
1032
|
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
1032
1033
|
]
|
1033
1034
|
|
@@ -1214,10 +1215,10 @@ dependencies = [
|
|
1214
1215
|
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
1215
1216
|
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
|
1216
1217
|
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
1217
|
-
"checksum wasmer-clif-backend 0.
|
1218
|
-
"checksum wasmer-runtime 0.
|
1219
|
-
"checksum wasmer-runtime-core 0.
|
1220
|
-
"checksum wasmer-win-exception-handler 0.
|
1218
|
+
"checksum wasmer-clif-backend 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3550d9770c7e0cd4fda73658b9d75e94df108fcf825914817960226122d443d"
|
1219
|
+
"checksum wasmer-runtime 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50be960b2a9dd5371785db681f5592662f3827da42e71c42121bc43befd9d6af"
|
1220
|
+
"checksum wasmer-runtime-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bbef3ab3407493f5b9005b4ddff9f2ea9e9bb7283e034f98fde35ed1eeab4a9e"
|
1221
|
+
"checksum wasmer-win-exception-handler 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d577aa8ba78e23e0e6db974998f5856e3f082a8666e7183886a3c30183a12654"
|
1221
1222
|
"checksum wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5e01c420bc7d36e778bd242e1167b079562ba8b34087122cc9057187026d060"
|
1222
1223
|
"checksum wasmparser 0.29.2 (registry+https://github.com/rust-lang/crates.io-index)" = "981a8797cf89762e0233ec45fae731cb79a4dfaee12d9f0fe6cee01e4ac58d00"
|
1223
1224
|
"checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164"
|
data/Cargo.toml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[package]
|
2
2
|
publish = false
|
3
3
|
name = "ruby-ext-wasm"
|
4
|
-
version = "0.
|
4
|
+
version = "0.2.0"
|
5
5
|
authors = ["Ivan Enderlin <ivan.enderlin@hoa-project.net>"]
|
6
6
|
edition = "2018"
|
7
7
|
description = "Ruby extension to run WebAssembly binaries"
|
@@ -15,7 +15,7 @@ name = "wasmer"
|
|
15
15
|
crate-type = ["dylib"]
|
16
16
|
|
17
17
|
[dependencies]
|
18
|
-
wasmer-runtime = "0.
|
19
|
-
wasmer-runtime-core = "0.
|
18
|
+
wasmer-runtime = "0.4.0"
|
19
|
+
wasmer-runtime-core = "0.4.0"
|
20
20
|
rutie = "0.5.4"
|
21
21
|
lazy_static = "1.3.0"
|
data/README.md
CHANGED
@@ -7,39 +7,40 @@
|
|
7
7
|
<p align="center">
|
8
8
|
<a href="https://spectrum.chat/wasmer">
|
9
9
|
<img src="https://withspectrum.github.io/badge/badge.svg" alt="Join the Wasmer Community"></a>
|
10
|
+
<a href="https://rubygems.org/gems/wasmer">
|
11
|
+
<img src="https://img.shields.io/gem/v/wasmer.svg" alt="Gem"></a>
|
12
|
+
<a href="https://rubygems.org/gems/wasmer">
|
13
|
+
<img src="https://img.shields.io/gem/dt/wasmer.svg" alt="Gem"></a>
|
10
14
|
<a href="https://github.com/wasmerio/wasmer/blob/master/LICENSE">
|
11
15
|
<img src="https://img.shields.io/github/license/wasmerio/wasmer.svg" alt="License"></a>
|
12
16
|
</p>
|
13
17
|
|
14
|
-
|
18
|
+
Wasmer is a Ruby library for executing WebAssembly binaries:
|
15
19
|
|
16
|
-
|
17
|
-
|
20
|
+
* **Easy to use**: The `wasmer` API mimics the standard WebAssembly API,
|
21
|
+
* **Fast**: `wasmer` executes the WebAssembly modules as fast as possible,
|
22
|
+
* **Safe**: All calls to WebAssembly will be fast, but more
|
23
|
+
importantly, completely safe and sandboxed.
|
18
24
|
|
19
|
-
|
25
|
+
# Install
|
20
26
|
|
21
|
-
|
27
|
+
To install the `wasmer` Ruby gem, just run this command in your shell:
|
22
28
|
|
23
|
-
|
29
|
+
```sh
|
30
|
+
$ gem install wasmer
|
31
|
+
```
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
> deployment on the web for client and server applications.
|
33
|
+
**Note**: [Rust][rust] is required to install the Ruby library (Cargo
|
34
|
+
—the build tool for Rust— is used to compile the extension). See [how
|
35
|
+
to install Rust][install-rust].
|
29
36
|
|
30
|
-
|
37
|
+
[View the `wasmer` gem on RubyGems][wasmer-gem].
|
31
38
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
> available on a wide range of platforms.
|
36
|
-
|
37
|
-
About safety:
|
39
|
+
[rust]: https://www.rust-lang.org/
|
40
|
+
[install-rust]: https://www.rust-lang.org/tools/install
|
41
|
+
[wasmer-gem]: https://rubygems.org/gems/wasmer
|
38
42
|
|
39
|
-
|
40
|
-
> environment](https://webassembly.org/docs/semantics/#linear-memory) […].
|
41
|
-
|
42
|
-
## Example
|
43
|
+
# Example
|
43
44
|
|
44
45
|
There is a toy program in `examples/simple.rs`, written in Rust (or
|
45
46
|
any other language that compiles to Wasm):
|
@@ -71,9 +72,9 @@ $ ruby simple.rb
|
|
71
72
|
3
|
72
73
|
```
|
73
74
|
|
74
|
-
|
75
|
+
# API documentation
|
75
76
|
|
76
|
-
|
77
|
+
## The `Instance` class
|
77
78
|
|
78
79
|
Instantiates a WebAssembly module represented by bytes, and calls exported functions on it:
|
79
80
|
|
@@ -105,7 +106,7 @@ view = instance.memory.uint8_view
|
|
105
106
|
|
106
107
|
See below for more information.
|
107
108
|
|
108
|
-
|
109
|
+
## The `Memory` class
|
109
110
|
|
110
111
|
A WebAssembly instance has its own memory, represented by the `Memory`
|
111
112
|
class. It is accessible by the `Instance.memory` getter.
|
@@ -124,7 +125,7 @@ view = instance.memory.uint8_view offset
|
|
124
125
|
puts view[0]
|
125
126
|
```
|
126
127
|
|
127
|
-
|
128
|
+
### The `*Array` classes
|
128
129
|
|
129
130
|
These classes represent views over a memory buffer of an instance.
|
130
131
|
|
@@ -241,7 +242,7 @@ assert_equal 0b01000000_00010000, int16[1]
|
|
241
242
|
assert_equal 0b01000000_00010000_00000100_00000001, int32[0]
|
242
243
|
```
|
243
244
|
|
244
|
-
|
245
|
+
## The `Module` class
|
245
246
|
|
246
247
|
The `Module` class contains one static method `validate`, that checks
|
247
248
|
whether the given bytes represent valid WebAssembly bytes:
|
@@ -258,7 +259,7 @@ end
|
|
258
259
|
|
259
260
|
This function returns a boolean.
|
260
261
|
|
261
|
-
|
262
|
+
# Install and Testing
|
262
263
|
|
263
264
|
To compile the entire project, run the following commands:
|
264
265
|
|
@@ -268,12 +269,36 @@ $ just test
|
|
268
269
|
$ ruby examples/simple.rb
|
269
270
|
```
|
270
271
|
|
271
|
-
(Yes, you need [`just`]
|
272
|
+
(Yes, you need [`just`][just]).
|
273
|
+
|
274
|
+
[just]: https://github.com/casey/just/
|
275
|
+
|
276
|
+
# What is WebAssembly?
|
277
|
+
|
278
|
+
Quoting [the WebAssembly site][wasm]:
|
272
279
|
|
273
|
-
|
280
|
+
> WebAssembly (abbreviated Wasm) is a binary instruction format for a
|
281
|
+
> stack-based virtual machine. Wasm is designed as a portable target
|
282
|
+
> for compilation of high-level languages like C/C++/Rust, enabling
|
283
|
+
> deployment on the web for client and server applications.
|
284
|
+
|
285
|
+
About speed:
|
286
|
+
|
287
|
+
> WebAssembly aims to execute at native speed by taking advantage of
|
288
|
+
> [common hardware
|
289
|
+
> capabilities](https://webassembly.org/docs/portability/#assumptions-for-efficient-execution)
|
290
|
+
> available on a wide range of platforms.
|
291
|
+
|
292
|
+
About safety:
|
293
|
+
|
294
|
+
> WebAssembly describes a memory-safe, sandboxed [execution
|
295
|
+
> environment](https://webassembly.org/docs/semantics/#linear-memory) […].
|
296
|
+
|
297
|
+
[wasm]: https://webassembly.org/
|
298
|
+
|
299
|
+
# License
|
274
300
|
|
275
301
|
The entire project is under the BSD-3-Clause license. Please read [the
|
276
302
|
`LICENSE` file][license].
|
277
303
|
|
278
|
-
|
279
304
|
[license]: https://github.com/wasmerio/wasmer/blob/master/LICENSE
|
data/lib/wasmer/version.rb
CHANGED