wasmtime 0.2.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: 44ec05581887e298d02a58e3d13d262da3e655dc50f5f1b4a5486bdced0a0af1
4
- data.tar.gz: d2078f7320a1c76eb9531cf5f2ade8bc3e05d5b116b8c9c232d56e8417faa68e
3
+ metadata.gz: 64421267f57fe90afa44623614764f249cb7fc06734509d1643f88513eac2797
4
+ data.tar.gz: d4d7c84b2f92dd9c6a9103e2aa7720b83515d083cdbb0a7aed887e2b89717c92
5
5
  SHA512:
6
- metadata.gz: 3e91df734e78123c034475d066de2e0d366dd141ebe31f35f7ea5827dcd6aa7eefa392efe1053e257640ef123dcae191f8dd7fd5eb9be2f8466c215be8b2a7d9
7
- data.tar.gz: b7ca4635c48d30042f907f8e1ea4a326ce63d3ea9198288425d0bd12e39461ede97e7f3742384b3265e44169acb20d225cadb74932c8bd6ee5da9ad971f0d84d
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,147 +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
- Ruby bindings for <a href="https://github.com/bytecodealliance/wasmtime">Wasmtime</a>, a WebAssembly runtime
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
18
+ ## Status
19
19
 
20
- This project provides Ruby bindings for [Wasmtime](https://github.com/bytecodealliance/wasmtime),
21
- a [WebAssembly](https://webassembly.org/) runtime. This allows you to execute
22
- WASM modules from within Ruby executing at near-native speeds in a safe
23
- sandboxed environment.
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.
24
21
 
25
- This is pretty experimental and not production ready right now. There are quite
26
- a few things that aren't built yet, see [TODO](#todo) section below.
22
+ ## Installation
27
23
 
28
- **Note:** [WebAssembly Interface Types](https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/Explainer.md)
29
- support has been [temporarily removed](https://github.com/bytecodealliance/wasmtime/pull/1292)
30
- from Wasmtime. Only 32 and 64-bit integers and floats are currently supported.
24
+ Install from RubyGems
31
25
 
32
- ## Usage
33
-
34
- Install the `wasmtime` gem. Pre-compiled binaries are available for
35
- `x86_64-linux` and `x86_64-darwin-19`. Compiling the native extension requires
36
- [Rust with rustup](https://rustup.rs/).
37
-
38
- ```sh
26
+ ```shell
39
27
  gem install wasmtime
40
28
  ```
41
29
 
42
- WASM has two formats `.wasm` (binary) and `.wat` (human-readable text). Both
43
- formats are supported. With the following `fibonacci.wat` file in your current
44
- directory.
45
-
46
- ```wat
47
- ;; fibonacci.wat
48
- (module
49
- (export "fib" (func $fib))
50
- (func $fib (param $n i32) (result i32)
51
- (if (i32.lt_s (get_local $n) (i32.const 2))
52
- (return (i32.const 1))
53
- )
54
- (return
55
- (i32.add
56
- (call $fib (i32.sub (get_local $n) (i32.const 2)))
57
- (call $fib (i32.sub (get_local $n) (i32.const 1)))
58
- )
59
- )
60
- )
61
- )
62
- ```
30
+ Or use in your Gemfile:
63
31
 
64
- In a ruby file, `require 'wasmtime/require'` to activate the Wasmtime require
65
- patch, allowing you to require any `.wasm` or `.wat` module as if it were a
66
- Ruby file. Doing so will internally create a `Wasmtime::Instance` and define a
67
- Ruby module with functions for each export.
68
-
69
- Finally, invoke the `fib` export like so.
70
-
71
- ```rb
72
- require 'wasmtime/require'
73
- require_relative 'fibonacci'
74
-
75
- puts Fibonacci.fib(11) #=> 89
76
- ```
77
-
78
- If you don't like all the magic in the example above, you can do the same
79
- without the require patch. If your project is going to be a dependency of others
80
- use this approach too.
81
-
82
- ```rb
83
- require 'wasmtime'
84
-
85
- instance = Wasmtime::Instance.new('fibonacci.wat')
86
- puts instance.exports['fib'].call(11) #=> 89
32
+ ```ruby
33
+ gem "wasmtime", "~> 0.3.0"
87
34
  ```
88
35
 
89
- ## Benchmarks
90
-
91
- None yet. But they will be impressive.
92
-
93
- ## Examples
94
-
95
- More usage examples are provided in `examples/`. To run some of these, you first
96
- need to compile the test WASM modules.
97
-
98
- Install some Rust tools.
99
-
100
- - [rustup](https://rustup.rs/) - Rust toolchain manager
101
- - [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) - WASM module bundler
102
-
103
- Install Ruby dependencies.
104
-
105
- ```sh
106
- bundle install
107
- ```
108
-
109
- Build the WASM modules.
110
-
111
- ```sh
112
- bundle exec rake wasm
113
- ```
36
+ ## Usage
114
37
 
115
- Run an example.
38
+ Example usage:
116
39
 
117
- ```sh
118
- ruby examples/fibonacci.rb
119
- ```
40
+ ```ruby
41
+ require "wasmtime"
120
42
 
121
- ## 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
122
46
 
123
- 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
124
55
 
125
- ```sh
126
- bundle exec rake compile
127
- ```
56
+ # Create a store. Store can keep state to be re-used in Funcs.
57
+ store = Wasmtime::Store.new(engine, {count: 0})
128
58
 
129
- 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
130
64
 
131
- ```sh
132
- bundle exec rake spec
133
- ```
65
+ # Build the Wasm instance by providing its imports
66
+ instance = Wasmtime::Instance.new(store, mod, [func])
134
67
 
135
- Format source code.
68
+ # Run the `run` export.
69
+ instance.invoke("run")
136
70
 
137
- ```sh
138
- bundle exec rake format
71
+ # Or: get the `run` export and call it
72
+ instance.export("run").call
139
73
  ```
140
74
 
141
- ## TODO
142
-
143
- - Add support for raw memory access and other types of exports
144
- - Add support for imports
145
- - Implement more of the Wasmtime API
146
- - Add benchmarks for WASM program against ones in pure Ruby and true native
147
- - 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.2.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,51 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wasmtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.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-19 00:00:00.000000000 Z
11
+ date: 2022-11-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description: A Ruby binding for Wasmtime, a WebAssembly runtime.
14
14
  email:
15
- - david@dtcristo.com
15
+ - hello@bytecodealliance.org
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".cargo/config"
21
- - CHANGELOG.md
22
- - Cargo.lock
23
- - Cargo.toml
24
20
  - LICENSE
25
21
  - README.md
26
- - ext/wasmtime/Makefile
27
- - ext/wasmtime/Rakefile
28
- - ext/wasmtime/extconf.rb
29
- - lib/tasks/compile.rake
30
22
  - lib/wasmtime.rb
31
- - lib/wasmtime/native.so
32
- - lib/wasmtime/refinements.rb
33
- - 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
34
26
  - lib/wasmtime/version.rb
35
- - src/export.rs
36
- - src/func.rs
37
- - src/instance.rs
38
- - src/lib.rs
39
- - src/memory.rs
40
- - src/ruby_type.rs
41
- - src/vm.rs
42
- homepage: https://github.com/dtcristo/wasmtime-ruby
27
+ homepage: https://github.com/BytecodeAlliance/wasmtime-rb
43
28
  licenses:
44
- - Apache-2.0 WITH LLVM-exception
29
+ - Apache-2.0
45
30
  metadata:
46
- source_code_uri: https://github.com/dtcristo/wasmtime-ruby
47
- changelog_uri: https://github.com/dtcristo/wasmtime-ruby/blob/master/CHANGELOG.md
48
- 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:
49
36
  rdoc_options: []
50
37
  require_paths:
51
38
  - lib
@@ -53,15 +40,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
40
  requirements:
54
41
  - - ">="
55
42
  - !ruby/object:Gem::Version
56
- version: 2.5.0
43
+ version: '2.7'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 3.2.dev
57
47
  required_rubygems_version: !ruby/object:Gem::Requirement
58
48
  requirements:
59
49
  - - ">="
60
50
  - !ruby/object:Gem::Version
61
51
  version: '0'
62
52
  requirements: []
63
- rubygems_version: 3.1.2
64
- signing_key:
53
+ rubygems_version: 3.3.22
54
+ signing_key:
65
55
  specification_version: 4
66
- summary: Ruby bindings for Wasmtime, a WebAssembly runtime
56
+ summary: Wasmtime bindings for Ruby
67
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,27 +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.2.0] - 2020-05-19
11
-
12
- - Exported functions now live on `Wasmtime::Instance#exports` instead of `#funcs`.
13
- - Exports hash is now keyed by strings instead of symbols.
14
- - Added support for `Wasmtime::Memory` exports with `#data_size`, `#size` and `#grow` methods.
15
-
16
- ## [0.1.0] - 2020-05-07
17
-
18
- ### Added
19
-
20
- - Initial release.
21
- - Support for calling exported functions on a module.
22
- - Support for 32 and 64-bit integers and floats in arguments and as return values.
23
- - Require patch for defining a Ruby module with functions for each export.
24
-
25
- [unreleased]: https://github.com/dtcristo/wasmtime-ruby/compare/v0.2.0...HEAD
26
- [0.2.0]: https://github.com/dtcristo/wasmtime-ruby/releases/tag/v0.2.0
27
- [0.1.0]: https://github.com/dtcristo/wasmtime-ruby/releases/tag/v0.1.0