Skip to content

Commit

Permalink
Merge pull request #2291 from fermyon/wasmtime-18
Browse files Browse the repository at this point in the history
Upgrade to wasmtime 18
  • Loading branch information
rylev authored Feb 26, 2024
2 parents 78f84e7 + dfa007e commit 2ea26c5
Show file tree
Hide file tree
Showing 9 changed files with 350 additions and 458 deletions.
499 changes: 241 additions & 258 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ llm-metal = ["llm", "spin-trigger-http/llm-metal"]
llm-cublas = ["llm", "spin-trigger-http/llm-cublas"]

[workspace]
members = [
"crates/*",
"tests/runtime-tests",
"tests/testing-framework",
]
members = ["crates/*", "tests/runtime-tests", "tests/testing-framework"]

[workspace.dependencies]
anyhow = "1.0.75"
Expand All @@ -128,12 +124,10 @@ hyper = { version = "1.0.0", features = ["full"] }
reqwest = { version = "0.11", features = ["stream", "blocking"] }
tracing = { version = "0.1", features = ["log"] }

wasi-common-preview1 = { version = "17.0.1", package = "wasi-common" }
wasmtime = "17.0.1"
wasmtime-wasi = { version = "17.0.1", features = [
"tokio",
] }
wasmtime-wasi-http = "17.0.1"
wasi-common-preview1 = { version = "18.0.1", package = "wasi-common" }
wasmtime = "18.0.1"
wasmtime-wasi = { version = "18.0.1", features = ["tokio"] }
wasmtime-wasi-http = "18.0.1"

spin-componentize = { git = "https://github.com/fermyon/spin-componentize", rev = "191789170abde10cd55590466c0660dd6c7d472a" }

Expand Down
15 changes: 2 additions & 13 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,11 @@ impl<T> AsMut<T> for Data<T> {
}

impl<T: Send> wasmtime_wasi::preview2::WasiView for Data<T> {
fn table(&self) -> &ResourceTable {
&self.table
}

fn table_mut(&mut self) -> &mut ResourceTable {
fn table(&mut self) -> &mut ResourceTable {
&mut self.table
}

fn ctx(&self) -> &wasmtime_wasi::preview2::WasiCtx {
match &self.wasi {
Wasi::Preview1(_) => panic!("using WASI Preview 1 functions with Preview 2 store"),
Wasi::Preview2 { wasi_ctx, .. } => wasi_ctx,
}
}

fn ctx_mut(&mut self) -> &mut wasmtime_wasi::preview2::WasiCtx {
fn ctx(&mut self) -> &mut wasmtime_wasi::preview2::WasiCtx {
match &mut self.wasi {
Wasi::Preview1(_) => panic!("using WASI Preview 1 functions with Preview 2 store"),
Wasi::Preview2 { wasi_ctx, .. } => wasi_ctx,
Expand Down
12 changes: 6 additions & 6 deletions crates/core/src/wasi_2023_10_18.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ impl UdpSocket {
socket: &Resource<UdpSocket>,
explicit: bool,
) -> wasmtime::Result<Result<(), SocketErrorCode>> {
let state = table.table_mut().get_mut(socket)?;
let state = table.table().get_mut(socket)?;
let (new_socket, addr) = match mem::replace(state, UdpSocket::Dummy) {
// Implicit finishes will call `stream` for sockets in the initial
// state.
Expand All @@ -1305,7 +1305,7 @@ impl UdpSocket {
Ok(pair) => pair,
Err(e) => return Ok(Err(e)),
};
*table.table_mut().get_mut(socket)? = UdpSocket::Connected {
*table.table().get_mut(socket)? = UdpSocket::Connected {
socket: new_socket,
incoming,
outgoing,
Expand Down Expand Up @@ -1359,7 +1359,7 @@ where
_network: Resource<Network>,
remote_address: IpSocketAddress,
) -> wasmtime::Result<Result<(), SocketErrorCode>> {
let socket = self.table_mut().get_mut(&self_)?;
let socket = self.table().get_mut(&self_)?;
let (new_state, result) = match mem::replace(socket, UdpSocket::Dummy) {
UdpSocket::Initial(socket) => (UdpSocket::Connecting(socket, remote_address), Ok(())),
other => (other, Err(SocketErrorCode::ConcurrencyConflict)),
Expand Down Expand Up @@ -1563,7 +1563,7 @@ where
}

fn drop(&mut self, rep: Resource<UdpSocket>) -> wasmtime::Result<()> {
let me = self.table_mut().delete(rep)?;
let me = self.table().delete(rep)?;
let socket = match me {
UdpSocket::Initial(s) => s,
UdpSocket::Connecting(s, _) => s,
Expand Down Expand Up @@ -1600,7 +1600,7 @@ where
Ok(socket) => socket,
Err(e) => return Ok(Err(e)),
};
let socket = self.table_mut().push(UdpSocket::Initial(socket))?;
let socket = self.table().push(UdpSocket::Initial(socket))?;
Ok(Ok(socket))
}
}
Expand Down Expand Up @@ -2185,7 +2185,7 @@ where
Ok(e) => Ok(Ok(e.into())),
Err(wasmtime_wasi::preview2::StreamError::Closed) => Ok(Err(StreamError::Closed)),
Err(wasmtime_wasi::preview2::StreamError::LastOperationFailed(e)) => {
let e = view.table_mut().push(e)?;
let e = view.table().push(e)?;
Ok(Err(StreamError::LastOperationFailed(e)))
}
Err(wasmtime_wasi::preview2::StreamError::Trap(e)) => Err(e),
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/wasi_2023_11_10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ where
Ok(e) => Ok(Ok(e.into())),
Err(wasmtime_wasi::preview2::StreamError::Closed) => Ok(Err(StreamError::Closed)),
Err(wasmtime_wasi::preview2::StreamError::LastOperationFailed(e)) => {
let e = view.table_mut().push(e)?;
let e = view.table().push(e)?;
Ok(Err(StreamError::LastOperationFailed(e)))
}
Err(wasmtime_wasi::preview2::StreamError::Trap(e)) => Err(e),
Expand Down
4 changes: 2 additions & 2 deletions crates/trigger-http/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use http_body_util::BodyExt;
use hyper::{Request, Response};
use outbound_http::OutboundHttpComponent;
use spin_core::async_trait;
use spin_core::wasi_2023_10_18::exports::wasi::http::incoming_handler::IncomingHandler as IncomingHandler2023_10_18;
use spin_core::wasi_2023_11_10::exports::wasi::http::incoming_handler::IncomingHandler as IncomingHandler2023_11_10;
use spin_core::wasi_2023_10_18::exports::wasi::http::incoming_handler::Guest as IncomingHandler2023_10_18;
use spin_core::wasi_2023_11_10::exports::wasi::http::incoming_handler::Guest as IncomingHandler2023_11_10;
use spin_core::Instance;
use spin_http::body;
use spin_trigger::{EitherInstance, TriggerAppEngine};
Expand Down
Loading

0 comments on commit 2ea26c5

Please sign in to comment.