Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: "3.4"
ruby-version: "4.0"
rustup-toolchain: "${{ env.NIGHTLY_VERSION }}"
bundler-cache: true
cargo-cache: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-gems.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
ruby-version: "4.0"

- uses: oxidize-rb/actions/cross-gem@v1
id: cross-gem
Expand All @@ -66,7 +66,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest"]
ruby: ["3.4"]
ruby: ["4.0"]
steps:
- uses: actions/checkout@v6

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/memcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ on:
ruby-version:
description: "Ruby version to memcheck"
required: true
default: "3.4"
default: "4.0"
type: choice
options:
- "head"
- "4.0"
- "3.4"
- "3.3"
- "3.2"
Expand Down Expand Up @@ -38,7 +39,7 @@ jobs:

- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: ${{ inputs.ruby-version || '3.4' }}
ruby-version: ${{ inputs.ruby-version || '4.0' }}
bundler-cache: true
cargo-cache: true
cache-version: v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
ruby-version: "4.0"

- uses: oxidize-rb/actions/cross-gem@v1
id: cross-gem
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:

- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: "3.4"
ruby-version: "4.0"
bundler-cache: true
cargo-cache: true
cache-version: v1
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
wasmtime (39.0.1)
rb_sys (~> 0.9.119)
rb_sys (~> 0.9.124)

GEM
remote: https://rubygems.org/
Expand All @@ -11,17 +11,17 @@ GEM
benchmark-ips (2.14.0)
bigdecimal (3.1.9)
diff-lcs (1.6.2)
ffi (1.17.1)
ffi (1.17.1-aarch64-linux-gnu)
ffi (1.17.1-aarch64-linux-musl)
ffi (1.17.1-arm-linux-gnu)
ffi (1.17.1-arm-linux-musl)
ffi (1.17.1-arm64-darwin)
ffi (1.17.1-x86-linux-gnu)
ffi (1.17.1-x86-linux-musl)
ffi (1.17.1-x86_64-darwin)
ffi (1.17.1-x86_64-linux-gnu)
ffi (1.17.1-x86_64-linux-musl)
ffi (1.17.3)
ffi (1.17.3-aarch64-linux-gnu)
ffi (1.17.3-aarch64-linux-musl)
ffi (1.17.3-arm-linux-gnu)
ffi (1.17.3-arm-linux-musl)
ffi (1.17.3-arm64-darwin)
ffi (1.17.3-x86-linux-gnu)
ffi (1.17.3-x86-linux-musl)
ffi (1.17.3-x86_64-darwin)
ffi (1.17.3-x86_64-linux-gnu)
ffi (1.17.3-x86_64-linux-musl)
fiddle (1.1.8)
get_process_mem (1.0.0)
bigdecimal (>= 2.0)
Expand All @@ -40,9 +40,9 @@ GEM
rake (13.3.1)
rake-compiler (1.3.0)
rake
rake-compiler-dock (1.10.0)
rb_sys (0.9.119)
rake-compiler-dock (= 1.10.0)
rake-compiler-dock (1.11.0)
rb_sys (0.9.124)
rake-compiler-dock (= 1.11.0)
regexp_parser (2.11.3)
rspec (3.13.2)
rspec-core (~> 3.13.0)
Expand Down Expand Up @@ -92,7 +92,7 @@ GEM
prettier_print (>= 1.2.0)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.1.0)
unicode-emoji (4.2.0)
yard (0.9.37)
yard-rustdoc (0.4.2)
syntax_tree (~> 6.0)
Expand Down
27 changes: 18 additions & 9 deletions ext/src/helpers/tmplock.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use magnus::{
rb_sys::{protect, AsRawValue},
value::ReprValue,
RString,
};

pub trait Tmplock {
fn as_locked_slice(&self) -> Result<(&[u8], TmplockGuard), magnus::Error>;
fn as_locked_str(&self) -> Result<(&str, TmplockGuard), magnus::Error>;
fn as_locked_slice(&self) -> Result<(&[u8], Option<TmplockGuard>), magnus::Error>;
fn as_locked_str(&self) -> Result<(&str, Option<TmplockGuard>), magnus::Error>;
}

#[derive(Debug)]
Expand All @@ -25,20 +26,28 @@ impl Drop for TmplockGuard {
}

impl Tmplock for RString {
fn as_locked_slice(&self) -> Result<(&[u8], TmplockGuard), magnus::Error> {
fn as_locked_slice(&self) -> Result<(&[u8], Option<TmplockGuard>), magnus::Error> {
let raw = self.as_raw();
let slice = unsafe { self.as_slice() };
let raw = protect(|| unsafe { rb_sys::rb_str_locktmp(raw) })?;
let guard = TmplockGuard { raw };
let guard = if self.is_frozen() {
None
} else {
let raw = protect(|| unsafe { rb_sys::rb_str_locktmp(raw) })?;
Some(TmplockGuard { raw })
};

Ok((slice, guard))
}

fn as_locked_str(&self) -> Result<(&str, TmplockGuard), magnus::Error> {
fn as_locked_str(&self) -> Result<(&str, Option<TmplockGuard>), magnus::Error> {
let str_result = unsafe { self.as_str()? };
let raw = self.as_raw();
let raw = protect(|| unsafe { rb_sys::rb_str_locktmp(raw) })?;
let guard = TmplockGuard { raw };
let guard = if self.is_frozen() {
None
} else {
let raw = self.as_raw();
let raw = protect(|| unsafe { rb_sys::rb_str_locktmp(raw) })?;
Some(TmplockGuard { raw })
};

Ok((str_result, guard))
}
Expand Down
10 changes: 8 additions & 2 deletions spec/integration/ractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Wasmtime::Instance.new(store, mod).invoke("hello")
end

result = r.take
result = value(r)
expect(result).to eq([1, 2, 3.0, 4.0])
end

Expand All @@ -42,7 +42,13 @@
end

ractors.each do |ractor|
expect(ractor.take).to eq([1, 2, 3.0, 4.0])
expect(value(ractor)).to eq([1, 2, 3.0, 4.0])
end
end

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("4.0")
def value(ractor) = ractor.value
else
def value(ractor) = ractor.take
end
end
2 changes: 1 addition & 1 deletion wasmtime.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Gem::Specification.new do |spec|

spec.rdoc_options += ["--exclude", "vendor"]

spec.add_dependency "rb_sys", "~> 0.9.119"
spec.add_dependency "rb_sys", "~> 0.9.124"
end
Loading