Skip to content

Commit 3a75bc4

Browse files
authored
Merge pull request #218 from bytecodealliance/update-wasmtime10
chore: Update to wasmtime@10
2 parents 36adaf6 + 6f5f6ce commit 3a75bc4

10 files changed

Lines changed: 222 additions & 131 deletions

File tree

Cargo.lock

Lines changed: 184 additions & 101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
wasmtime (9.0.4)
4+
wasmtime (10.0.0)
55
rb_sys (~> 0.9.81)
66

77
GEM

examples/rust-crate/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ doctest = false
1010
wasmtime-rb = { path = "../../ext", features = ["ruby-api"] }
1111

1212
[dev-dependencies]
13-
magnus = { version = "0.5.3", features = ["embed"] } # Only need embed feature for tests
13+
magnus = { version = "0.5.5", features = ["embed"] } # Only need embed feature for tests
1414
wasmtime-rb = { path = "../../ext", features = ["embed"] } # Only need embed feature for tests

ext/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ magnus = { version = "0.5.5", features = ["rb-sys-interop"] }
2020
rb-sys = { version = "*", default-features = false, features = [
2121
"stable-api-compiled-fallback",
2222
] }
23-
wasmtime = { version = "= 9.0.4" }
24-
wasmtime-wasi = "= 9.0.4"
25-
wasi-common = "= 9.0.4"
26-
wasi-cap-std-sync = "= 9.0.4"
23+
wasmtime = { version = "= 10.0.0" }
24+
wasmtime-wasi = "= 10.0.0"
25+
wasi-common = "= 10.0.0"
26+
wasi-cap-std-sync = "= 10.0.0"
2727
cap-std = "1.0.5"
2828
anyhow = "*" # Use whatever Wasmtime uses
2929
wat = "1.0.69"
@@ -37,8 +37,8 @@ async-timer = { version = "1.0.0-beta.8", features = [
3737
"tokio1",
3838
], optional = true }
3939
static_assertions = "1.1.0"
40-
wasmtime-runtime = "= 9.0.4"
41-
wasmtime-environ = "= 9.0.4"
40+
wasmtime-runtime = "= 10.0.0"
41+
wasmtime-environ = "= 10.0.0"
4242

4343
[build-dependencies]
4444
rb-sys-env = "0.1.2"

ext/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn bundle_ruby_file(filename: &str) -> Result<(), Box<dyn Error>> {
3333
contents
3434
};
3535

36-
let template = r###"
36+
let template = r##"
3737
// This file is generated by build.rs
3838
3939
use magnus::eval;
@@ -48,7 +48,7 @@ __FILE_CONTENTS__
4848
Ok(())
4949
}
5050
51-
"###;
51+
"##;
5252

5353
let contents = template.replace("__FILE_CONTENTS__", &contents);
5454

ext/src/ruby_api/global.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'a> Global<'a> {
5555
mutability: Mutability,
5656
) -> Result<Self, Error> {
5757
let wasm_type = value_type.to_val_type()?;
58-
let wasm_default = default.to_wasm_val(wasm_type)?;
58+
let wasm_default = default.to_wasm_val(wasm_type.clone())?;
5959
let store = s.get();
6060
let inner = GlobalImpl::new(
6161
store.context_mut(),
@@ -96,7 +96,7 @@ impl<'a> Global<'a> {
9696
/// @def type
9797
/// @return [Symbol] The Wasm type of the global‘s content.
9898
pub fn type_(&self) -> Result<Symbol, Error> {
99-
self.ty().map(|ty| ty.content().to_sym())
99+
self.ty().map(|ty| ty.content().clone().to_sym())
100100
}
101101

102102
/// @yard
@@ -130,7 +130,7 @@ impl<'a> Global<'a> {
130130
}
131131

132132
fn value_type(&self) -> Result<wasmtime::ValType, Error> {
133-
self.ty().map(|ty| *ty.content())
133+
self.ty().map(|ty| ty.content().clone())
134134
}
135135

136136
fn retain_non_nil_extern_ref(&self, value: Value) -> Result<(), Error> {

ext/src/ruby_api/memory/unsafe_slice.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,13 @@ impl<'a> UnsafeSlice<'a> {
124124
_flags: i32,
125125
) -> bool {
126126
let obj = unsafe { Value::from_raw(value) };
127-
let Ok(memory) = <Obj<UnsafeSlice>>::try_convert(obj) else { return false };
127+
let Ok(memory) = <Obj<UnsafeSlice>>::try_convert(obj) else {
128+
return false;
129+
};
128130
let memory = memory.get();
129-
let Ok(raw_slice) = memory.get_raw_slice() else { return false; };
131+
let Ok(raw_slice) = memory.get_raw_slice() else {
132+
return false;
133+
};
130134
let (ptr, size) = (raw_slice.as_ptr(), raw_slice.len());
131135

132136
unsafe { rb_memory_view_init_as_byte_array(view, value, ptr as _, size as _, true) }
@@ -135,7 +139,9 @@ impl<'a> UnsafeSlice<'a> {
135139
#[cfg(ruby_gte_3_0)]
136140
extern "C" fn is_memory_view_available(value: VALUE) -> bool {
137141
let obj = unsafe { Value::from_raw(value) };
138-
let Ok(memory) = <Obj<UnsafeSlice>>::try_convert(obj) else { return false };
142+
let Ok(memory) = <Obj<UnsafeSlice>>::try_convert(obj) else {
143+
return false;
144+
};
139145
let memory = memory.get();
140146

141147
memory.get_raw_slice().is_ok()

ext/src/ruby_api/params.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use magnus::{exception::arg_error, Error, ExceptionClass, Value};
33
use static_assertions::assert_eq_size;
44
use wasmtime::{FuncType, ValType};
55

6-
#[derive(Debug, Copy, Clone)]
6+
#[derive(Debug, Clone)]
77
#[repr(C)]
88
struct Param {
99
val: Value,
@@ -19,17 +19,19 @@ impl Param {
1919
Self { index, ty, val }
2020
}
2121

22-
fn to_wasmtime_val(self) -> Result<wasmtime::Val, Error> {
23-
self.val.to_wasm_val(self.ty).map_err(|error| match error {
24-
Error::Error(class, msg) => {
25-
Error::new(class, format!("{} (param at index {})", msg, self.index))
26-
}
27-
Error::Exception(exception) => Error::new(
28-
ExceptionClass::from_value(exception.class().into()).unwrap_or_else(arg_error),
29-
format!("{} (param at index {})", exception, self.index),
30-
),
31-
_ => error,
32-
})
22+
fn to_wasmtime_val(&self) -> Result<wasmtime::Val, Error> {
23+
self.val
24+
.to_wasm_val(self.ty.clone())
25+
.map_err(|error| match error {
26+
Error::Error(class, msg) => {
27+
Error::new(class, format!("{} (param at index {})", msg, self.index))
28+
}
29+
Error::Exception(exception) => Error::new(
30+
ExceptionClass::from_value(exception.class().into()).unwrap_or_else(arg_error),
31+
format!("{} (param at index {})", exception, self.index),
32+
),
33+
_ => error,
34+
})
3335
}
3436
}
3537

ext/src/ruby_api/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a> Table<'a> {
5252
let (max,) = kw.optional;
5353
let store = s.get();
5454
let wasm_type = value_type.to_val_type()?;
55-
let wasm_default = default.to_wasm_val(wasm_type)?;
55+
let wasm_default = default.to_wasm_val(wasm_type.clone())?;
5656

5757
let inner = TableImpl::new(
5858
store.context_mut(),

lib/wasmtime/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Wasmtime
4-
VERSION = "9.0.4"
4+
VERSION = "10.0.0"
55
end

0 commit comments

Comments
 (0)