Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: WASI-Virt with upstreamed walrus changes #24

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
8 changes: 3 additions & 5 deletions Cargo.lock

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

13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ members = [
"tests/components/do-everything",
"tests/components/file-read",
"tests/components/get-env",
"tests/components/stdio"
"tests/components/stdio",
]

[profile.release]
Expand All @@ -33,7 +33,8 @@ anyhow = "1"
clap = { version = "4", features = ["derive"] }
serde = { version = "1", features = ["derive"] }
toml = "0.7"
walrus = "0.20.1"
# TODO: use published version of walrus
walrus = { git = "https://github.com/rustwasm/walrus", rev = "db5d437b91e80c564f5e45204b8b165027d2a870" }
wasm-compose = "0.4.2"
wasm-metadata = "0.10.5"
wasm-opt = "0.114.1"
Expand All @@ -45,12 +46,14 @@ anyhow = "1"
[dev-dependencies]
anyhow = "1"
cap-std = "1.0.12"
heck = { version = "0.4" }
heck = { version = "0.4" }
tokio = { version = "1.30.0", features = ["macros"] }
wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", features = ["component-model"] }
wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", features = [
"component-model",
] }
wasmtime-wasi = { git = "https://github.com/bytecodealliance/wasmtime" }
wasmparser = "0.113.1"

[workspace.dependencies]
anyhow = "1"
wit-bindgen = "0.12.0"
wit-bindgen = "0.12.0"
13 changes: 6 additions & 7 deletions src/data.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use crate::walrus_ops::{
bump_stack_global, get_exported_func, get_memory_id, remove_exported_func,
};
use anyhow::{bail, Result};
use std::collections::HashMap;
use walrus::{
ActiveData, ActiveDataLocation, DataKind, ElementKind, FunctionBuilder, FunctionId,
FunctionKind, InitExpr, Module, ValType,
};

use crate::walrus_ops::bump_stack_global;

/// Data section
/// Because data is stack-allocated we create a corresponding byte vector as large
/// as the stack, zero fill it then populate it backwards from the
Expand Down Expand Up @@ -115,7 +114,7 @@ impl Data {
}
pub fn finish(mut self, module: &mut Module) -> Result<()> {
// stack embedding
let memory = get_memory_id(module)?;
let memory = module.get_memory_id()?;
let rem = (self.stack_start - self.stack_ptr) % 8;
if rem != 0 {
self.stack_ptr -= 8 - rem;
Expand All @@ -132,7 +131,7 @@ impl Data {
// passive segment embedding
// we create one function for each passive segment, due to
if self.passive_segments.len() > 0 {
let alloc_fid = get_exported_func(module, "cabi_realloc")?;
let alloc_fid = module.exports.get_func("cabi_realloc")?;

let offset_local = module.locals.add(ValType::I32);
let len_local = module.locals.add(ValType::I32);
Expand Down Expand Up @@ -206,13 +205,13 @@ impl Data {
.call_indirect(passive_fn_alloc_type, passive_tid);

// update the existing passive_alloc function export with the new function body
let passive_alloc_fid = get_exported_func(module, "passive_alloc")?;
let passive_alloc_fid = module.exports.get_func("passive_alloc")?;
let passive_alloc_func = module.funcs.get_mut(passive_alloc_fid);
passive_alloc_func.kind =
FunctionKind::Local(builder.local_func(vec![passive_idx, offset_local, len_local]));
}

remove_exported_func(module, "passive_alloc")?;
module.exports.remove("passive_alloc")?;

Ok(())
}
Expand Down
Loading
Loading