Skip to content

Commit

Permalink
Merge pull request #26 from kateinoigakukun/katei/update-testsuite
Browse files Browse the repository at this point in the history
Update testsuite
  • Loading branch information
kateinoigakukun authored Nov 21, 2023
2 parents 261cf8a + 1ba9284 commit efafdeb
Show file tree
Hide file tree
Showing 23 changed files with 373 additions and 1,154 deletions.
26 changes: 21 additions & 5 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ fn test_directory(out: &mut String, path: impl AsRef<Path>) -> Result<usize> {
if p.file_stem()?.to_str()?.starts_with('.') {
return None;
}
// Skip simd tests for now.
if p.file_name()?.to_str()?.starts_with("simd_") {
return None;
}
Some(p)
})
.collect();
Expand Down
2 changes: 1 addition & 1 deletion crates/debugger-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
wasminspect-debugger = { path = "../debugger" }
wasminspect-vm = { path = "../vm" }
wasmparser = "0.81.0"
wasmparser = "0.95.0"
anyhow = "1.0.26"
hyper = { version = "0.14.0", features = ["full"] }
serde = { version = "1.0.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ clap = "2.33.0"
structopt = "0.3"
thiserror = "1.0.9"
anyhow = "1.0.26"
wasmparser = "0.81.0"
wasmparser = "0.95.0"
gimli = "0.21.0"
log = "0.4.8"
num-bigint = "0.4"
Expand Down
6 changes: 3 additions & 3 deletions crates/debugger/src/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl MainDebugger {
}
}
(FunctionInstance::Defined(func), exec_addr) => {
let ret_types = &func.ty().returns;
let ret_types = &func.ty().results();
let frame = CallFrame::new_from_func(exec_addr, func, args, None);
let pc = ProgramCounter::new(func.module_index(), exec_addr, InstIndex::zero());
let executor = Rc::new(RefCell::new(Executor::new(frame, ret_types.len(), pc)));
Expand Down Expand Up @@ -244,7 +244,7 @@ impl debugger::Debugger for MainDebugger {

Some(debugger::FunctionFrame {
module_index: frame.module_index,
argument_count: func.ty().params.len(),
argument_count: func.ty().params().len(),
})
}
fn frame(&self) -> Vec<String> {
Expand Down Expand Up @@ -343,7 +343,7 @@ impl debugger::Debugger for MainDebugger {
let func = store.func_global(pc.exec_addr());
let results = executor
.borrow_mut()
.pop_result(func.ty().returns.to_vec())?;
.pop_result(func.ty().results().to_vec())?;
return Ok(RunResult::Finish(results));
}
Err(err) => return Err(anyhow!("Function exec failure {}", err)),
Expand Down
4 changes: 2 additions & 2 deletions crates/debugger/src/dwarf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub fn parse_dwarf(module: &[u8]) -> Result<Dwarf> {
let mut sections = HashMap::new();
for payload in parser.parse_all(module) {
match payload? {
wasmparser::Payload::CustomSection { name, data, .. } => {
sections.insert(name, data);
wasmparser::Payload::CustomSection(section) => {
sections.insert(section.name(), section.data());
}
_ => continue,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Yuta Saito <kateinoigakukun@gmail.com>"]
edition = "2018"

[dependencies]
wasmparser = "0.81.0"
wasmparser = "0.95.0"
thiserror = "1.0.9"
anyhow = "1.0.26"
wasminspect-vm-macro = { path = "./macro" }
63 changes: 63 additions & 0 deletions crates/vm/macro/src/inst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,69 @@ pub fn try_from_wasmparser_operator(ast: DeriveInput) -> Result<proc_macro2::Tok
})
}

pub fn define_instr_kind(ast: proc_macro2::TokenStream) -> Result<proc_macro2::TokenStream> {
// Accept ($( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident)*)

let mut tokens = proc_macro2::TokenStream::new();
let mut iter = ast.into_iter();

loop {
let at = match iter.next() {
Some(t) => t,
None => break,
};
assert_eq!(at.to_string(), "@");

let _proposal = iter.next().expect("unexpected end of input");

let op = iter.next().expect("unexpected end of input");
let op = match op {
proc_macro2::TokenTree::Ident(i) => i,
_ => panic!("unexpected token: {}", op),
};

let mut payload = None;
if let Some(proc_macro2::TokenTree::Group(g)) = iter.clone().next() {
iter.next();
payload = Some(g.stream());
}

assert_eq!(iter.next().expect("unexpected end of input").to_string(), "=");
assert_eq!(iter.next().expect("unexpected end of input").to_string(), ">");
iter.next().expect("unexpected end of input");


tokens.extend(build_instr_kind_case(op, payload));
}

Ok(quote! {
#[derive(Debug, Clone, TryFromWasmParserOperator)]
pub enum InstructionKind {
#tokens
}
})
}

fn build_instr_kind_case(op: proc_macro2::Ident, payload: Option<proc_macro2::TokenStream>) -> proc_macro2::TokenStream {
if let Some(payload) = payload {
// BrTable is a special case because it has lifetime in its payload
if op == "BrTable" {
return quote! {
#op {
targets: BrTableData
},
};
}
quote! {
#op { #payload },
}
} else {
quote! {
#op,
}
}
}

fn build_translate_arm(
enum_name: &proc_macro2::Ident,
variant: &Variant,
Expand Down
7 changes: 7 additions & 0 deletions crates/vm/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ pub fn try_from_wasmparser_operator(args: TokenStream) -> TokenStream {
.unwrap()
.into()
}

#[proc_macro]
pub fn define_instr_kind(args: TokenStream) -> TokenStream {
inst::define_instr_kind(syn::parse_macro_input!(args))
.unwrap()
.into()
}
Loading

0 comments on commit efafdeb

Please sign in to comment.