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

Update walrus to 0.21.0 #65

Merged
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
23 changes: 4 additions & 19 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ anyhow = "1"
clap = { version = "4", features = ["derive"] }
serde = { version = "1", features = ["derive"] }
toml = "0.8"
walrus = "0.20.3"
walrus = "0.21.0"
wasm-compose = "0.212.0"
wasm-metadata = "0.212.0"
wasm-opt = { version = "0.116.0", optional = true }
Expand Down
22 changes: 11 additions & 11 deletions src/data.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use anyhow::{bail, Result};
use std::collections::HashMap;
use walrus::{
ActiveData, ActiveDataLocation, DataKind, ElementKind, FunctionBuilder, FunctionId,
FunctionKind, InitExpr, Module, ValType,
ActiveData, ActiveDataLocation, ConstExpr, DataKind, ElementItems, ElementKind,
FunctionBuilder, FunctionId, FunctionKind, Module, RefType, ValType,
};

use crate::walrus_ops::bump_stack_global;
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Data {
let len_local = module.locals.add(ValType::I32);
let ptr_local = module.locals.add(ValType::I32);

let mut passive_fids: Vec<Option<FunctionId>> = Vec::new();
let mut passive_fids: Vec<FunctionId> = Vec::new();
for passive_segment in self.passive_segments {
let passive_id = module.data.add(DataKind::Passive, passive_segment);

Expand Down Expand Up @@ -166,25 +166,25 @@ impl Data {
// return the allocated pointer
.local_get(ptr_local);

passive_fids.push(Some(
passive_fids.push(
module
.funcs
.add_local(builder.local_func(vec![offset_local, len_local])),
));
);
}

let passive_tid = module.tables.add_local(
passive_fids.len() as u32,
Some(passive_fids.len() as u32),
ValType::Funcref,
false,
passive_fids.len() as u64,
Some(passive_fids.len() as u64),
RefType::Funcref,
);
module.elements.add(
ElementKind::Active {
table: passive_tid,
offset: InitExpr::Value(walrus::ir::Value::I32(0)),
offset: ConstExpr::Value(walrus::ir::Value::I32(0)),
},
ValType::Funcref,
passive_fids,
ElementItems::Functions(passive_fids),
);

// main passive call function
Expand Down
4 changes: 2 additions & 2 deletions src/virt_env.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{bail, Context, Result};
use serde::Deserialize;
use walrus::{
ir::Value, ActiveData, ActiveDataLocation, DataKind, ExportItem, GlobalKind, InitExpr, Module,
ir::Value, ActiveData, ActiveDataLocation, ConstExpr, DataKind, ExportItem, GlobalKind, Module,
};

use crate::walrus_ops::{bump_stack_global, get_active_data_segment};
Expand Down Expand Up @@ -78,7 +78,7 @@ pub(crate) fn create_env_virt<'a>(module: &'a mut Module, env: &VirtEnv) -> Resu
let ExportItem::Global(env_ptr_global) = env_ptr_export.item else {
bail!("Adapter 'env' not a global");
};
let GlobalKind::Local(InitExpr::Value(Value::I32(env_ptr_addr))) =
let GlobalKind::Local(ConstExpr::Value(Value::I32(env_ptr_addr))) =
&module.globals.get(env_ptr_global).kind
else {
bail!("Adapter 'env' not a local I32 global value");
Expand Down
4 changes: 2 additions & 2 deletions src/virt_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::BTreeMap, fmt, fs};
use anyhow::{bail, Context, Result};
use clap::ValueEnum;
use serde::Deserialize;
use walrus::{ir::Value, ExportItem, GlobalKind, InitExpr, Module};
use walrus::{ir::Value, ConstExpr, ExportItem, GlobalKind, Module};

use crate::{
data::{Data, WasmEncode},
Expand Down Expand Up @@ -505,7 +505,7 @@ pub(crate) fn create_io_virt<'a>(
let ExportItem::Global(io_ptr_global) = io_ptr_export.item else {
bail!("Virt adapter 'io' not a global");
};
let GlobalKind::Local(InitExpr::Value(Value::I32(io_ptr_addr))) =
let GlobalKind::Local(ConstExpr::Value(Value::I32(io_ptr_addr))) =
&module.globals.get(io_ptr_global).kind
else {
bail!("Virt adapter 'io' not a local I32 global value");
Expand Down
7 changes: 4 additions & 3 deletions src/walrus_ops.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{bail, Context, Result};
use walrus::{
ir::Value, ActiveData, ActiveDataLocation, Data, DataKind, GlobalKind, InitExpr, MemoryId,
ir::Value, ActiveData, ActiveDataLocation, ConstExpr, Data, DataKind, GlobalKind, MemoryId,
Module,
};

Expand Down Expand Up @@ -56,7 +56,7 @@ pub(crate) fn get_stack_global(module: &Module) -> Result<u32> {
.context("Unable to find __stack_pointer global name")?
.id();
let stack_global = module.globals.get(stack_global_id);
let GlobalKind::Local(InitExpr::Value(Value::I32(stack_value))) = &stack_global.kind else {
let GlobalKind::Local(ConstExpr::Value(Value::I32(stack_value))) = &stack_global.kind else {
bail!("Stack global is not a constant I32");
};
Ok(*stack_value as u32)
Expand All @@ -73,7 +73,8 @@ pub(crate) fn bump_stack_global(module: &mut Module, offset: i32) -> Result<u32>
.context("Unable to find __stack_pointer global name")?
.id();
let stack_global = module.globals.get_mut(stack_global_id);
let GlobalKind::Local(InitExpr::Value(Value::I32(stack_value))) = &mut stack_global.kind else {
let GlobalKind::Local(ConstExpr::Value(Value::I32(stack_value))) = &mut stack_global.kind
else {
bail!("Stack global is not a constant I32");
};
if offset > *stack_value {
Expand Down