wasmtime 0.1.0-x86_64-linux → 0.3.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8173eb67aa058d58c648420399fe5f9f30c7bc595e68a5925fe7f5a0915f5526
4
- data.tar.gz: 615737654388916add2cf16cf9f24098ff593c3530ef1f9fb6e2e15f9d3af613
3
+ metadata.gz: 64421267f57fe90afa44623614764f249cb7fc06734509d1643f88513eac2797
4
+ data.tar.gz: d4d7c84b2f92dd9c6a9103e2aa7720b83515d083cdbb0a7aed887e2b89717c92
5
5
  SHA512:
6
- metadata.gz: b3c74540c437a6e737fef26e3177b50c4090bd2ce8910fa4364612cd951bbe220b76ccfb4dfea934be09238c4c41867cc2edda025f4c7a92ca4d8e0fdaceb713
7
- data.tar.gz: 528c8b1b529a0ca4d834c6e10ea5c38ccce72eef038cefd1a55d3a738df83a9e06d00999ae77d5e59fd888d9f02c340a8c9ae9ef51140bfd00ff9dfda0579040
6
+ metadata.gz: 585c63f8747ac0c7d4e794257db037723c4d9b8ee96ba02ef87966d09ebe5ee86ea689a2fd44ec2d2ce857bc1d5cd6349c0516addf3419b3fd92018541744d97
7
+ data.tar.gz: a0b66e6c7ff40b3053f98a60b73e23e099dd270537be0a9e328e45f7d262596a0dbbc1ffcba6182795e32630b936ed5bcb70936316517656a70a767d5648c3ed
data/LICENSE CHANGED
@@ -1,10 +1,11 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
4
5
 
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
7
 
7
- 1. Definitions.
8
+ 1. Definitions.
8
9
 
9
10
  "License" shall mean the terms and conditions for use, reproduction,
10
11
  and distribution as defined by Sections 1 through 9 of this document.
@@ -63,14 +64,14 @@
63
64
  on behalf of whom a Contribution has been received by Licensor and
64
65
  subsequently incorporated within the Work.
65
66
 
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
68
  this License, each Contributor hereby grants to You a perpetual,
68
69
  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
70
  copyright license to reproduce, prepare Derivative Works of,
70
71
  publicly display, publicly perform, sublicense, and distribute the
71
72
  Work and such Derivative Works in Source or Object form.
72
73
 
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
75
  this License, each Contributor hereby grants to You a perpetual,
75
76
  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
77
  (except as stated in this section) patent license to make, have made,
@@ -86,7 +87,7 @@
86
87
  granted to You under this License for that Work shall terminate
87
88
  as of the date such litigation is filed.
88
89
 
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
+ 4. Redistribution. You may reproduce and distribute copies of the
90
91
  Work or Derivative Works thereof in any medium, with or without
91
92
  modifications, and in Source or Object form, provided that You
92
93
  meet the following conditions:
@@ -127,7 +128,7 @@
127
128
  reproduction, and distribution of the Work otherwise complies with
128
129
  the conditions stated in this License.
129
130
 
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
132
  any Contribution intentionally submitted for inclusion in the Work
132
133
  by You to the Licensor shall be under the terms and conditions of
133
134
  this License, without any additional terms or conditions.
@@ -135,12 +136,12 @@
135
136
  the terms of any separate license agreement you may have executed
136
137
  with Licensor regarding such Contributions.
137
138
 
138
- 6. Trademarks. This License does not grant permission to use the trade
139
+ 6. Trademarks. This License does not grant permission to use the trade
139
140
  names, trademarks, service marks, or product names of the Licensor,
140
141
  except as required for reasonable and customary use in describing the
141
142
  origin of the Work and reproducing the content of the NOTICE file.
142
143
 
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
145
  agreed to in writing, Licensor provides the Work (and each
145
146
  Contributor provides its Contributions) on an "AS IS" BASIS,
146
147
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
@@ -150,7 +151,7 @@
150
151
  appropriateness of using or redistributing the Work and assume any
151
152
  risks associated with Your exercise of permissions under this License.
152
153
 
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
+ 8. Limitation of Liability. In no event and under no legal theory,
154
155
  whether in tort (including negligence), contract, or otherwise,
155
156
  unless required by applicable law (such as deliberate and grossly
156
157
  negligent acts) or agreed to in writing, shall any Contributor be
@@ -162,7 +163,7 @@
162
163
  other commercial damages or losses), even if such Contributor
163
164
  has been advised of the possibility of such damages.
164
165
 
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
167
  the Work or Derivative Works thereof, You may choose to offer,
167
168
  and charge a fee for, acceptance of support, warranty, indemnity,
168
169
  or other liability obligations and/or rights consistent with this
@@ -173,9 +174,9 @@
173
174
  incurred by, or claims asserted against, such Contributor by reason
174
175
  of your accepting any such warranty or additional liability.
175
176
 
176
- END OF TERMS AND CONDITIONS
177
+ END OF TERMS AND CONDITIONS
177
178
 
178
- APPENDIX: How to apply the Apache License to your work.
179
+ APPENDIX: How to apply the Apache License to your work.
179
180
 
180
181
  To apply the Apache License to your work, attach the following
181
182
  boilerplate notice, with the fields enclosed by brackets "[]"
@@ -186,19 +187,19 @@
186
187
  same "printed page" as the copyright notice for easier
187
188
  identification within third-party archives.
188
189
 
189
- Copyright [yyyy] [name of copyright owner]
190
+ Copyright [yyyy] [name of copyright owner]
190
191
 
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
194
195
 
195
196
  http://www.apache.org/licenses/LICENSE-2.0
196
197
 
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
202
203
 
203
204
 
204
205
  --- LLVM Exceptions to the Apache 2.0 License ----
@@ -216,3 +217,4 @@ conflicts with the conditions of the GPLv2, you may retroactively and
216
217
  prospectively choose to deem waived or otherwise exclude such Section(s) of
217
218
  the License, but only in their entirety and only with respect to the Combined
218
219
  Software.
220
+
data/README.md CHANGED
@@ -1,150 +1,76 @@
1
1
  <div align="center">
2
- <h1>wasmtime-ruby</h1>
2
+ <h1><code>wasmtime-rb</code></h1>
3
+
3
4
  <p>
4
- <strong>
5
- <a href="https://github.com/bytecodealliance/wasmtime">Wasmtime</a> WebAssembly runtime in Ruby
6
- </strong>
5
+ <strong>Ruby embedding of
6
+ <a href="https://github.com/bytecodealliance/wasmtime">Wasmtime</a></strong>
7
7
  </p>
8
+
9
+ <strong>A <a href="https://bytecodealliance.org/">Bytecode Alliance</a> project</strong>
10
+
8
11
  <p>
9
- <a href="https://rubygems.org/gems/wasmtime">
10
- <img src="https://img.shields.io/gem/v/wasmtime" alt="RubyGems version badge" />
11
- </a>
12
- <a href="https://github.com/dtcristo/wasmtime-ruby/actions?query=workflow%3ACI">
13
- <img src="https://img.shields.io/github/workflow/status/dtcristo/wasmtime-ruby/CI" alt="CI status badge" />
12
+ <a href="https://github.com/bytecodealliance/wasmtime-rb/actions?query=workflow%3ACI">
13
+ <img src="https://github.com/bytecodealliance/wasmtime-rb/workflows/CI/badge.svg" alt="CI status"/>
14
14
  </a>
15
15
  </p>
16
16
  </div>
17
17
 
18
- ## Introduction
19
-
20
- This gem allows you to use the [Wasmtime](https://wasmtime.dev/) WebAssembly
21
- runtime from within your Ruby project.
18
+ ## Status
22
19
 
23
- Why would you want that? [WebAssembly](https://webassembly.org/) (or WASM) is a
24
- technology that allows you to write programs that run at near-native speeds in a
25
- safe sandboxed environment. Wasmtime is a runtime for WASM programs. This gem
26
- embedds Wasmtime in a native extension so you can now run WASM from Ruby.
20
+ The Wasmtime Ruby bindings are still under development, [some features](https://github.com/bytecodealliance/wasmtime-rb/issues?q=is%3Aissue+is%3Aopen+label%3A%22missing+feature%22) are still missing.
27
21
 
28
- This is pretty experimental and not production ready right now. There are quite
29
- a few things that aren't built yet, see [TODO](#todo) section below.
22
+ ## Installation
30
23
 
31
- **Note:** [WebAssembly Interface Types](https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/Explainer.md)
32
- support has been [temporarily removed](https://github.com/bytecodealliance/wasmtime/pull/1292)
33
- from Wasmtime. Only 32 and 64-bit integers and floats are currently supported.
24
+ Install from RubyGems
34
25
 
35
- ## Usage
36
-
37
- Install the `wasmtime` gem. Pre-compiled binaries are available for
38
- `x86_64-linux` and `x86_64-darwin-19`. Compiling the native extension requires
39
- [Rust with rustup](https://rustup.rs/).
40
-
41
- ```sh
26
+ ```shell
42
27
  gem install wasmtime
43
28
  ```
44
29
 
45
- WASM has two formats `*.wasm` (binary) and `*.wat` (human-readable text). Both
46
- formats are supported. With the following `fibonacci.wat` file in your current
47
- directory.
48
-
49
- ```wat
50
- ;; fibonacci.wat
51
- (module
52
- (export "fib" (func $fib))
53
- (func $fib (param $n i32) (result i32)
54
- (if (i32.lt_s (get_local $n) (i32.const 2))
55
- (return (i32.const 1))
56
- )
57
- (return
58
- (i32.add
59
- (call $fib (i32.sub (get_local $n) (i32.const 2)))
60
- (call $fib (i32.sub (get_local $n) (i32.const 1)))
61
- )
62
- )
63
- )
64
- )
65
- ```
66
-
67
- In a ruby file, `require 'wasmtime/require'` to activate the Wasmtime require
68
- patch, allowing you to require any `*.wasm` or `*.wat` module as if it were a
69
- Ruby file. Doing so will internally create a `Wasmtime::Instance` and define a
70
- Ruby module with functions for each export.
71
-
72
- Finally, invoke the `fib` export like so.
73
-
74
- ```rb
75
- require 'wasmtime/require'
76
- require_relative 'fibonacci'
77
-
78
- puts Fibonacci.fib(11) #=> 89
79
- ```
80
-
81
- If you don't like all the magic in the example above, you can do the same
82
- without the require patch. If your project is going to be a dependency of others
83
- use this approach too.
84
-
85
- ```rb
86
- require 'wasmtime'
87
-
88
- instance = Wasmtime::Instance.new('fibonacci.wat')
89
- puts instance.funcs[:fib].call(11) #=> 89
90
- ```
91
-
92
- ## Benchmarks
93
-
94
- None yet. But they will be impressive.
95
-
96
- ## Examples
97
-
98
- More usage examples are provided in `examples/`. To run some of these, you first
99
- need to compile the test WASM modules.
100
-
101
- Install some Rust tools.
102
-
103
- - [rustup](https://rustup.rs/) - Rust toolchain manager
104
- - [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) - WASM module bundler
105
-
106
- Install Ruby dependencies.
30
+ Or use in your Gemfile:
107
31
 
108
- ```sh
109
- bundle install
32
+ ```ruby
33
+ gem "wasmtime", "~> 0.3.0"
110
34
  ```
111
35
 
112
- Build the WASM modules.
113
-
114
- ```sh
115
- bundle exec rake wasm
116
- ```
36
+ ## Usage
117
37
 
118
- Run an example.
38
+ Example usage:
119
39
 
120
- ```sh
121
- ruby examples/fibonacci.rb
122
- ```
40
+ ```ruby
41
+ require "wasmtime"
123
42
 
124
- ## Development
43
+ # Create an engine. Generally, you only need a single engine and can
44
+ # re-use it a throughout your program
45
+ engine = Wasmtime::Engine.new
125
46
 
126
- Compile Rust native extension.
47
+ # Compile a Wasm module from either Wasm or WAT. The compiled module is
48
+ # specific to the Engine's configuration.
49
+ mod = Wasmtime::Module.new(engine, <<~WAT)
50
+ (module
51
+ (func $hello (import "" "hello"))
52
+ (func (export "run") (call $hello))
53
+ )
54
+ WAT
127
55
 
128
- ```sh
129
- bundle exec rake compile
130
- ```
56
+ # Create a store. Store can keep state to be re-used in Funcs.
57
+ store = Wasmtime::Store.new(engine, {count: 0})
131
58
 
132
- Run test suite.
59
+ # Define a Wasm function from Ruby code.
60
+ func = Wasmtime::Func.new(store, Wasmtime::FuncType.new([], [])) do |caller|
61
+ puts "Hello from Func!"
62
+ puts "Ran #{caller[:count]} time(s)"
63
+ end
133
64
 
134
- ```sh
135
- bundle exec rake spec
136
- ```
65
+ # Build the Wasm instance by providing its imports
66
+ instance = Wasmtime::Instance.new(store, mod, [func])
137
67
 
138
- Format source code.
68
+ # Run the `run` export.
69
+ instance.invoke("run")
139
70
 
140
- ```sh
141
- bundle exec rake format
71
+ # Or: get the `run` export and call it
72
+ instance.export("run").call
142
73
  ```
143
74
 
144
- ## TODO
145
-
146
- - Add support for raw memory access and other types of exports
147
- - Add support for imports
148
- - Implement more of the Wasmtime API
149
- - Add benchmarks for WASM program against ones in pure Ruby and true native
150
- - Add support for WASM Interface Types when they are supported in Wasmtime
75
+ For more, see [examples](https://github.com/bytecodealliance/wasmtime-rb/tree/main/examples)
76
+ or the [API documentation](https://bytecodealliance.github.io/wasmtime-rb/latest/).
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wasmtime
4
- VERSION = '0.1.0'
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/wasmtime.rb CHANGED
@@ -1,7 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Wasmtime; end
3
+ require_relative "wasmtime/version"
4
4
 
5
- require 'wasmtime/version'
6
- require 'wasmtime/refinements'
7
- require 'wasmtime/native'
5
+ # Tries to require the extension for the given Ruby version first
6
+ begin
7
+ RUBY_VERSION =~ /(\d+\.\d+)/
8
+ require "wasmtime/#{Regexp.last_match(1)}/ext"
9
+ rescue LoadError
10
+ require "wasmtime/ext"
11
+ end
12
+
13
+ module Wasmtime
14
+ class Error < StandardError; end
15
+
16
+ class ConversionError < Error; end
17
+
18
+ class Trap < Error
19
+ STACK_OVERFLOW = :stack_overflow
20
+ HEAP_MISALIGNED = :heap_misaligned
21
+ TABLE_OUT_OF_BOUNDS = :table_out_of_bounds
22
+ INDIRECT_CALL_TO_NULL = :indirect_call_to_null
23
+ BAD_SIGNATURE = :bad_signature
24
+ INTEGER_OVERFLOW = :integer_overflow
25
+ INTEGER_DIVISION_BY_ZERO = :integer_division_by_zero
26
+ BAD_CONVERSION_TO_INTEGER = :bad_conversion_to_integer
27
+ UNREACHABLE_CODE_REACHED = :unreachable_code_reached
28
+ INTERRUPT = :interrupt
29
+ ALWAYS_TRAP_ADAPTER = :always_trap_adapter
30
+ UNKNOWN = :unknown
31
+ end
32
+ end
metadata CHANGED
@@ -1,50 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wasmtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
- - David Cristofaro
8
- autorequire:
9
- bindir: bin
7
+ - The Wasmtime Project Developers
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-07 00:00:00.000000000 Z
11
+ date: 2022-11-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: This gem allows you to use the Wasmtime WebAssembly runtime from within
14
- your Ruby project.
13
+ description: A Ruby binding for Wasmtime, a WebAssembly runtime.
15
14
  email:
16
- - david@dtcristo.com
15
+ - hello@bytecodealliance.org
17
16
  executables: []
18
17
  extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
- - ".cargo/config"
22
- - CHANGELOG.md
23
- - Cargo.lock
24
- - Cargo.toml
25
20
  - LICENSE
26
21
  - README.md
27
- - ext/wasmtime/Makefile
28
- - ext/wasmtime/Rakefile
29
- - ext/wasmtime/extconf.rb
30
- - lib/tasks/compile.rake
31
22
  - lib/wasmtime.rb
32
- - lib/wasmtime/native.so
33
- - lib/wasmtime/refinements.rb
34
- - lib/wasmtime/require.rb
23
+ - lib/wasmtime/2.7/ext.so
24
+ - lib/wasmtime/3.0/ext.so
25
+ - lib/wasmtime/3.1/ext.so
35
26
  - lib/wasmtime/version.rb
36
- - src/func.rs
37
- - src/instance.rs
38
- - src/lib.rs
39
- - src/memory.rs
40
- - src/vm.rs
41
- homepage: https://github.com/dtcristo/wasmtime-ruby
27
+ homepage: https://github.com/BytecodeAlliance/wasmtime-rb
42
28
  licenses:
43
- - Apache-2.0 WITH LLVM-exception
29
+ - Apache-2.0
44
30
  metadata:
45
- source_code_uri: https://github.com/dtcristo/wasmtime-ruby
46
- changelog_uri: https://github.com/dtcristo/wasmtime-ruby/blob/master/CHANGELOG.md
47
- post_install_message:
31
+ homepage_uri: https://github.com/BytecodeAlliance/wasmtime-rb
32
+ source_code_uri: https://github.com/BytecodeAlliance/wasmtime-rb
33
+ cargo_crate_name: ext
34
+ changelog_uri: https://github.com/bytecodealliance/wasmtime-rb/blob/main/CHANGELOG.md
35
+ post_install_message:
48
36
  rdoc_options: []
49
37
  require_paths:
50
38
  - lib
@@ -52,15 +40,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
40
  requirements:
53
41
  - - ">="
54
42
  - !ruby/object:Gem::Version
55
- version: 2.5.0
43
+ version: '2.7'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 3.2.dev
56
47
  required_rubygems_version: !ruby/object:Gem::Requirement
57
48
  requirements:
58
49
  - - ">="
59
50
  - !ruby/object:Gem::Version
60
51
  version: '0'
61
52
  requirements: []
62
- rubygems_version: 3.1.2
63
- signing_key:
53
+ rubygems_version: 3.3.22
54
+ signing_key:
64
55
  specification_version: 4
65
- summary: Wasmtime WebAssembly runtime
56
+ summary: Wasmtime bindings for Ruby
66
57
  test_files: []
data/.cargo/config DELETED
@@ -1,4 +0,0 @@
1
- [target.x86_64-apple-darwin]
2
- rustflags = [
3
- "-C", "link-args=-undefined dynamic_lookup"
4
- ]
data/CHANGELOG.md DELETED
@@ -1,20 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [Unreleased]
9
-
10
- ## [0.1.0] - 2020-05-07
11
-
12
- ### Added
13
-
14
- - Initial release.
15
- - Support for calling exported functions on a module.
16
- - Support for 32 and 64-bit integers and floats in arguments and as return values.
17
- - Require patch for defining a Ruby module with functions for each export.
18
-
19
- [unreleased]: https://github.com/dtcristo/wasmtime-ruby/compare/v0.1.0...HEAD
20
- [0.1.0]: https://github.com/dtcristo/wasmtime-ruby/releases/tag/v0.1.0