Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
use witx 0.9 (#637)
Browse files Browse the repository at this point in the history
* bump wasmtime submodule and update for witx 0.9 changes

* fix witx syntax in test
  • Loading branch information
Pat Hickey authored Feb 25, 2021
1 parent 4a948c7 commit 9082715
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 46 deletions.
12 changes: 6 additions & 6 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 lucet-wiggle/generate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
[dependencies]
wiggle-generate = { path = "../../wasmtime/crates/wiggle/generate", version = "0.23.0" }
lucet-module = { path = "../../lucet-module", version = "0.7.0-dev" }
witx = { path = "../../wasmtime/crates/wasi-common/WASI/tools/witx", version = "0.8.4" }
witx = { path = "../../wasmtime/crates/wasi-common/WASI/tools/witx", version = "0.9" }
quote = "1.0"
proc-macro2 = "1.0"
heck = "*"
Expand Down
38 changes: 19 additions & 19 deletions lucet-wiggle/generate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub use config::Config;

use heck::SnakeCase;
use lucet_module::bindings::Bindings;
use proc_macro2::{Ident, TokenStream};
use proc_macro2::{Ident, Span, TokenStream};
use quote::{format_ident, quote};

pub fn hostcall_name(m: &witx::Module, f: &witx::InterfaceFunc) -> String {
Expand Down Expand Up @@ -40,34 +40,34 @@ pub fn generate(
let fs = doc.modules().map(|m| {
let fs = m.funcs().map(|f| {
let name = format_ident!("{}", hostcall_name(&m, &f));
let coretype = f.core_type();
let func_args = coretype.args.iter().map(|a| {
let name = names.func_core_arg(a);
let atom = names.atom_type(a.repr());
let (params, results) = f.wasm_signature();
let arg_names = (0..params.len())
.map(|i| Ident::new(&format!("arg{}", i), Span::call_site()))
.collect::<Vec<_>>();
let func_args = params.iter().enumerate().map(|(i, ty)| {
let name = &arg_names[i];
let atom = names.wasm_type(*ty);
quote!(#name: #atom)
});
let call_args = coretype.args.iter().map(|a| {
let name = names.func_core_arg(a);
quote!(#name)
});
let rets = coretype
.ret
.as_ref()
.map(|r| {
let atom = names.atom_type(r.repr());
quote!(#atom)
})
.unwrap_or(quote!(()));
let ret_ty = match results.len() {
0 => quote!(()),
1 => names.wasm_type(results[0]),
_ => panic!(
"lucet-wiggle only supports 0 or 1 result type. function {} has: {:?}",
hostcall_name(&m, &f),
results
),
};
let mod_name = names.module(&m.name);
let method_name = names.func(&f.name);
quote! {
#[lucet_hostcall]
#[no_mangle]
pub fn #name(vmctx: &lucet_runtime::vmctx::Vmctx, #(#func_args),*) -> #rets {
pub fn #name(vmctx: &lucet_runtime::vmctx::Vmctx, #(#func_args),*) -> #ret_ty {
{ #pre_hook }
let memory = lucet_wiggle::runtime::LucetMemory::new(vmctx);
let mut ctx: #ctx_type = #ctx_constructor;
let r = super::#mod_name::#method_name(&ctx, &memory, #(#call_args),*);
let r = super::#mod_name::#method_name(&ctx, &memory, #(#arg_names),*);
{ #post_hook }
match r {
Ok(r) => { r },
Expand Down
2 changes: 1 addition & 1 deletion lucet-wiggle/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ proc-macro = true
[dependencies]
lucet-wiggle-generate = { path = "../generate", version = "0.7.0-dev" }
wiggle-generate = { path = "../../wasmtime/crates/wiggle/generate", version = "0.23.0" }
witx = { path = "../../wasmtime/crates/wasi-common/WASI/tools/witx", version = "0.8.8" }
witx = { path = "../../wasmtime/crates/wasi-common/WASI/tools/witx", version = "0.9" }
syn = { version = "1.0", features = ["full"] }
quote = "1.0"
2 changes: 1 addition & 1 deletion lucetc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cranelift-wasm = { path = "../wasmtime/cranelift/wasm", version = "0.70.0" }
target-lexicon = "0.11"
lucet-module = { path = "../lucet-module", version = "=0.7.0-dev" }
lucet-wiggle-generate = { path = "../lucet-wiggle/generate", version = "=0.7.0-dev" }
witx = { path = "../wasmtime/crates/wasi-common/WASI/tools/witx", version = "0.8.5" }
witx = { path = "../wasmtime/crates/wasi-common/WASI/tools/witx", version = "0.9" }
wasmparser = "0.59.0"
clap="2.32"

Expand Down
30 changes: 15 additions & 15 deletions lucetc/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use thiserror::Error;
use witx::Id;

pub use cranelift_wasm::{WasmFuncType, WasmType};
pub use witx::{AtomType, Document, WitxError};
pub use witx::{Document, WitxError};

#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum Error {
Expand Down Expand Up @@ -187,7 +187,7 @@ impl Validator {
.ok_or(not_found.clone())?
.func(&Id::new(field))
.ok_or(not_found)?;
let spec_type = witx_to_functype(&func.core_type());
let spec_type = witx_to_functype(&func);
if &spec_type != type_ {
Err(Error::ImportTypeError {
module: module.to_owned(),
Expand Down Expand Up @@ -235,25 +235,25 @@ impl Validator {
}
}

fn witx_to_functype(coretype: &witx::CoreFuncType) -> WasmFuncType {
fn atom_to_type(atom: &witx::AtomType) -> WasmType {
fn witx_to_functype(func: &witx::InterfaceFunc) -> WasmFuncType {
fn atom_to_type(atom: &witx::WasmType) -> WasmType {
match atom {
witx::AtomType::I32 => WasmType::I32,
witx::AtomType::I64 => WasmType::I64,
witx::AtomType::F32 => WasmType::F32,
witx::AtomType::F64 => WasmType::F64,
witx::WasmType::I32 => WasmType::I32,
witx::WasmType::I64 => WasmType::I64,
witx::WasmType::F32 => WasmType::F32,
witx::WasmType::F64 => WasmType::F64,
}
}
let params = coretype
.args
let (params, results) = func.wasm_signature();
let params = params
.iter()
.map(|a| atom_to_type(&a.repr()))
.map(|a| atom_to_type(&a))
.collect::<Vec<_>>()
.into_boxed_slice();
let returns = if let Some(ref r) = coretype.ret {
vec![atom_to_type(&r.repr())].into_boxed_slice()
} else {
vec![].into_boxed_slice()
let returns = match results.len() {
0 => vec![].into_boxed_slice(),
1 => vec![atom_to_type(&results[0])].into_boxed_slice(),
_ => unimplemented!("multiple result types"),
};
WasmFuncType { params, returns }
}
4 changes: 2 additions & 2 deletions lucetc/tests/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,15 @@ mod validate {
let b = stub_wasi_bindings();

let witx = "
(typename $errno (enum u8 $inval))
(typename $errno (enum (@witx tag u8) $inval))
(module $wasi_snapshot_preview1
(import \"memory\" (memory))
;;; Read command-line argument data.
;;; The size of the array should match that returned by `args_sizes_get`
(@interface func (export \"args_get\")
(param $argv (@witx pointer (@witx pointer u8)))
(param $argv_buf (@witx pointer u8))
(result $error $errno)
(result $error (expected (error $errno)))
)
)";
let v = Validator::builder()
Expand Down
2 changes: 1 addition & 1 deletion wasmtime
Submodule wasmtime updated 93 files
+34 −10 .github/ISSUE_TEMPLATE/clif-bug-report.md
+10 −11 .github/ISSUE_TEMPLATE/improvement.md
+31 −9 .github/ISSUE_TEMPLATE/wasmtime-bug-report.md
+32 −29 Cargo.lock
+3 −3 Cargo.toml
+1 −1 cranelift/codegen/Cargo.toml
+5 −0 cranelift/codegen/src/ir/jumptable.rs
+13 −0 cranelift/codegen/src/unreachable_code.rs
+21 −0 cranelift/filetests/filetests/isa/x64/unused_jt_unreachable_block.clif
+3 −6 cranelift/jit/src/backend.rs
+6 −11 cranelift/module/src/module.rs
+3 −6 cranelift/object/src/backend.rs
+1 −1 cranelift/peepmatic/Cargo.toml
+1 −1 cranelift/peepmatic/crates/fuzzing/Cargo.toml
+1 −1 cranelift/peepmatic/crates/runtime/Cargo.toml
+1 −1 cranelift/peepmatic/crates/souper/Cargo.toml
+1 −1 cranelift/peepmatic/crates/test-operator/Cargo.toml
+1 −1 cranelift/wasm/Cargo.toml
+23 −2 cranelift/wasm/src/code_translator.rs
+5 −0 crates/bench-api/Cargo.toml
+28 −3 crates/bench-api/src/lib.rs
+1 −1 crates/cranelift/Cargo.toml
+1 −1 crates/debug/Cargo.toml
+1 −1 crates/environ/Cargo.toml
+2 −2 crates/fuzzing/Cargo.toml
+1 −1 crates/jit/Cargo.toml
+1 −1 crates/lightbeam/Cargo.toml
+1 −1 crates/lightbeam/wasmtime/Cargo.toml
+71 −0 crates/runtime/src/traphandlers.rs
+1 −1 crates/wasi-common/WASI
+1 −1 crates/wasi-crypto/spec
+6 −4 crates/wasi-crypto/src/wiggle_interfaces/asymmetric_common.rs
+1 −13 crates/wasi-crypto/src/wiggle_interfaces/common.rs
+4 −4 crates/wasi-crypto/src/wiggle_interfaces/symmetric.rs
+1 −1 crates/wasi-nn/spec
+1 −1 crates/wasi-nn/src/impl.rs
+0 −1 crates/wasi-nn/src/lib.rs
+6 −6 crates/wasi-nn/src/witx.rs
+2 −2 crates/wasmtime/Cargo.toml
+1 −1 crates/wast/Cargo.toml
+1 −1 crates/wiggle/Cargo.toml
+1 −1 crates/wiggle/generate/Cargo.toml
+5 −1 crates/wiggle/generate/src/error_transform.rs
+288 −299 crates/wiggle/generate/src/funcs.rs
+19 −3 crates/wiggle/generate/src/lib.rs
+13 −22 crates/wiggle/generate/src/lifetimes.rs
+34 −32 crates/wiggle/generate/src/module_trait.rs
+48 −34 crates/wiggle/generate/src/names.rs
+0 −120 crates/wiggle/generate/src/types/enum.rs
+15 −31 crates/wiggle/generate/src/types/flags.rs
+0 −2 crates/wiggle/generate/src/types/handle.rs
+0 −100 crates/wiggle/generate/src/types/int.rs
+17 −39 crates/wiggle/generate/src/types/mod.rs
+5 −5 crates/wiggle/generate/src/types/record.rs
+0 −116 crates/wiggle/generate/src/types/union.rs
+149 −0 crates/wiggle/generate/src/types/variant.rs
+1 −1 crates/wiggle/macro/Cargo.toml
+6 −0 crates/wiggle/src/lib.rs
+7 −8 crates/wiggle/test-helpers/examples/tracing.rs
+2 −2 crates/wiggle/tests/atoms.rs
+2 −3 crates/wiggle/tests/atoms.witx
+1 −1 crates/wiggle/tests/errno.witx
+9 −9 crates/wiggle/tests/errors.rs
+1 −1 crates/wiggle/tests/excuse.witx
+2 −2 crates/wiggle/tests/flags.rs
+2 −3 crates/wiggle/tests/flags.witx
+3 −3 crates/wiggle/tests/handles.rs
+2 −3 crates/wiggle/tests/handles.witx
+4 −4 crates/wiggle/tests/ints.rs
+4 −9 crates/wiggle/tests/ints.witx
+3 −3 crates/wiggle/tests/keywords.rs
+4 −4 crates/wiggle/tests/keywords_union.witx
+11 −11 crates/wiggle/tests/lists.rs
+13 −13 crates/wiggle/tests/lists.witx
+3 −4 crates/wiggle/tests/pointers.rs
+1 −1 crates/wiggle/tests/pointers.witx
+18 −18 crates/wiggle/tests/records.rs
+17 −20 crates/wiggle/tests/records.witx
+3 −3 crates/wiggle/tests/strings.rs
+5 −4 crates/wiggle/tests/strings.witx
+38 −38 crates/wiggle/tests/typenames.witx
+0 −31 crates/wiggle/tests/union.witx
+8 −8 crates/wiggle/tests/variant.rs
+27 −0 crates/wiggle/tests/variant.witx
+1 −1 crates/wiggle/tests/wasi.rs
+54 −78 crates/wiggle/tests/wasi.witx
+1 −1 crates/wiggle/wasmtime/Cargo.toml
+1 −1 crates/wiggle/wasmtime/macro/Cargo.toml
+0 −53 crates/wiggle/wasmtime/macro/src/config.rs
+17 −24 crates/wiggle/wasmtime/macro/src/lib.rs
+2 −2 tests/misc_testsuite/module-linking/alias-outer.wast
+5 −5 tests/misc_testsuite/module-linking/alias.wast
+25 −25 tests/misc_testsuite/module-linking/instantiate.wast

0 comments on commit 9082715

Please sign in to comment.