diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe3bfc1383ac..3fa37f3cef40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -194,6 +194,7 @@ jobs: audit: ${{ steps.calculate.outputs.audit }} preview1-adapter: ${{ steps.calculate.outputs.preview1-adapter }} run-dwarf: ${{ steps.calculate.outputs.run-dwarf }} + platform-checks: ${{ steps.calculate.outputs.platform-checks }} steps: - uses: actions/checkout@v4 - id: calculate @@ -216,6 +217,8 @@ jobs: run_full=true elif grep -q 'prtest:debug' commits.log; then echo run-dwarf=true >> $GITHUB_OUTPUT + elif grep -q 'prtest:platform-checks' commits.log; then + echo platform-checks=true >> $GITHUB_OUTPUT fi if grep -q crates.c-api names.log; then echo test-capi=true >> $GITHUB_OUTPUT @@ -257,6 +260,7 @@ jobs: echo audit=true >> $GITHUB_OUTPUT echo preview1-adapter=true >> $GITHUB_OUTPUT echo run-dwarf=true >> $GITHUB_OUTPUT + echo platform-checks=true >> $GITHUB_OUTPUT fi # Build all documentation of Wasmtime, including the C API documentation, @@ -442,30 +446,6 @@ jobs: - uses: ./.github/actions/cancel-on-failure if: failure() - # Checks for no_std support, ensure that crates can build on a no_std target - no_std_checks: - name: no_std checks - runs-on: ubuntu-latest - env: - CARGO_NDK_VERSION: 2.12.2 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: ./.github/actions/install-rust - - # NOTE(dhil): Currently, we only support x86_64 Linux. - # - run: rustup target add x86_64-unknown-none - # - run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,component-model - # - run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,gc,component-model - # - run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps - # - run: cargo check --target x86_64-unknown-none -p cranelift-control --no-default-features - # - run: cargo check --target x86_64-unknown-none -p pulley-interpreter --features encode,decode,disas,interp - - # common logic to cancel the entire run if this job fails - - uses: ./.github/actions/cancel-on-failure - if: failure() - # Check that Clippy lints are passing. clippy: name: Clippy @@ -520,10 +500,6 @@ jobs: - run: cargo check --features wasmfx_pooling_allocator - run: cargo check --features wasmfx_baseline,wasmfx_pooling_allocator - # Check whether `wasmtime` cross-compiles to x86_64-unknown-freebsd - - run: rustup target add x86_64-unknown-freebsd - - run: cargo check --target x86_64-unknown-freebsd - # Re-vendor all WIT files and ensure that they're all up-to-date by ensuring # that there's no git changes. - name: Re-vendor WIT @@ -539,45 +515,66 @@ jobs: - uses: ./.github/actions/cancel-on-failure if: failure() - checks_illumos: - name: Check illumos - runs-on: ubuntu-latest + # Various checks that Wasmtime builds for a variety of platforms. Each + # platform may not include the entire dependency tree and maybe just a few + # features here and there, see the `include` matrix for more details. + platform_checks: + needs: determine + # NOTE(dhil): Disabled as the platforms are currently unsupported. + if: false && needs.determine.outputs.platform-checks + name: "Platform: ${{ matrix.target }}" + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + include: + - target: x86_64-unknown-freebsd + os: ubuntu-latest + test: cargo check + - target: aarch64-pc-windows-msvc + os: windows-latest + test: cargo check + # While we're here testing a windows target also test a feature'd build + # on Windows. Note that this isn't covered by `micro_checks` above since + # that's for unix platforms, not Windows, so include a small check here + # which isn't the full `micro_checks` matrix but hopefully enough bang + # for our buck. + - target: i686-pc-windows-msvc + os: windows-latest + test: cargo check && cargo build -p wasmtime --no-default-features --features runtime + # This is used for general compatibility with `#![no_std]` targets and a + # variety of crates are tested here. + - target: x86_64-unknown-none + os: ubuntu-latest + test: > + cargo check -p wasmtime --no-default-features --features runtime,component-model && + cargo check -p wasmtime --no-default-features --features runtime,gc,component-model && + cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps && + cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps && + cargo check -p cranelift-control --no-default-features && + cargo check -p pulley-interpreter --features encode,decode,disas,interp + # Use `cross` for illumos to have a C compiler/linker available. + - target: x86_64-unknown-illumos + os: ubuntu-latest + cross: true + test: cross build + - target: wasm32-wasip1 + os: ubuntu-latest + test: cargo build --no-default-features --features compile,cranelift,all-arch steps: - uses: actions/checkout@v4 with: submodules: true - uses: ./.github/actions/install-rust - - # Check whether `wasmtime` cross-compiles to illumos. We need to use `cross` for this (even for - # cargo check) because of non-Rust dependencies. + - run: rustup target add ${{ matrix.target }} - name: Install cross run: | curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash cargo binstall --no-confirm cross - - name: Cross-compile to illumos - run: - cross build --target x86_64-unknown-illumos - - # common logic to cancel the entire run if this job fails - - uses: ./.github/actions/cancel-on-failure - if: failure() - - # Check whether `wasmtime` cross-compiles to aarch64-pc-windows-msvc - # We don't build nor test it because it lacks trap handling. - # Tracking issue: https://github.com/bytecodealliance/wasmtime/issues/4992 - checks_winarm64: - needs: determine - # TODO(dhil): This check is disabled due to lack of platform support. - if: needs.determine.outputs.run-full && false - name: Check Windows ARM64 - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: ./.github/actions/install-rust - - run: rustup target add aarch64-pc-windows-msvc - - run: cargo check -p wasmtime --target aarch64-pc-windows-msvc + if: ${{ matrix.cross }} + - run: ${{ matrix.test }} + env: + CARGO_BUILD_TARGET: ${{ matrix.target }} # common logic to cancel the entire run if this job fails - uses: ./.github/actions/cancel-on-failure @@ -991,27 +988,6 @@ jobs: - uses: ./.github/actions/cancel-on-failure if: failure() - - build-wasmtime-target-wasm32: - name: Build wasmtime-target-wasm32 - # TODO(dhil): This platform is unsupported. - if: false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: ./.github/actions/install-rust - - run: rustup target add wasm32-wasip1 wasm32-unknown-unknown - - run: cargo build --target wasm32-wasip1 --no-default-features --features compile,cranelift,all-arch - env: - VERSION: ${{ github.sha }} - - # common logic to cancel the entire run if this job fails - - uses: ./.github/actions/cancel-on-failure - if: failure() - - bench: needs: determine if: needs.determine.outputs.run-full @@ -1206,11 +1182,9 @@ jobs: - doc - micro_checks - fiber_tests - - no_std_checks - clippy - monolith_checks - - checks_illumos - - checks_winarm64 + - platform_checks - bench - meta_deterministic_check - verify-publish @@ -1218,7 +1192,6 @@ jobs: - miri - build-preview1-component-adapter - build-preview1-component-adapter-provider - - build-wasmtime-target-wasm32 - test-min-platform-example - check_js if: always() diff --git a/Cargo.lock b/Cargo.lock index 1ca90d333457..6dd9db5455a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3464,6 +3464,17 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "trait-variant" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70977707304198400eb4835a78f6a9f928bf41bba420deb8fdb175cd965d77a7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "try-lock" version = "0.2.4" @@ -3986,6 +3997,7 @@ dependencies = [ "sptr", "target-lexicon", "tempfile", + "trait-variant", "wasi-common", "wasm-encoder 0.221.2", "wasm-wave", @@ -4130,6 +4142,7 @@ dependencies = [ "tokio", "toml", "tracing", + "trait-variant", "walkdir", "wasi-common", "wasm-encoder 0.221.2", @@ -4432,6 +4445,7 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "trait-variant", "url", "wasmtime", "wiggle", diff --git a/Cargo.toml b/Cargo.toml index b18fde0e1e00..41981d233b85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,6 +74,7 @@ humantime = { workspace = true } tempfile = { workspace = true, optional = true } async-trait = { workspace = true } +trait-variant = { workspace = true } bytes = { workspace = true } cfg-if = { workspace = true } tokio = { workspace = true, optional = true, features = [ "signal", "macros" ] } @@ -98,6 +99,7 @@ criterion = { workspace = true } num_cpus = "1.13.0" memchr = "2.4" async-trait = { workspace = true } +trait-variant = { workspace = true } wat = { workspace = true } rayon = "1.5.0" wasmtime-wast = { workspace = true, features = ['component-model'] } @@ -316,6 +318,7 @@ tracing = "0.1.26" bitflags = "2.0" thiserror = "1.0.43" async-trait = "0.1.71" +trait-variant = "0.1.2" heck = "0.5" similar = "2.1.0" toml = "0.8.10" diff --git a/ci/build-test-matrix.js b/ci/build-test-matrix.js index 875070c79d33..35c813e8091a 100644 --- a/ci/build-test-matrix.js +++ b/ci/build-test-matrix.js @@ -83,9 +83,10 @@ const FULL_MATRIX = [ // TODO(dhil): Disabled as long as we don't support other platforms // than x86_64 Linux. // { - // "os": "macos-13", + // "os": macos, // "name": "Test macOS x86_64", // "filter": "macos-x64", + // "target": "x86_64-apple-darwin", // }, // { // "os": macos, diff --git a/cranelift/codegen/build.rs b/cranelift/codegen/build.rs index 2cbf2c9e5128..72ea49bbb886 100644 --- a/cranelift/codegen/build.rs +++ b/cranelift/codegen/build.rs @@ -212,11 +212,6 @@ fn run_compilation(compilation: &IsleCompilation) -> Result<(), Errors> { isle::compile::from_files(file_paths, &options)? }; - let code = rustfmt(&code).unwrap_or_else(|e| { - println!("cargo:warning=Failed to run `rustfmt` on ISLE-generated code: {e:?}"); - code - }); - eprintln!( "Writing ISLE-generated Rust code to {}", compilation.output.display() @@ -226,30 +221,3 @@ fn run_compilation(compilation: &IsleCompilation) -> Result<(), Errors> { Ok(()) } - -fn rustfmt(code: &str) -> std::io::Result { - use std::io::Write; - - let mut rustfmt = std::process::Command::new("rustfmt") - .stdin(std::process::Stdio::piped()) - .stdout(std::process::Stdio::piped()) - .spawn()?; - - let mut stdin = rustfmt.stdin.take().unwrap(); - stdin.write_all(code.as_bytes())?; - drop(stdin); - - let mut stdout = rustfmt.stdout.take().unwrap(); - let mut data = vec![]; - stdout.read_to_end(&mut data)?; - - let status = rustfmt.wait()?; - if !status.success() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("`rustfmt` exited with status {status}"), - )); - } - - Ok(String::from_utf8(data).expect("rustfmt always writes utf-8 to stdout")) -} diff --git a/cranelift/codegen/meta/src/cdsl/instructions.rs b/cranelift/codegen/meta/src/cdsl/instructions.rs index a0bf34e84932..b944255149fc 100644 --- a/cranelift/codegen/meta/src/cdsl/instructions.rs +++ b/cranelift/codegen/meta/src/cdsl/instructions.rs @@ -421,7 +421,7 @@ fn verify_polymorphic( /// Verify that the use of TypeVars is consistent with `ctrl_typevar` as the controlling type /// variable. /// -/// All polymorhic inputs must either be derived from `ctrl_typevar` or be independent free type +/// All polymorphic inputs must either be derived from `ctrl_typevar` or be independent free type /// variables only used once. /// /// All polymorphic results must be derived from `ctrl_typevar`. diff --git a/cranelift/codegen/meta/src/pulley.rs b/cranelift/codegen/meta/src/pulley.rs index fb7b2affb074..6fb8316b9270 100644 --- a/cranelift/codegen/meta/src/pulley.rs +++ b/cranelift/codegen/meta/src/pulley.rs @@ -89,7 +89,8 @@ impl Inst<'_> { match self.name { // Skip instructions related to control-flow as those require // special handling with `MachBuffer`. - "Jump" | "Call" | "CallIndirect" => true, + "Jump" => true, + n if n.starts_with("Call") => true, // Skip special instructions not used in Cranelift. "XPush32Many" | "XPush64Many" | "XPop32Many" | "XPop64Many" => true, diff --git a/cranelift/codegen/meta/src/shared/instructions.rs b/cranelift/codegen/meta/src/shared/instructions.rs index ec67c143b44d..2bdd07c0de8b 100644 --- a/cranelift/codegen/meta/src/shared/instructions.rs +++ b/cranelift/codegen/meta/src/shared/instructions.rs @@ -1815,7 +1815,7 @@ pub(crate) fn define( r#" Fixed-point multiplication of numbers in the QN format, where N + 1 is the number bitwidth: - `a := signed_saturate((x * y + 1 << (Q - 1)) >> Q)` + `a := signed_saturate((x * y + (1 << (Q - 1))) >> Q)` Polymorphic over all integer vector types with 16- or 32-bit numbers. "#, diff --git a/cranelift/codegen/src/isa/pulley_shared/abi.rs b/cranelift/codegen/src/isa/pulley_shared/abi.rs index 5c72b5311fcd..6efbd3927b2b 100644 --- a/cranelift/codegen/src/isa/pulley_shared/abi.rs +++ b/cranelift/codegen/src/isa/pulley_shared/abi.rs @@ -297,7 +297,7 @@ where /// common cases and we don't want to spread the logic over multiple /// functions. /// - /// The general machinst methods are split to accomodate stack checks and + /// The general machinst methods are split to accommodate stack checks and /// things like stack probes, all of which are empty on Pulley because /// Pulley has its own stack check mechanism. fn gen_prologue_frame_setup( @@ -441,15 +441,45 @@ where fn gen_call( dest: &CallDest, _tmp: Writable, - info: CallInfo<()>, + mut info: CallInfo<()>, ) -> SmallVec<[Self::I; 2]> { match dest { // "near" calls are pulley->pulley calls so they use a normal "call" // opcode - CallDest::ExtName(name, RelocDistance::Near) => smallvec![Inst::Call { - info: Box::new(info.map(|()| name.clone())) + CallDest::ExtName(name, RelocDistance::Near) => { + // The first four integer arguments to a call can be handled via + // special pulley call instructions. Assert here that + // `info.uses` is sorted in order and then take out x0-x3 if + // they're present and move them from `info.uses` to + // `info.dest.args` to be handled differently during register + // allocation. + let mut args = SmallVec::new(); + if cfg!(debug_assertions) { + let xargs = info + .uses + .iter() + .filter_map(|a| XReg::new(a.preg)) + .collect::>(); + for window in xargs.windows(2) { + assert!(window[0] < window[1]); + } + } + info.uses.retain(|arg| { + if arg.preg != x0() && arg.preg != x1() && arg.preg != x2() && arg.preg != x3() + { + return true; + } + args.push(XReg::new(arg.vreg).unwrap()); + false + }); + smallvec![Inst::Call { + info: Box::new(info.map(|()| PulleyCall { + name: name.clone(), + args, + })) + } + .into()] } - .into()], // "far" calls are pulley->host calls so they use a different opcode // which is lowered with a special relocation in the backend. CallDest::ExtName(name, RelocDistance::Far) => smallvec![Inst::IndirectCallHost { @@ -496,7 +526,7 @@ where fn get_machine_env(_flags: &settings::Flags, _call_conv: isa::CallConv) -> &MachineEnv { static MACHINE_ENV: OnceLock = OnceLock::new(); - MACHINE_ENV.get_or_init(create_reg_enviroment) + MACHINE_ENV.get_or_init(create_reg_environment) } fn get_regs_clobbered_by_call(_call_conv_of_callee: isa::CallConv) -> PRegSet { @@ -883,7 +913,7 @@ const DEFAULT_CLOBBERS: PRegSet = PRegSet::empty() .with(pv_reg(30)) .with(pv_reg(31)); -fn create_reg_enviroment() -> MachineEnv { +fn create_reg_environment() -> MachineEnv { // Prefer caller-saved registers over callee-saved registers, because that // way we don't need to emit code to save and restore them if we don't // mutate them. diff --git a/cranelift/codegen/src/isa/pulley_shared/inst.isle b/cranelift/codegen/src/isa/pulley_shared/inst.isle index 30c98eb5819a..ffb72c24abf5 100644 --- a/cranelift/codegen/src/isa/pulley_shared/inst.isle +++ b/cranelift/codegen/src/isa/pulley_shared/inst.isle @@ -58,7 +58,7 @@ ;; An indirect call out to a host-defined function. The host function ;; pointer is the first "argument" of this function call. - (IndirectCallHost (info BoxCallInfo)) + (IndirectCallHost (info BoxCallIndirectHostInfo)) ;; Unconditional jumps. (Jump (label MachLabel)) @@ -154,6 +154,7 @@ (type BoxReturnCallInfo (primitive BoxReturnCallInfo)) (type BoxReturnCallIndInfo (primitive BoxReturnCallIndInfo)) (type XRegSet (primitive XRegSet)) +(type BoxCallIndirectHostInfo (primitive BoxCallIndirectHostInfo)) ;;;; Address Modes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -389,18 +390,8 @@ (rule 0 (imm $I64 x) (pulley_xconst64 (u64_as_i64 x))) ;; Base cases for floats. -(rule 0 (imm $F32 c) (gen_bitcast (imm $I32 c) $I32 $F32)) -(rule 0 (imm $F64 c) (gen_bitcast (imm $I64 c) $I64 $F64)) - -;;;; Bitcasts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; Bitcast from the first type, into the second type. -(decl gen_bitcast (Reg Type Type) Reg) -(rule (gen_bitcast r $F32 $I32) (pulley_bitcast_float_from_int_32 r)) -(rule (gen_bitcast r $F64 $I64) (pulley_bitcast_float_from_int_64 r)) -(rule (gen_bitcast r $I32 $F32) (pulley_bitcast_int_from_float_32 r)) -(rule (gen_bitcast r $I64 $F64) (pulley_bitcast_int_from_float_64 r)) -(rule -1 (gen_bitcast r ty ty) r) +(rule 0 (imm $F32 (u64_as_u32 c)) (pulley_fconst32 c)) +(rule 0 (imm $F64 c) (pulley_fconst64 c)) ;;;; Instruction Constructors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/cranelift/codegen/src/isa/pulley_shared/inst/args.rs b/cranelift/codegen/src/isa/pulley_shared/inst/args.rs index cb7496336341..48bb791538e3 100644 --- a/cranelift/codegen/src/isa/pulley_shared/inst/args.rs +++ b/cranelift/codegen/src/isa/pulley_shared/inst/args.rs @@ -1,6 +1,7 @@ //! Pulley instruction arguments. use super::*; +use crate::ir::ExternalName; use crate::machinst::abi::StackAMode; use pulley_interpreter::encode; use pulley_interpreter::regs::Reg as _; @@ -137,7 +138,7 @@ impl XReg { } } - /// Returns the pulley-typed register, if this is a phyiscal register. + /// Returns the pulley-typed register, if this is a physical register. pub fn as_pulley(&self) -> Option { let enc = self.to_real_reg()?.hw_enc(); Some(pulley_interpreter::XReg::new(enc).unwrap()) @@ -565,3 +566,15 @@ impl fmt::Display for Cond { } } } + +/// Payload of `CallInfo` for call instructions +#[derive(Clone, Debug)] +pub struct PulleyCall { + /// The external name that's being called, or the Cranelift-generated + /// function that's being invoked. + pub name: ExternalName, + /// Arguments tracked in this call invocation which aren't assigned fixed + /// registers. This tracks up to 4 registers and all remaining registers + /// will be present and tracked in `CallInfo` fields. + pub args: SmallVec<[XReg; 4]>, +} diff --git a/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs b/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs index 9140fa8fb60c..9090e3585f2e 100644 --- a/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs +++ b/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs @@ -172,16 +172,36 @@ fn pulley_emit

( Inst::LoadExtName { .. } => todo!(), Inst::Call { info } => { - sink.put1(pulley_interpreter::Opcode::Call as u8); - sink.add_reloc( + let offset = sink.cur_offset(); + + // If arguments happen to already be in the right register for the + // ABI then remove them from this list. Otherwise emit the + // appropriate `Call` instruction depending on how many arguments we + // have that aren't already in their correct register according to + // ABI conventions. + let mut args = &info.dest.args[..]; + while !args.is_empty() && args.last().copied() == XReg::new(x_reg(args.len() - 1)) { + args = &args[..args.len() - 1]; + } + match args { + [] => enc::call(sink, 0), + [x0] => enc::call1(sink, x0, 0), + [x0, x1] => enc::call2(sink, x0, x1, 0), + [x0, x1, x2] => enc::call3(sink, x0, x1, x2, 0), + [x0, x1, x2, x3] => enc::call4(sink, x0, x1, x2, x3, 0), + _ => unreachable!(), + } + let end = sink.cur_offset(); + sink.add_reloc_at_offset( + end - 4, // TODO: is it actually okay to reuse this reloc here? Reloc::X86CallPCRel4, - &info.dest, + &info.dest.name, // This addend adjusts for the difference between the start of - // the instruction and the beginning of the immediate field. - -1, + // the instruction and the beginning of the immediate offset + // field which is always the final 4 bytes of the instruction. + -i64::from(end - offset - 4), ); - sink.put4(0); if let Some(s) = state.take_stack_map() { let offset = sink.cur_offset(); sink.push_user_stack_map(state, offset, s); diff --git a/cranelift/codegen/src/isa/pulley_shared/inst/mod.rs b/cranelift/codegen/src/isa/pulley_shared/inst/mod.rs index ec95bdbe53e5..67e3bf075971 100644 --- a/cranelift/codegen/src/isa/pulley_shared/inst/mod.rs +++ b/cranelift/codegen/src/isa/pulley_shared/inst/mod.rs @@ -151,7 +151,29 @@ fn pulley_get_operands(inst: &mut Inst, collector: &mut impl OperandVisitor) { collector.reg_def(dst); } - Inst::Call { info } | Inst::IndirectCallHost { info } => { + Inst::Call { info } => { + let CallInfo { + uses, defs, dest, .. + } = &mut **info; + + // Pulley supports having the first few integer arguments in any + // register, so flag that with `reg_use` here. + let PulleyCall { args, .. } = dest; + for arg in args { + collector.reg_use(arg); + } + + // Remaining arguments (and return values) are all in fixed + // registers according to Pulley's ABI, however. + for CallArgPair { vreg, preg } in uses { + collector.reg_fixed_use(vreg, *preg); + } + for CallRetPair { vreg, preg } in defs { + collector.reg_fixed_def(vreg, *preg); + } + collector.reg_clobbers(info.clobbers); + } + Inst::IndirectCallHost { info } => { let CallInfo { uses, defs, .. } = &mut **info; for CallArgPair { vreg, preg } in uses { collector.reg_fixed_use(vreg, *preg); diff --git a/cranelift/codegen/src/isa/pulley_shared/lower.isle b/cranelift/codegen/src/isa/pulley_shared/lower.isle index 93a818ae0ada..f158bcc84877 100644 --- a/cranelift/codegen/src/isa/pulley_shared/lower.isle +++ b/cranelift/codegen/src/isa/pulley_shared/lower.isle @@ -161,13 +161,11 @@ ;;;; Rules for `f32const`;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(rule (lower (f32const (u32_from_ieee32 x))) - (pulley_fconst32 x)) +(rule (lower (f32const (u32_from_ieee32 x))) (imm $F32 x)) ;;;; Rules for `f64const`;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(rule (lower (f64const (u64_from_ieee64 x))) - (pulley_fconst64 x)) +(rule (lower (f64const (u64_from_ieee64 x))) (imm $F64 x)) ;;;; Rules for `iadd` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -223,6 +221,11 @@ (rule 1 (lower (has_type $I32X4 (iadd a b))) (pulley_vaddi32x4 a b)) (rule 1 (lower (has_type $I64X2 (iadd a b))) (pulley_vaddi64x2 a b)) +(rule 1 (lower (has_type $I8X16 (sadd_sat a b))) (pulley_vaddi8x16_sat a b)) +(rule 1 (lower (has_type $I8X16 (uadd_sat a b))) (pulley_vaddu8x16_sat a b)) +(rule 1 (lower (has_type $I16X8 (sadd_sat a b))) (pulley_vaddi16x8_sat a b)) +(rule 1 (lower (has_type $I16X8 (uadd_sat a b))) (pulley_vaddu16x8_sat a b)) + ;;;; Rules for `isub` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule 0 (lower (has_type (ty_int (fits_in_32 _)) (isub a b))) (pulley_xsub32 a b)) @@ -258,6 +261,11 @@ (rule 1 (lower (has_type $I32X4 (isub a b))) (pulley_vsubi32x4 a b)) (rule 1 (lower (has_type $I64X2 (isub a b))) (pulley_vsubi64x2 a b)) +(rule 1 (lower (has_type $I8X16 (ssub_sat a b))) (pulley_vsubi8x16_sat a b)) +(rule 1 (lower (has_type $I8X16 (usub_sat a b))) (pulley_vsubu8x16_sat a b)) +(rule 1 (lower (has_type $I16X8 (ssub_sat a b))) (pulley_vsubi16x8_sat a b)) +(rule 1 (lower (has_type $I16X8 (usub_sat a b))) (pulley_vsubu16x8_sat a b)) + ;;;; Rules for `imul` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (has_type $I8 (imul a b))) (pulley_xmul32 a b)) @@ -313,6 +321,10 @@ (rule (lower (has_type $I64 (smulhi a b))) (pulley_xmulhi64_s a b)) +;;;; Rules for `sqmul_round_sat` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(rule (lower (has_type $I16X8 (sqmul_round_sat a b))) (pulley_vqmulrsi16x8 a b)) + ;;;; Rules for `sdiv` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule 0 (lower (has_type (fits_in_32 _) (sdiv a b))) @@ -337,6 +349,11 @@ (pulley_xrem32_u (zext32 a) (zext32 b))) (rule 1 (lower (has_type $I64 (urem a b))) (pulley_xrem64_u a b)) +;;;; Rules for `avg_round` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(rule (lower (has_type $I8X16 (avg_round a b))) (pulley_vavground8x16 a b)) +(rule (lower (has_type $I16X8 (avg_round a b))) (pulley_vavground16x8 a b)) + ;;;; Rules for `ishl` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (has_type $I8 (ishl a b))) @@ -506,24 +523,36 @@ (rule 0 (lower (has_type (fits_in_32 _) (umin a b))) (pulley_xmin32_u (zext32 a) (zext32 b))) (rule 1 (lower (has_type $I64 (umin a b))) (pulley_xmin64_u a b)) +(rule 1 (lower (has_type $I8X16 (umin a b))) (pulley_vmin8x16_u a b)) +(rule 1 (lower (has_type $I16X8 (umin a b))) (pulley_vmin16x8_u a b)) +(rule 1 (lower (has_type $I32X4 (umin a b))) (pulley_vmin32x4_u a b)) ;;;; Rules for `smin` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule 0 (lower (has_type (fits_in_32 _) (smin a b))) (pulley_xmin32_s (sext32 a) (sext32 b))) (rule 1 (lower (has_type $I64 (smin a b))) (pulley_xmin64_s a b)) +(rule 1 (lower (has_type $I8X16 (smin a b))) (pulley_vmin8x16_s a b)) +(rule 1 (lower (has_type $I16X8 (smin a b))) (pulley_vmin16x8_s a b)) +(rule 1 (lower (has_type $I32X4 (smin a b))) (pulley_vmin32x4_s a b)) ;;;; Rules for `umax` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule 0 (lower (has_type (fits_in_32 _) (umax a b))) (pulley_xmax32_u (zext32 a) (zext32 b))) (rule 1 (lower (has_type $I64 (umax a b))) (pulley_xmax64_u a b)) +(rule 1 (lower (has_type $I8X16 (umax a b))) (pulley_vmax8x16_u a b)) +(rule 1 (lower (has_type $I16X8 (umax a b))) (pulley_vmax16x8_u a b)) +(rule 1 (lower (has_type $I32X4 (umax a b))) (pulley_vmax32x4_u a b)) ;;;; Rules for `smax` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule 0 (lower (has_type (fits_in_32 _) (smax a b))) (pulley_xmax32_s (sext32 a) (sext32 b))) (rule 1 (lower (has_type $I64 (smax a b))) (pulley_xmax64_s a b)) +(rule 1 (lower (has_type $I8X16 (smax a b))) (pulley_vmax8x16_s a b)) +(rule 1 (lower (has_type $I16X8 (smax a b))) (pulley_vmax16x8_s a b)) +(rule 1 (lower (has_type $I32X4 (smax a b))) (pulley_vmax32x4_s a b)) ;;;; Rules for `bmask` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -556,6 +585,7 @@ (rule 0 (lower (has_type (fits_in_32 _) (popcnt a))) (pulley_xpopcnt32 (zext32 a))) (rule 1 (lower (has_type $I64 (popcnt a))) (pulley_xpopcnt64 a)) +(rule 1 (lower (has_type $I8X16 (popcnt a))) (pulley_vpopcnt8x16 a)) ;;;; Rules for `rotl` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1133,6 +1163,7 @@ (rule (lower (has_type $F32 (fdiv a b))) (pulley_fdiv32 a b)) (rule (lower (has_type $F64 (fdiv a b))) (pulley_fdiv64 a b)) +(rule (lower (has_type $F32X4 (fdiv a b))) (pulley_vdivf32x4 a b)) ;;;; Rules for `fmax` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1152,26 +1183,44 @@ (rule (lower (has_type $F32 (trunc a))) (pulley_ftrunc32 a)) (rule (lower (has_type $F64 (trunc a))) (pulley_ftrunc64 a)) +(rule (lower (has_type $F32X4 (trunc a))) (pulley_vtrunc32x4 a)) +(rule (lower (has_type $F64X2 (trunc a))) (pulley_vtrunc64x2 a)) ;;;; Rules for `floor` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (has_type $F32 (floor a))) (pulley_ffloor32 a)) (rule (lower (has_type $F64 (floor a))) (pulley_ffloor64 a)) - +(rule (lower (has_type $F32X4 (floor a))) + (pulley_vfloor32x4 a)) +(rule (lower (has_type $F64X2 (floor a))) + (pulley_vfloor64x2 a)) ;;;; Rules for `ceil` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (has_type $F32 (ceil a))) (pulley_fceil32 a)) (rule (lower (has_type $F64 (ceil a))) (pulley_fceil64 a)) +(rule (lower (has_type $F64X2 (ceil a))) + (pulley_vceil64x2 a)) +(rule (lower (has_type $F32X4 (ceil a))) + (pulley_vceil32x4 a)) ;;;; Rules for `nearest` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (has_type $F32 (nearest a))) (pulley_fnearest32 a)) (rule (lower (has_type $F64 (nearest a))) (pulley_fnearest64 a)) +(rule (lower (has_type $F32X4 (nearest a))) + (pulley_vnearest32x4 a)) +(rule (lower (has_type $F64X2 (nearest a))) + (pulley_vnearest64x2 a)) ;;;; Rules for `sqrt` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (has_type $F32 (sqrt a))) (pulley_fsqrt32 a)) (rule (lower (has_type $F64 (sqrt a))) (pulley_fsqrt64 a)) +(rule (lower (has_type $F32X4 (sqrt a))) + (pulley_vsqrt32x4 a)) +(rule (lower (has_type $F64X2 (sqrt a))) + (pulley_vsqrt64x2 a)) + ;;;; Rules for `fneg` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1213,6 +1262,10 @@ (rule 0 (lower (has_type (fits_in_32 _) (iabs a))) (pulley_xabs32 (sext32 a))) (rule 1 (lower (has_type $I64 (iabs a))) (pulley_xabs64 a)) +(rule 1 (lower (has_type $I8X16 (iabs a))) (pulley_vabs8x16 a)) +(rule 1 (lower (has_type $I16X8 (iabs a))) (pulley_vabs16x8 a)) +(rule 1 (lower (has_type $I32X4 (iabs a))) (pulley_vabs32x4 a)) +(rule 1 (lower (has_type $I64X2 (iabs a))) (pulley_vabs64x2 a)) ;;;; Rules for `splat` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1342,3 +1395,8 @@ (pulley_vinsertf32 (pulley_vconst128 0) a 0)) (rule (lower (scalar_to_vector a @ (value_type $F64))) (pulley_vinsertf64 (pulley_vconst128 0) a 0)) + + +;;;; Rules for `swizzle` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(rule 1 (lower (has_type $I8X16 (swizzle a b))) (pulley_vswizzlei8x16 a b)) diff --git a/cranelift/codegen/src/isa/pulley_shared/lower/isle.rs b/cranelift/codegen/src/isa/pulley_shared/lower/isle.rs index ed77a698b0f7..f344d33436df 100644 --- a/cranelift/codegen/src/isa/pulley_shared/lower/isle.rs +++ b/cranelift/codegen/src/isa/pulley_shared/lower/isle.rs @@ -10,7 +10,8 @@ use crate::ir::{condcodes::*, immediates::*, types::*, *}; use crate::isa::pulley_shared::{ abi::*, inst::{ - FReg, OperandSize, ReturnCallInfo, VReg, WritableFReg, WritableVReg, WritableXReg, XReg, + FReg, OperandSize, PulleyCall, ReturnCallInfo, VReg, WritableFReg, WritableVReg, + WritableXReg, XReg, }, lower::{regs, Cond}, *, @@ -26,8 +27,9 @@ use regalloc2::PReg; type Unit = (); type VecArgPair = Vec; type VecRetPair = Vec; -type BoxCallInfo = Box>; +type BoxCallInfo = Box>; type BoxCallIndInfo = Box>; +type BoxCallIndirectHostInfo = Box>; type BoxReturnCallInfo = Box>; type BoxReturnCallIndInfo = Box>; type BoxExternalName = Box; diff --git a/cranelift/codegen/src/isa/riscv64/abi.rs b/cranelift/codegen/src/isa/riscv64/abi.rs index 05e936a5e1a4..6098769c017e 100644 --- a/cranelift/codegen/src/isa/riscv64/abi.rs +++ b/cranelift/codegen/src/isa/riscv64/abi.rs @@ -634,7 +634,7 @@ impl ABIMachineSpec for Riscv64MachineDeps { fn get_machine_env(_flags: &settings::Flags, _call_conv: isa::CallConv) -> &MachineEnv { static MACHINE_ENV: OnceLock = OnceLock::new(); - MACHINE_ENV.get_or_init(create_reg_enviroment) + MACHINE_ENV.get_or_init(create_reg_environment) } fn get_regs_clobbered_by_call(_call_conv_of_callee: isa::CallConv) -> PRegSet { @@ -894,7 +894,7 @@ const DEFAULT_CLOBBERS: PRegSet = PRegSet::empty() .with(pv_reg(30)) .with(pv_reg(31)); -fn create_reg_enviroment() -> MachineEnv { +fn create_reg_environment() -> MachineEnv { // Some C Extension instructions can only use a subset of the registers. // x8 - x15, f8 - f15, v8 - v15 so we should prefer to use those since // they allow us to emit C instructions more often. diff --git a/cranelift/codegen/src/isa/riscv64/inst/args.rs b/cranelift/codegen/src/isa/riscv64/inst/args.rs index 1d54496785d5..6c973b068590 100644 --- a/cranelift/codegen/src/isa/riscv64/inst/args.rs +++ b/cranelift/codegen/src/isa/riscv64/inst/args.rs @@ -1546,7 +1546,7 @@ impl AtomicOP { pub enum AMO { Relax = 0b00, Release = 0b01, - Aquire = 0b10, + Acquire = 0b10, SeqCst = 0b11, } @@ -1555,7 +1555,7 @@ impl AMO { match self { AMO::Relax => "", AMO::Release => ".rl", - AMO::Aquire => ".aq", + AMO::Acquire => ".aq", AMO::SeqCst => ".aqrl", } } diff --git a/cranelift/codegen/src/isa/riscv64/inst/emit_tests.rs b/cranelift/codegen/src/isa/riscv64/inst/emit_tests.rs index 4899109f3eb2..6f1b2d7df5e5 100644 --- a/cranelift/codegen/src/isa/riscv64/inst/emit_tests.rs +++ b/cranelift/codegen/src/isa/riscv64/inst/emit_tests.rs @@ -1860,7 +1860,7 @@ fn test_riscv64_binemit() { rd: writable_a0(), addr: a1(), src: a2(), - amo: AMO::Aquire, + amo: AMO::Acquire, }, "amoswap.w.aq a0,a2,(a1)", 0xcc5a52f, diff --git a/cranelift/codegen/src/isa/s390x/inst/emit.rs b/cranelift/codegen/src/isa/s390x/inst/emit.rs index 24bd4cb0fcfc..53d383ea535a 100644 --- a/cranelift/codegen/src/isa/s390x/inst/emit.rs +++ b/cranelift/codegen/src/isa/s390x/inst/emit.rs @@ -220,7 +220,13 @@ pub fn mem_emit( &MemArg::Symbol { ref name, offset, .. } => { - sink.add_reloc_at_offset(2, Reloc::S390xPCRel32Dbl, &**name, (offset + 2).into()); + let reloc_offset = sink.cur_offset() + 2; + sink.add_reloc_at_offset( + reloc_offset, + Reloc::S390xPCRel32Dbl, + &**name, + (offset + 2).into(), + ); put(sink, &enc_ril_b(opcode_ril.unwrap(), rd, 0)); } _ => unreachable!(), @@ -3198,7 +3204,8 @@ impl Inst { // Add relocation for target function. This has to be done *before* // the S390xTlsGdCall relocation if any, to ensure linker relaxation // works correctly. - sink.add_reloc_at_offset(2, Reloc::S390xPLTRel32Dbl, &info.dest, 2); + let offset = sink.cur_offset() + 2; + sink.add_reloc_at_offset(offset, Reloc::S390xPLTRel32Dbl, &info.dest, 2); if let Some(s) = state.take_stack_map() { let offset = sink.cur_offset() + 6; @@ -3232,7 +3239,8 @@ impl Inst { } let opcode = 0xc04; // BCRL - sink.add_reloc_at_offset(2, Reloc::S390xPLTRel32Dbl, &info.dest, 2); + let offset = sink.cur_offset() + 2; + sink.add_reloc_at_offset(offset, Reloc::S390xPLTRel32Dbl, &info.dest, 2); put(sink, &enc_ril_c(opcode, 15, 0)); sink.add_call_site(); } @@ -3257,7 +3265,8 @@ impl Inst { // *before* the S390xTlsGdCall, to ensure linker relaxation // works correctly. let dest = ExternalName::LibCall(LibCall::ElfTlsGetOffset); - sink.add_reloc_at_offset(2, Reloc::S390xPLTRel32Dbl, &dest, 2); + let offset = sink.cur_offset() + 2; + sink.add_reloc_at_offset(offset, Reloc::S390xPLTRel32Dbl, &dest, 2); match &**symbol { SymbolReloc::TlsGd { name } => sink.add_reloc(Reloc::S390xTlsGdCall, name, 0), _ => unreachable!(), diff --git a/cranelift/codegen/src/isa/x64/inst.isle b/cranelift/codegen/src/isa/x64/inst.isle index f90eb02744ae..24c4fe99a6ad 100644 --- a/cranelift/codegen/src/isa/x64/inst.isle +++ b/cranelift/codegen/src/isa/x64/inst.isle @@ -237,7 +237,7 @@ (src1 Gpr) (src2 GprMemImm)) - ;; Materializes the requested condition code in the destinaton reg. + ;; Materializes the requested condition code in the destination reg. (Setcc (cc CC) (dst WritableGpr)) @@ -2221,7 +2221,7 @@ (_ Unit (emit (MInst.XmmToGprVex op src dst size)))) dst)) -;; Helper for creating `xmm_min_max_seq` psuedo-instructions. +;; Helper for creating `xmm_min_max_seq` pseudo-instructions. (decl xmm_min_max_seq (Type bool Xmm Xmm) Xmm) (rule (xmm_min_max_seq ty is_min lhs rhs) (let ((dst WritableXmm (temp_writable_xmm)) diff --git a/cranelift/codegen/src/machinst/buffer.rs b/cranelift/codegen/src/machinst/buffer.rs index 93c11658e34a..518b4cdbe389 100644 --- a/cranelift/codegen/src/machinst/buffer.rs +++ b/cranelift/codegen/src/machinst/buffer.rs @@ -1536,7 +1536,7 @@ impl MachBuffer { } } - /// Add an external relocation at the given offset from current offset. + /// Add an external relocation at the given offset. pub fn add_reloc_at_offset + Clone>( &mut self, offset: CodeOffset, @@ -1579,7 +1579,7 @@ impl MachBuffer { // when a relocation can't otherwise be resolved later, so it shouldn't // actually result in any memory unsafety or anything like that. self.relocs.push(MachReloc { - offset: self.data.len() as CodeOffset + offset, + offset, kind, target, addend, @@ -1593,7 +1593,7 @@ impl MachBuffer { target: &T, addend: Addend, ) { - self.add_reloc_at_offset(0, kind, target, addend); + self.add_reloc_at_offset(self.data.len() as CodeOffset, kind, target, addend); } /// Add a trap record at the current offset. diff --git a/cranelift/filetests/filetests/isa/pulley32/call.clif b/cranelift/filetests/filetests/isa/pulley32/call.clif index 6c8a95bce988..d2d9a29f232c 100644 --- a/cranelift/filetests/filetests/isa/pulley32/call.clif +++ b/cranelift/filetests/filetests/isa/pulley32/call.clif @@ -15,16 +15,16 @@ block0: ; VCode: ; push_frame ; block0: -; xconst8 x0, 0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }], clobbers: PRegSet { bits: [65534, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; xconst8 x2, 0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }], clobbers: PRegSet { bits: [65534, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; xconst8 x0, 1 ; pop_frame ; ret ; ; Disassembled: ; push_frame -; xconst8 x0, 0 -; call 0x0 // target = 0x4 +; xconst8 x2, 0 +; call1 x2, 0x0 // target = 0x4 ; xconst8 x0, 1 ; pop_frame ; ret @@ -42,16 +42,16 @@ block0: ; VCode: ; push_frame ; block0: -; xconst8 x0, 0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }], clobbers: PRegSet { bits: [65534, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; xconst8 x2, 0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }], clobbers: PRegSet { bits: [65534, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; xconst8 x0, 1 ; pop_frame ; ret ; ; Disassembled: ; push_frame -; xconst8 x0, 0 -; call 0x0 // target = 0x4 +; xconst8 x2, 0 +; call1 x2, 0x0 // target = 0x4 ; xconst8 x0, 1 ; pop_frame ; ret @@ -71,21 +71,21 @@ block0: ; VCode: ; push_frame ; block0: -; xconst8 x0, 0 -; xconst8 x1, 1 -; xconst8 x2, 2 -; xconst8 x3, 3 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; xconst8 x3, 0 +; xconst8 x4, 1 +; xconst8 x5, 2 +; xconst8 x6, 3 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p3i), XReg(p4i), XReg(p5i), XReg(p6i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; xconst8 x0, 0 -; xconst8 x1, 1 -; xconst8 x2, 2 -; xconst8 x3, 3 -; call 0x0 // target = 0xd +; xconst8 x3, 0 +; xconst8 x4, 1 +; xconst8 x5, 2 +; xconst8 x6, 3 +; call4 x3, x4, x5, x6, 0x0 // target = 0xd ; pop_frame ; ret @@ -103,7 +103,7 @@ block0: ; VCode: ; push_frame ; block0: -; call CallInfo { dest: TestCase(%g), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }, CallRetPair { vreg: Writable { reg: p1i }, preg: p1i }, CallRetPair { vreg: Writable { reg: p2i }, preg: p2i }, CallRetPair { vreg: Writable { reg: p3i }, preg: p3i }], clobbers: PRegSet { bits: [65520, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }, CallRetPair { vreg: Writable { reg: p1i }, preg: p1i }, CallRetPair { vreg: Writable { reg: p2i }, preg: p2i }, CallRetPair { vreg: Writable { reg: p3i }, preg: p3i }], clobbers: PRegSet { bits: [65520, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; xadd64 x4, x0, x2 ; xadd64 x3, x1, x3 ; xadd64 x0, x4, x3 @@ -138,10 +138,6 @@ block0: ; xstore64 OutgoingArg(24), x15 // flags = notrap aligned ; xstore64 OutgoingArg(32), x15 // flags = notrap aligned ; xstore64 OutgoingArg(40), x15 // flags = notrap aligned -; xmov x0, x15 -; xmov x1, x15 -; xmov x2, x15 -; xmov x3, x15 ; xmov x4, x15 ; xmov x5, x15 ; xmov x6, x15 @@ -153,7 +149,7 @@ block0: ; xmov x12, x15 ; xmov x13, x15 ; xmov x14, x15 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }, CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }, CallArgPair { vreg: p15i, preg: p15i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p15i), XReg(p15i), XReg(p15i), XReg(p15i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }, CallArgPair { vreg: p15i, preg: p15i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame_restore 48, {} ; ret ; @@ -166,10 +162,6 @@ block0: ; xstore64le_offset8 sp, 24, x15 ; xstore64le_offset8 sp, 32, x15 ; xstore64le_offset8 sp, 40, x15 -; xmov x0, x15 -; xmov x1, x15 -; xmov x2, x15 -; xmov x3, x15 ; xmov x4, x15 ; xmov x5, x15 ; xmov x6, x15 @@ -181,7 +173,7 @@ block0: ; xmov x12, x15 ; xmov x13, x15 ; xmov x14, x15 -; call 0x0 // target = 0x51 +; call4 x15, x15, x15, x15, 0x0 // target = 0x45 ; pop_frame_restore 48, ; ret @@ -224,8 +216,8 @@ block0: ; VCode: ; push_frame_save 112, {x17, x18, x20, x21, x22, x23, x29} ; block0: -; x0 = load_addr OutgoingArg(0) -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }, CallRetPair { vreg: Writable { reg: p1i }, preg: p1i }, CallRetPair { vreg: Writable { reg: p2i }, preg: p2i }, CallRetPair { vreg: Writable { reg: p3i }, preg: p3i }, CallRetPair { vreg: Writable { reg: p4i }, preg: p4i }, CallRetPair { vreg: Writable { reg: p5i }, preg: p5i }, CallRetPair { vreg: Writable { reg: p6i }, preg: p6i }, CallRetPair { vreg: Writable { reg: p7i }, preg: p7i }, CallRetPair { vreg: Writable { reg: p8i }, preg: p8i }, CallRetPair { vreg: Writable { reg: p9i }, preg: p9i }, CallRetPair { vreg: Writable { reg: p10i }, preg: p10i }, CallRetPair { vreg: Writable { reg: p11i }, preg: p11i }, CallRetPair { vreg: Writable { reg: p12i }, preg: p12i }, CallRetPair { vreg: Writable { reg: p13i }, preg: p13i }, CallRetPair { vreg: Writable { reg: p14i }, preg: p14i }, CallRetPair { vreg: Writable { reg: p15i }, preg: p15i }], clobbers: PRegSet { bits: [0, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; x12 = load_addr OutgoingArg(0) +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p12i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }, CallRetPair { vreg: Writable { reg: p1i }, preg: p1i }, CallRetPair { vreg: Writable { reg: p2i }, preg: p2i }, CallRetPair { vreg: Writable { reg: p3i }, preg: p3i }, CallRetPair { vreg: Writable { reg: p4i }, preg: p4i }, CallRetPair { vreg: Writable { reg: p5i }, preg: p5i }, CallRetPair { vreg: Writable { reg: p6i }, preg: p6i }, CallRetPair { vreg: Writable { reg: p7i }, preg: p7i }, CallRetPair { vreg: Writable { reg: p8i }, preg: p8i }, CallRetPair { vreg: Writable { reg: p9i }, preg: p9i }, CallRetPair { vreg: Writable { reg: p10i }, preg: p10i }, CallRetPair { vreg: Writable { reg: p11i }, preg: p11i }, CallRetPair { vreg: Writable { reg: p12i }, preg: p12i }, CallRetPair { vreg: Writable { reg: p13i }, preg: p13i }, CallRetPair { vreg: Writable { reg: p14i }, preg: p14i }, CallRetPair { vreg: Writable { reg: p15i }, preg: p15i }], clobbers: PRegSet { bits: [0, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; xmov x20, x13 ; xmov x22, x11 ; x29 = xload64 OutgoingArg(0) // flags = notrap aligned @@ -263,8 +255,8 @@ block0: ; ; Disassembled: ; push_frame_save 112, x17, x18, x20, x21, x22, x23, x29 -; xmov x0, sp -; call 0x0 // target = 0xc +; xmov x12, sp +; call1 x12, 0x0 // target = 0xc ; xmov x20, x13 ; xmov x22, x11 ; xload64le_offset8 x29, sp, 0 diff --git a/cranelift/filetests/filetests/isa/pulley32/extend.clif b/cranelift/filetests/filetests/isa/pulley32/extend.clif index 4af13e4b19c8..d82485e18853 100644 --- a/cranelift/filetests/filetests/isa/pulley32/extend.clif +++ b/cranelift/filetests/filetests/isa/pulley32/extend.clif @@ -11,15 +11,15 @@ block0(v0: i8): ; VCode: ; push_frame ; block0: -; zext8 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; zext8 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; zext8 x0, x0 -; call 0x0 // target = 0x4 +; zext8 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -33,15 +33,15 @@ block0(v0: i16): ; VCode: ; push_frame ; block0: -; zext16 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; zext16 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; zext16 x0, x0 -; call 0x0 // target = 0x4 +; zext16 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -55,7 +55,7 @@ block0(v0: i32): ; VCode: ; push_frame ; block0: -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; @@ -75,7 +75,7 @@ block0(v0: i64): ; VCode: ; push_frame ; block0: -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; @@ -95,15 +95,15 @@ block0(v0: i8): ; VCode: ; push_frame ; block0: -; sext8 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; sext8 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; sext8 x0, x0 -; call 0x0 // target = 0x4 +; sext8 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -117,15 +117,15 @@ block0(v0: i16): ; VCode: ; push_frame ; block0: -; sext16 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; sext16 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; sext16 x0, x0 -; call 0x0 // target = 0x4 +; sext16 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -139,7 +139,7 @@ block0(v0: i32): ; VCode: ; push_frame ; block0: -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; @@ -159,7 +159,7 @@ block0(v0: i64): ; VCode: ; push_frame ; block0: -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; diff --git a/cranelift/filetests/filetests/isa/pulley64/call.clif b/cranelift/filetests/filetests/isa/pulley64/call.clif index 711216049cdd..e00fd590985e 100644 --- a/cranelift/filetests/filetests/isa/pulley64/call.clif +++ b/cranelift/filetests/filetests/isa/pulley64/call.clif @@ -15,16 +15,16 @@ block0: ; VCode: ; push_frame ; block0: -; xconst8 x0, 0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }], clobbers: PRegSet { bits: [65534, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; xconst8 x2, 0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }], clobbers: PRegSet { bits: [65534, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; xconst8 x0, 1 ; pop_frame ; ret ; ; Disassembled: ; push_frame -; xconst8 x0, 0 -; call 0x0 // target = 0x4 +; xconst8 x2, 0 +; call1 x2, 0x0 // target = 0x4 ; xconst8 x0, 1 ; pop_frame ; ret @@ -42,16 +42,16 @@ block0: ; VCode: ; push_frame ; block0: -; xconst8 x0, 0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }], clobbers: PRegSet { bits: [65534, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; xconst8 x2, 0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }], clobbers: PRegSet { bits: [65534, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; xconst8 x0, 1 ; pop_frame ; ret ; ; Disassembled: ; push_frame -; xconst8 x0, 0 -; call 0x0 // target = 0x4 +; xconst8 x2, 0 +; call1 x2, 0x0 // target = 0x4 ; xconst8 x0, 1 ; pop_frame ; ret @@ -71,21 +71,21 @@ block0: ; VCode: ; push_frame ; block0: -; xconst8 x0, 0 -; xconst8 x1, 1 -; xconst8 x2, 2 -; xconst8 x3, 3 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; xconst8 x3, 0 +; xconst8 x4, 1 +; xconst8 x5, 2 +; xconst8 x6, 3 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p3i), XReg(p4i), XReg(p5i), XReg(p6i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; xconst8 x0, 0 -; xconst8 x1, 1 -; xconst8 x2, 2 -; xconst8 x3, 3 -; call 0x0 // target = 0xd +; xconst8 x3, 0 +; xconst8 x4, 1 +; xconst8 x5, 2 +; xconst8 x6, 3 +; call4 x3, x4, x5, x6, 0x0 // target = 0xd ; pop_frame ; ret @@ -103,7 +103,7 @@ block0: ; VCode: ; push_frame ; block0: -; call CallInfo { dest: TestCase(%g), uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }, CallRetPair { vreg: Writable { reg: p1i }, preg: p1i }, CallRetPair { vreg: Writable { reg: p2i }, preg: p2i }, CallRetPair { vreg: Writable { reg: p3i }, preg: p3i }], clobbers: PRegSet { bits: [65520, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }, CallRetPair { vreg: Writable { reg: p1i }, preg: p1i }, CallRetPair { vreg: Writable { reg: p2i }, preg: p2i }, CallRetPair { vreg: Writable { reg: p3i }, preg: p3i }], clobbers: PRegSet { bits: [65520, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; xadd64 x4, x0, x2 ; xadd64 x3, x1, x3 ; xadd64 x0, x4, x3 @@ -138,10 +138,6 @@ block0: ; xstore64 OutgoingArg(24), x15 // flags = notrap aligned ; xstore64 OutgoingArg(32), x15 // flags = notrap aligned ; xstore64 OutgoingArg(40), x15 // flags = notrap aligned -; xmov x0, x15 -; xmov x1, x15 -; xmov x2, x15 -; xmov x3, x15 ; xmov x4, x15 ; xmov x5, x15 ; xmov x6, x15 @@ -153,7 +149,7 @@ block0: ; xmov x12, x15 ; xmov x13, x15 ; xmov x14, x15 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }, CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }, CallArgPair { vreg: p15i, preg: p15i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p15i), XReg(p15i), XReg(p15i), XReg(p15i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }, CallArgPair { vreg: p15i, preg: p15i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame_restore 48, {} ; ret ; @@ -166,10 +162,6 @@ block0: ; xstore64le_offset8 sp, 24, x15 ; xstore64le_offset8 sp, 32, x15 ; xstore64le_offset8 sp, 40, x15 -; xmov x0, x15 -; xmov x1, x15 -; xmov x2, x15 -; xmov x3, x15 ; xmov x4, x15 ; xmov x5, x15 ; xmov x6, x15 @@ -181,7 +173,7 @@ block0: ; xmov x12, x15 ; xmov x13, x15 ; xmov x14, x15 -; call 0x0 // target = 0x51 +; call4 x15, x15, x15, x15, 0x0 // target = 0x45 ; pop_frame_restore 48, ; ret @@ -224,8 +216,8 @@ block0: ; VCode: ; push_frame_save 112, {x17, x18, x20, x21, x22, x23, x29} ; block0: -; x0 = load_addr OutgoingArg(0) -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }, CallRetPair { vreg: Writable { reg: p1i }, preg: p1i }, CallRetPair { vreg: Writable { reg: p2i }, preg: p2i }, CallRetPair { vreg: Writable { reg: p3i }, preg: p3i }, CallRetPair { vreg: Writable { reg: p4i }, preg: p4i }, CallRetPair { vreg: Writable { reg: p5i }, preg: p5i }, CallRetPair { vreg: Writable { reg: p6i }, preg: p6i }, CallRetPair { vreg: Writable { reg: p7i }, preg: p7i }, CallRetPair { vreg: Writable { reg: p8i }, preg: p8i }, CallRetPair { vreg: Writable { reg: p9i }, preg: p9i }, CallRetPair { vreg: Writable { reg: p10i }, preg: p10i }, CallRetPair { vreg: Writable { reg: p11i }, preg: p11i }, CallRetPair { vreg: Writable { reg: p12i }, preg: p12i }, CallRetPair { vreg: Writable { reg: p13i }, preg: p13i }, CallRetPair { vreg: Writable { reg: p14i }, preg: p14i }, CallRetPair { vreg: Writable { reg: p15i }, preg: p15i }], clobbers: PRegSet { bits: [0, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; x12 = load_addr OutgoingArg(0) +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p12i)] }, uses: [], defs: [CallRetPair { vreg: Writable { reg: p0i }, preg: p0i }, CallRetPair { vreg: Writable { reg: p1i }, preg: p1i }, CallRetPair { vreg: Writable { reg: p2i }, preg: p2i }, CallRetPair { vreg: Writable { reg: p3i }, preg: p3i }, CallRetPair { vreg: Writable { reg: p4i }, preg: p4i }, CallRetPair { vreg: Writable { reg: p5i }, preg: p5i }, CallRetPair { vreg: Writable { reg: p6i }, preg: p6i }, CallRetPair { vreg: Writable { reg: p7i }, preg: p7i }, CallRetPair { vreg: Writable { reg: p8i }, preg: p8i }, CallRetPair { vreg: Writable { reg: p9i }, preg: p9i }, CallRetPair { vreg: Writable { reg: p10i }, preg: p10i }, CallRetPair { vreg: Writable { reg: p11i }, preg: p11i }, CallRetPair { vreg: Writable { reg: p12i }, preg: p12i }, CallRetPair { vreg: Writable { reg: p13i }, preg: p13i }, CallRetPair { vreg: Writable { reg: p14i }, preg: p14i }, CallRetPair { vreg: Writable { reg: p15i }, preg: p15i }], clobbers: PRegSet { bits: [0, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; xmov x20, x13 ; xmov x22, x11 ; x29 = xload64 OutgoingArg(0) // flags = notrap aligned @@ -263,8 +255,8 @@ block0: ; ; Disassembled: ; push_frame_save 112, x17, x18, x20, x21, x22, x23, x29 -; xmov x0, sp -; call 0x0 // target = 0xc +; xmov x12, sp +; call1 x12, 0x0 // target = 0xc ; xmov x20, x13 ; xmov x22, x11 ; xload64le_offset8 x29, sp, 0 @@ -350,10 +342,6 @@ block0: ; xstore64 OutgoingArg(40), x15 // flags = notrap aligned ; xstore64 OutgoingArg(48), x15 // flags = notrap aligned ; xstore64 OutgoingArg(56), x15 // flags = notrap aligned -; xmov x0, x15 -; xmov x1, x15 -; xmov x2, x15 -; xmov x3, x15 ; xmov x4, x15 ; xmov x5, x15 ; xmov x6, x15 @@ -365,7 +353,7 @@ block0: ; xmov x12, x15 ; xmov x13, x15 ; xmov x14, x15 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }, CallArgPair { vreg: p1i, preg: p1i }, CallArgPair { vreg: p2i, preg: p2i }, CallArgPair { vreg: p3i, preg: p3i }, CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }, CallArgPair { vreg: p15i, preg: p15i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p15i), XReg(p15i), XReg(p15i), XReg(p15i)] }, uses: [CallArgPair { vreg: p4i, preg: p4i }, CallArgPair { vreg: p5i, preg: p5i }, CallArgPair { vreg: p6i, preg: p6i }, CallArgPair { vreg: p7i, preg: p7i }, CallArgPair { vreg: p8i, preg: p8i }, CallArgPair { vreg: p9i, preg: p9i }, CallArgPair { vreg: p10i, preg: p10i }, CallArgPair { vreg: p11i, preg: p11i }, CallArgPair { vreg: p12i, preg: p12i }, CallArgPair { vreg: p13i, preg: p13i }, CallArgPair { vreg: p14i, preg: p14i }, CallArgPair { vreg: p15i, preg: p15i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame_restore 64, {} ; ret ; @@ -380,10 +368,6 @@ block0: ; xstore64le_offset8 sp, 40, x15 ; xstore64le_offset8 sp, 48, x15 ; xstore64le_offset8 sp, 56, x15 -; xmov x0, x15 -; xmov x1, x15 -; xmov x2, x15 -; xmov x3, x15 ; xmov x4, x15 ; xmov x5, x15 ; xmov x6, x15 @@ -395,7 +379,7 @@ block0: ; xmov x12, x15 ; xmov x13, x15 ; xmov x14, x15 -; call 0x0 // target = 0x59 +; call4 x15, x15, x15, x15, 0x0 // target = 0x4d ; pop_frame_restore 64, ; ret diff --git a/cranelift/filetests/filetests/isa/pulley64/extend.clif b/cranelift/filetests/filetests/isa/pulley64/extend.clif index 22b0e46dbf22..0efbfb6a9a5a 100644 --- a/cranelift/filetests/filetests/isa/pulley64/extend.clif +++ b/cranelift/filetests/filetests/isa/pulley64/extend.clif @@ -11,15 +11,15 @@ block0(v0: i8): ; VCode: ; push_frame ; block0: -; zext8 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; zext8 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; zext8 x0, x0 -; call 0x0 // target = 0x4 +; zext8 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -33,15 +33,15 @@ block0(v0: i16): ; VCode: ; push_frame ; block0: -; zext16 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; zext16 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; zext16 x0, x0 -; call 0x0 // target = 0x4 +; zext16 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -55,15 +55,15 @@ block0(v0: i32): ; VCode: ; push_frame ; block0: -; zext32 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; zext32 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; zext32 x0, x0 -; call 0x0 // target = 0x4 +; zext32 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -77,7 +77,7 @@ block0(v0: i64): ; VCode: ; push_frame ; block0: -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; @@ -97,15 +97,15 @@ block0(v0: i8): ; VCode: ; push_frame ; block0: -; sext8 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; sext8 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; sext8 x0, x0 -; call 0x0 // target = 0x4 +; sext8 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -119,15 +119,15 @@ block0(v0: i16): ; VCode: ; push_frame ; block0: -; sext16 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; sext16 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; sext16 x0, x0 -; call 0x0 // target = 0x4 +; sext16 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -141,15 +141,15 @@ block0(v0: i32): ; VCode: ; push_frame ; block0: -; sext32 x0, x0 -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; sext32 x2, x0 +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p2i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; ; Disassembled: ; push_frame -; sext32 x0, x0 -; call 0x0 // target = 0x4 +; sext32 x2, x0 +; call1 x2, 0x0 // target = 0x4 ; pop_frame ; ret @@ -163,7 +163,7 @@ block0(v0: i64): ; VCode: ; push_frame ; block0: -; call CallInfo { dest: TestCase(%g), uses: [CallArgPair { vreg: p0i, preg: p0i }], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } +; call CallInfo { dest: PulleyCall { name: TestCase(%g), args: [XReg(p0i)] }, uses: [], defs: [], clobbers: PRegSet { bits: [65535, 65535, 4294967295, 0] }, callee_conv: Fast, caller_conv: Fast, callee_pop_size: 0 } ; pop_frame ; ret ; diff --git a/cranelift/isle/docs/language-reference.md b/cranelift/isle/docs/language-reference.md index 1993210dc9cb..e64d8598789c 100644 --- a/cranelift/isle/docs/language-reference.md +++ b/cranelift/isle/docs/language-reference.md @@ -905,7 +905,7 @@ This also works in the extractor position: for example, if one writes ```lisp (decl defining_instruction (Inst) Value) - (extern extractor definining_instruction ...) + (extern extractor defining_instruction ...) (decl iadd (Value Value) Inst) @@ -1446,8 +1446,8 @@ The grammar accepted by the parser is as follows: ::= | ::= ";" * ( | eof) - ::= "\n" | "\r" ::= + ::= "\n" | "\r" ::= "(;" * ";)" ::= @@ -1461,42 +1461,40 @@ The grammar accepted by the parser is as follows: | "(" "type" ")" | "(" "decl" ")" | "(" "rule" ")" - | "(" "extractor" ")" + | "(" "extractor" ")" | "(" "extern" ")" | "(" "convert" ")" -// No pragmas are defined yet +;; No pragmas are defined yet ::= - ::= [ "extern" | "nodebug" ] + ::= [ "extern" | "nodebug" ] ::= * ::= "$" * - ::= ::= - ::= [ "-" ] ( "0".."9" | "_" )+ - | [ "-" ] "0x" ( "0".."9" | "A".."F" | "a".."f" | "_" )+ - | [ "-" ] "0o" ( "0".."7" | "_" )+ - | [ "-" ] "0b" ( "0".."1" | "_" )+ - - ::= "(" "primitive" ")" - | "(" "enum" * ")" + ::= "(" "primitive" ")" + | "(" "enum" * ")" - ::= - | "(" * ")" + ::= + | "(" * ")" - ::= "(" ")" + ::= "(" ")" ::= ::= [ "pure" ] [ "multi" ] [ "partial" ] "(" * ")" ::= [ ] [ ] * + ::= - ::= "(" * ")" + ::= [ "-" ] ( "0".."9" | "_" )+ + | [ "-" ] "0" ("x" | "X") ( "0".."9" | "A".."F" | "a".."f" | "_" )+ + | [ "-" ] "0" ("o" | "O") ( "0".."7" | "_" )+ + | [ "-" ] "0" ("b" | "B") ( "0".."1" | "_" )+ ::= | "true" | "false" @@ -1505,10 +1503,7 @@ The grammar accepted by the parser is as follows: | | "@" | "(" "and" * ")" - | "(" * ")" - - ::= - | "<" ;; in-argument to an extractor + | "(" * ")" ::= "(" "if-let" ")" | "(" "if" ")" @@ -1522,6 +1517,8 @@ The grammar accepted by the parser is as follows: ::= "(" ")" + ::= "(" * ")" + ::= "constructor" | "extractor" [ "infallible" ] | "const" diff --git a/cranelift/isle/veri/veri_ir/src/annotation_ir.rs b/cranelift/isle/veri/veri_ir/src/annotation_ir.rs index e3362a1fcdd6..44e0652efa9b 100644 --- a/cranelift/isle/veri/veri_ir/src/annotation_ir.rs +++ b/cranelift/isle/veri/veri_ir/src/annotation_ir.rs @@ -88,7 +88,7 @@ pub enum Type { BitVectorWithWidth(usize), // Use if the width is unknown after inference, indexed by a - // cannonical type variable + // canonical type variable BitVectorUnknown(u32), /// The expression is an integer (currently used for ISLE type, diff --git a/crates/bench-api/Cargo.toml b/crates/bench-api/Cargo.toml index cc306e45ce0b..a171b0beedd8 100644 --- a/crates/bench-api/Cargo.toml +++ b/crates/bench-api/Cargo.toml @@ -22,7 +22,7 @@ doctest = false anyhow = { workspace = true } shuffling-allocator = { version = "1.1.1", optional = true } target-lexicon = { workspace = true } -wasmtime = { workspace = true, default-features = true, features = ["winch"] } +wasmtime = { workspace = true, default-features = true, features = ["winch", "pulley"] } wasmtime-cli-flags = { workspace = true, default-features = true, features = [ "cranelift", ] } diff --git a/crates/bench-api/src/lib.rs b/crates/bench-api/src/lib.rs index bedcca3f402b..13a1fd2b35b4 100644 --- a/crates/bench-api/src/lib.rs +++ b/crates/bench-api/src/lib.rs @@ -484,10 +484,7 @@ impl BenchState { } fn compile(&mut self, bytes: &[u8]) -> Result<()> { - assert!( - self.module.is_none(), - "create a new engine to repeat compilation" - ); + self.module = None; (self.compilation_start)(self.compilation_timer); let module = Module::from_binary(self.linker.engine(), bytes)?; @@ -498,6 +495,8 @@ impl BenchState { } fn instantiate(&mut self) -> Result<()> { + self.store_and_instance = None; + let module = self .module .as_ref() diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.toml index d79ba3102396..46392ce30a9a 100644 --- a/crates/c-api/Cargo.toml +++ b/crates/c-api/Cargo.toml @@ -71,5 +71,6 @@ wasmfx_pooling_allocator = [ # Enable the old-style unsafe malloc'd stacks unsafe_wasmfx_stacks = ["wasmtime/unsafe_wasmfx_stacks"] +debug-builtins = ['wasmtime/debug-builtins'] # ... if you add a line above this be sure to change the other locations # marked WASMTIME_FEATURE_LIST diff --git a/crates/c-api/artifact/Cargo.toml b/crates/c-api/artifact/Cargo.toml index f9c594c0ed8f..bdba085a9659 100644 --- a/crates/c-api/artifact/Cargo.toml +++ b/crates/c-api/artifact/Cargo.toml @@ -38,6 +38,7 @@ default = [ 'gc-null', 'cranelift', 'winch', + 'debug-builtins', # ... if you add a line above this be sure to change the other locations # marked WASMTIME_FEATURE_LIST ] @@ -68,6 +69,6 @@ wasmfx_pooling_allocator = ["wasmtime-c-api/wasmfx_pooling_allocator"] # Enable the old-style unsafe malloc'd stacks unsafe_wasmfx_stacks = ["wasmtime-c-api/unsafe_wasmfx_stacks"] - +debug-builtins = ["wasmtime-c-api/debug-builtins"] # ... if you add a line above this be sure to read the comment at the end of # `default` diff --git a/crates/c-api/build.rs b/crates/c-api/build.rs index 5b9f66ef1335..3762019a070d 100644 --- a/crates/c-api/build.rs +++ b/crates/c-api/build.rs @@ -22,6 +22,7 @@ const FEATURES: &[&str] = &[ "WASMFX_BASELINE", "WASMFX_POOLING_ALLOCATOR", "UNSAFE_WASMFX_STACKS", + "DEBUG_BUILTINS", ]; // ... if you add a line above this be sure to change the other locations // marked WASMTIME_FEATURE_LIST diff --git a/crates/c-api/cmake/features.cmake b/crates/c-api/cmake/features.cmake index cba1d67706cd..0ebb233311cd 100644 --- a/crates/c-api/cmake/features.cmake +++ b/crates/c-api/cmake/features.cmake @@ -46,5 +46,6 @@ feature(winch ON) feature(wasmfx_baseline OFF) feature(wasmfx_pooling_allocator OFF) feature(unsafe_wasmfx_stacks OFF) +feature(debug-builtins ON) # ... if you add a line above this be sure to change the other locations # marked WASMTIME_FEATURE_LIST diff --git a/crates/c-api/include/wasmtime/conf.h.in b/crates/c-api/include/wasmtime/conf.h.in index 70902584abf7..84cb28e96aec 100644 --- a/crates/c-api/include/wasmtime/conf.h.in +++ b/crates/c-api/include/wasmtime/conf.h.in @@ -28,6 +28,7 @@ #cmakedefine WASMTIME_FEATURE_WASMFX_BASELINE #cmakedefine WASMTIME_FEATURE_WASMFX_POOLING_ALLOCATOR #cmakedefine WASMTIME_FEATURE_UNSAFE_WASMFX_STACKS +#cmakedefine WASMTIME_FEATURE_DEBUG_BUILTINS // ... if you add a line above this be sure to change the other locations // marked WASMTIME_FEATURE_LIST diff --git a/crates/cli-flags/Cargo.toml b/crates/cli-flags/Cargo.toml index c1c84ce39dd7..f42efcdc05bd 100644 --- a/crates/cli-flags/Cargo.toml +++ b/crates/cli-flags/Cargo.toml @@ -18,7 +18,7 @@ clap = { workspace = true } file-per-thread-logger = { workspace = true, optional = true } tracing-subscriber = { workspace = true, optional = true } rayon = { version = "1.5.0", optional = true } -wasmtime = { workspace = true, features = ["gc"] } +wasmtime = { workspace = true } humantime = { workspace = true } [features] diff --git a/crates/cli-flags/src/lib.rs b/crates/cli-flags/src/lib.rs index 329f1f8bd22f..22b83e2be82d 100644 --- a/crates/cli-flags/src/lib.rs +++ b/crates/cli-flags/src/lib.rs @@ -551,11 +551,19 @@ impl CommonOptions { } else { use std::io::IsTerminal; use tracing_subscriber::{EnvFilter, FmtSubscriber}; - let b = FmtSubscriber::builder() + let builder = FmtSubscriber::builder() .with_writer(std::io::stderr) .with_env_filter(EnvFilter::from_env("WASMTIME_LOG")) .with_ansi(std::io::stderr().is_terminal()); - b.init(); + if std::env::var("WASMTIME_LOG_NO_CONTEXT").is_ok_and(|value| value.eq("1")) { + builder + .with_level(false) + .with_target(false) + .without_time() + .init() + } else { + builder.init(); + } } #[cfg(not(feature = "logging"))] if self.debug.log_to_files == Some(true) || self.debug.logging == Some(true) { @@ -722,8 +730,10 @@ impl CommonOptions { if let Some(enable) = self.debug.address_map { config.generate_address_map(enable); } - if let Some(enable) = self.opts.memory_init_cow { - config.memory_init_cow(enable); + match_feature! { + ["signals-based-traps" : self.opts.memory_init_cow] + enable => config.memory_init_cow(enable), + _ => err, } match_feature! { ["signals-based-traps" : self.opts.signals_based_traps] diff --git a/crates/component-macro/tests/expanded/char.rs b/crates/component-macro/tests/expanded/char.rs index c8e1b9436487..6ff749f08e7f 100644 --- a/crates/component-macro/tests/expanded/char.rs +++ b/crates/component-macro/tests/expanded/char.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod chars { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { /// A function that accepts a character fn take_char(&mut self, x: char) -> (); @@ -258,7 +258,7 @@ pub mod exports { #[allow(clippy::all)] pub mod chars { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { take_char: wasmtime::component::Func, return_char: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/char_async.rs b/crates/component-macro/tests/expanded/char_async.rs index e2bb10590177..730c6acb3213 100644 --- a/crates/component-macro/tests/expanded/char_async.rs +++ b/crates/component-macro/tests/expanded/char_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod chars { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { /// A function that accepts a character async fn take_char(&mut self, x: char) -> (); @@ -255,7 +255,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { /// A function that accepts a character async fn take_char(&mut self, x: char) -> () { @@ -275,7 +274,7 @@ pub mod exports { #[allow(clippy::all)] pub mod chars { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { take_char: wasmtime::component::Func, return_char: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/char_tracing_async.rs b/crates/component-macro/tests/expanded/char_tracing_async.rs index dc7caf15fc8d..aa1f926ea35f 100644 --- a/crates/component-macro/tests/expanded/char_tracing_async.rs +++ b/crates/component-macro/tests/expanded/char_tracing_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod chars { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { /// A function that accepts a character async fn take_char(&mut self, x: char) -> (); @@ -284,7 +284,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { /// A function that accepts a character async fn take_char(&mut self, x: char) -> () { @@ -304,7 +303,7 @@ pub mod exports { #[allow(clippy::all)] pub mod chars { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { take_char: wasmtime::component::Func, return_char: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/conventions.rs b/crates/component-macro/tests/expanded/conventions.rs index 631be530d8b8..eb341bb8b471 100644 --- a/crates/component-macro/tests/expanded/conventions.rs +++ b/crates/component-macro/tests/expanded/conventions.rs @@ -187,7 +187,7 @@ pub mod foo { #[allow(clippy::all)] pub mod conventions { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -420,7 +420,7 @@ pub mod exports { #[allow(clippy::all)] pub mod conventions { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/conventions_async.rs b/crates/component-macro/tests/expanded/conventions_async.rs index f591169d80bf..dfda26d25938 100644 --- a/crates/component-macro/tests/expanded/conventions_async.rs +++ b/crates/component-macro/tests/expanded/conventions_async.rs @@ -194,7 +194,7 @@ pub mod foo { #[allow(clippy::all)] pub mod conventions { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -227,7 +227,7 @@ pub mod foo { >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn kebab_case(&mut self) -> (); async fn foo(&mut self, x: LudicrousSpeed) -> (); @@ -403,7 +403,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn kebab_case(&mut self) -> () { Host::kebab_case(*self).await @@ -457,7 +456,7 @@ pub mod exports { #[allow(clippy::all)] pub mod conventions { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/conventions_tracing_async.rs b/crates/component-macro/tests/expanded/conventions_tracing_async.rs index ac89ef41c553..d949eaae9fa2 100644 --- a/crates/component-macro/tests/expanded/conventions_tracing_async.rs +++ b/crates/component-macro/tests/expanded/conventions_tracing_async.rs @@ -194,7 +194,7 @@ pub mod foo { #[allow(clippy::all)] pub mod conventions { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -227,7 +227,7 @@ pub mod foo { >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn kebab_case(&mut self) -> (); async fn foo(&mut self, x: LudicrousSpeed) -> (); @@ -563,7 +563,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn kebab_case(&mut self) -> () { Host::kebab_case(*self).await @@ -617,7 +616,7 @@ pub mod exports { #[allow(clippy::all)] pub mod conventions { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/dead-code.rs b/crates/component-macro/tests/expanded/dead-code.rs index 30781af56403..23f775721411 100644 --- a/crates/component-macro/tests/expanded/dead-code.rs +++ b/crates/component-macro/tests/expanded/dead-code.rs @@ -174,7 +174,7 @@ pub mod a { #[allow(clippy::all)] pub mod interface_with_live_type { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -243,7 +243,7 @@ pub mod a { #[allow(clippy::all)] pub mod interface_with_dead_type { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host {} pub trait GetHost< T, diff --git a/crates/component-macro/tests/expanded/dead-code_async.rs b/crates/component-macro/tests/expanded/dead-code_async.rs index 9ae5d387835d..7ba8b30a3908 100644 --- a/crates/component-macro/tests/expanded/dead-code_async.rs +++ b/crates/component-macro/tests/expanded/dead-code_async.rs @@ -181,7 +181,7 @@ pub mod a { #[allow(clippy::all)] pub mod interface_with_live_type { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -202,7 +202,7 @@ pub mod a { 4 == < LiveType as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn f(&mut self) -> LiveType; } @@ -248,7 +248,6 @@ pub mod a { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn f(&mut self) -> LiveType { Host::f(*self).await @@ -258,8 +257,8 @@ pub mod a { #[allow(clippy::all)] pub mod interface_with_dead_type { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -293,7 +292,6 @@ pub mod a { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/component-macro/tests/expanded/dead-code_tracing_async.rs b/crates/component-macro/tests/expanded/dead-code_tracing_async.rs index fc670a943af6..b394499697c0 100644 --- a/crates/component-macro/tests/expanded/dead-code_tracing_async.rs +++ b/crates/component-macro/tests/expanded/dead-code_tracing_async.rs @@ -181,7 +181,7 @@ pub mod a { #[allow(clippy::all)] pub mod interface_with_live_type { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -202,7 +202,7 @@ pub mod a { 4 == < LiveType as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn f(&mut self) -> LiveType; } @@ -261,7 +261,6 @@ pub mod a { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn f(&mut self) -> LiveType { Host::f(*self).await @@ -271,8 +270,8 @@ pub mod a { #[allow(clippy::all)] pub mod interface_with_dead_type { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -306,7 +305,6 @@ pub mod a { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/component-macro/tests/expanded/direct-import_async.rs b/crates/component-macro/tests/expanded/direct-import_async.rs index 3eb3b163154f..a0ab29ebc481 100644 --- a/crates/component-macro/tests/expanded/direct-import_async.rs +++ b/crates/component-macro/tests/expanded/direct-import_async.rs @@ -95,7 +95,7 @@ pub struct FooIndices {} /// [`Component`]: wasmtime::component::Component /// [`Linker`]: wasmtime::component::Linker pub struct Foo {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait FooImports: Send { async fn foo(&mut self) -> (); } @@ -111,7 +111,6 @@ where { type Host = O; } -#[wasmtime::component::__internal::async_trait] impl<_T: FooImports + ?Sized + Send> FooImports for &mut _T { async fn foo(&mut self) -> () { FooImports::foo(*self).await diff --git a/crates/component-macro/tests/expanded/direct-import_tracing_async.rs b/crates/component-macro/tests/expanded/direct-import_tracing_async.rs index 464deae28bf9..1ee124c08a94 100644 --- a/crates/component-macro/tests/expanded/direct-import_tracing_async.rs +++ b/crates/component-macro/tests/expanded/direct-import_tracing_async.rs @@ -95,7 +95,7 @@ pub struct FooIndices {} /// [`Component`]: wasmtime::component::Component /// [`Linker`]: wasmtime::component::Linker pub struct Foo {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait FooImports: Send { async fn foo(&mut self) -> (); } @@ -111,7 +111,6 @@ where { type Host = O; } -#[wasmtime::component::__internal::async_trait] impl<_T: FooImports + ?Sized + Send> FooImports for &mut _T { async fn foo(&mut self) -> () { FooImports::foo(*self).await diff --git a/crates/component-macro/tests/expanded/flags.rs b/crates/component-macro/tests/expanded/flags.rs index c036a1a2d85b..456c9a239905 100644 --- a/crates/component-macro/tests/expanded/flags.rs +++ b/crates/component-macro/tests/expanded/flags.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod flegs { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; }); const _: () = { assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32); @@ -446,7 +446,7 @@ pub mod exports { #[allow(clippy::all)] pub mod flegs { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; wasmtime::component::flags!( Flag1 { #[component(name = "b0")] const B0; } ); diff --git a/crates/component-macro/tests/expanded/flags_async.rs b/crates/component-macro/tests/expanded/flags_async.rs index d7f9786d0d75..c872a542d0ce 100644 --- a/crates/component-macro/tests/expanded/flags_async.rs +++ b/crates/component-macro/tests/expanded/flags_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod flegs { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; }); const _: () = { assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32); @@ -307,7 +307,7 @@ pub mod foo { assert!(8 == < Flag64 as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn roundtrip_flag1(&mut self, x: Flag1) -> Flag1; async fn roundtrip_flag2(&mut self, x: Flag2) -> Flag2; @@ -440,7 +440,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn roundtrip_flag1(&mut self, x: Flag1) -> Flag1 { Host::roundtrip_flag1(*self, x).await @@ -473,7 +472,7 @@ pub mod exports { #[allow(clippy::all)] pub mod flegs { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; wasmtime::component::flags!( Flag1 { #[component(name = "b0")] const B0; } ); diff --git a/crates/component-macro/tests/expanded/flags_tracing_async.rs b/crates/component-macro/tests/expanded/flags_tracing_async.rs index 8bec37487115..01bfeb05ab6d 100644 --- a/crates/component-macro/tests/expanded/flags_tracing_async.rs +++ b/crates/component-macro/tests/expanded/flags_tracing_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod flegs { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; }); const _: () = { assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32); @@ -307,7 +307,7 @@ pub mod foo { assert!(8 == < Flag64 as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Flag64 as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn roundtrip_flag1(&mut self, x: Flag1) -> Flag1; async fn roundtrip_flag2(&mut self, x: Flag2) -> Flag2; @@ -552,7 +552,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn roundtrip_flag1(&mut self, x: Flag1) -> Flag1 { Host::roundtrip_flag1(*self, x).await @@ -585,7 +584,7 @@ pub mod exports { #[allow(clippy::all)] pub mod flegs { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; wasmtime::component::flags!( Flag1 { #[component(name = "b0")] const B0; } ); diff --git a/crates/component-macro/tests/expanded/floats.rs b/crates/component-macro/tests/expanded/floats.rs index 50f7b3ca973f..89079f828361 100644 --- a/crates/component-macro/tests/expanded/floats.rs +++ b/crates/component-macro/tests/expanded/floats.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod floats { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { fn f32_param(&mut self, x: f32) -> (); fn f64_param(&mut self, x: f64) -> (); @@ -275,7 +275,7 @@ pub mod exports { #[allow(clippy::all)] pub mod floats { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { f32_param: wasmtime::component::Func, f64_param: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/floats_async.rs b/crates/component-macro/tests/expanded/floats_async.rs index 268d10882964..4313d8ca2b95 100644 --- a/crates/component-macro/tests/expanded/floats_async.rs +++ b/crates/component-macro/tests/expanded/floats_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod floats { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn f32_param(&mut self, x: f32) -> (); async fn f64_param(&mut self, x: f64) -> (); @@ -272,7 +272,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn f32_param(&mut self, x: f32) -> () { Host::f32_param(*self, x).await @@ -296,7 +295,7 @@ pub mod exports { #[allow(clippy::all)] pub mod floats { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { f32_param: wasmtime::component::Func, f64_param: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/floats_tracing_async.rs b/crates/component-macro/tests/expanded/floats_tracing_async.rs index 254cdef3d299..25194e376795 100644 --- a/crates/component-macro/tests/expanded/floats_tracing_async.rs +++ b/crates/component-macro/tests/expanded/floats_tracing_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod floats { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn f32_param(&mut self, x: f32) -> (); async fn f64_param(&mut self, x: f64) -> (); @@ -330,7 +330,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn f32_param(&mut self, x: f32) -> () { Host::f32_param(*self, x).await @@ -354,7 +353,7 @@ pub mod exports { #[allow(clippy::all)] pub mod floats { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { f32_param: wasmtime::component::Func, f64_param: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/host-world_async.rs b/crates/component-macro/tests/expanded/host-world_async.rs index 79226375a941..d6dee9406e8c 100644 --- a/crates/component-macro/tests/expanded/host-world_async.rs +++ b/crates/component-macro/tests/expanded/host-world_async.rs @@ -95,7 +95,7 @@ pub struct Host_Indices {} /// [`Component`]: wasmtime::component::Component /// [`Linker`]: wasmtime::component::Linker pub struct Host_ {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host_Imports: Send { async fn foo(&mut self) -> (); } @@ -111,7 +111,6 @@ where { type Host = O; } -#[wasmtime::component::__internal::async_trait] impl<_T: Host_Imports + ?Sized + Send> Host_Imports for &mut _T { async fn foo(&mut self) -> () { Host_Imports::foo(*self).await diff --git a/crates/component-macro/tests/expanded/host-world_tracing_async.rs b/crates/component-macro/tests/expanded/host-world_tracing_async.rs index 9ded0ccb6d54..8ef92dbe2326 100644 --- a/crates/component-macro/tests/expanded/host-world_tracing_async.rs +++ b/crates/component-macro/tests/expanded/host-world_tracing_async.rs @@ -95,7 +95,7 @@ pub struct Host_Indices {} /// [`Component`]: wasmtime::component::Component /// [`Linker`]: wasmtime::component::Linker pub struct Host_ {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host_Imports: Send { async fn foo(&mut self) -> (); } @@ -111,7 +111,6 @@ where { type Host = O; } -#[wasmtime::component::__internal::async_trait] impl<_T: Host_Imports + ?Sized + Send> Host_Imports for &mut _T { async fn foo(&mut self) -> () { Host_Imports::foo(*self).await diff --git a/crates/component-macro/tests/expanded/integers.rs b/crates/component-macro/tests/expanded/integers.rs index a0ea4d42e45e..fd4edcf6e1ab 100644 --- a/crates/component-macro/tests/expanded/integers.rs +++ b/crates/component-macro/tests/expanded/integers.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod integers { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { fn a1(&mut self, x: u8) -> (); fn a2(&mut self, x: i8) -> (); @@ -485,7 +485,7 @@ pub mod exports { #[allow(clippy::all)] pub mod integers { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { a1: wasmtime::component::Func, a2: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/integers_async.rs b/crates/component-macro/tests/expanded/integers_async.rs index e0dc621675bb..47045b1f6a92 100644 --- a/crates/component-macro/tests/expanded/integers_async.rs +++ b/crates/component-macro/tests/expanded/integers_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod integers { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a1(&mut self, x: u8) -> (); async fn a2(&mut self, x: i8) -> (); @@ -459,7 +459,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a1(&mut self, x: u8) -> () { Host::a1(*self, x).await @@ -535,7 +534,7 @@ pub mod exports { #[allow(clippy::all)] pub mod integers { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { a1: wasmtime::component::Func, a2: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/integers_tracing_async.rs b/crates/component-macro/tests/expanded/integers_tracing_async.rs index b14b6f2d962c..a8778d525cb6 100644 --- a/crates/component-macro/tests/expanded/integers_tracing_async.rs +++ b/crates/component-macro/tests/expanded/integers_tracing_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod integers { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a1(&mut self, x: u8) -> (); async fn a2(&mut self, x: i8) -> (); @@ -724,7 +724,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a1(&mut self, x: u8) -> () { Host::a1(*self, x).await @@ -800,7 +799,7 @@ pub mod exports { #[allow(clippy::all)] pub mod integers { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { a1: wasmtime::component::Func, a2: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/lists.rs b/crates/component-macro/tests/expanded/lists.rs index d5067c796dc5..bf131e0b4b01 100644 --- a/crates/component-macro/tests/expanded/lists.rs +++ b/crates/component-macro/tests/expanded/lists.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -963,7 +963,7 @@ pub mod exports { #[allow(clippy::all)] pub mod lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/lists_async.rs b/crates/component-macro/tests/expanded/lists_async.rs index 219a469f9548..aa55a3f6503e 100644 --- a/crates/component-macro/tests/expanded/lists_async.rs +++ b/crates/component-macro/tests/expanded/lists_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -373,7 +373,7 @@ pub mod foo { >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn list_u8_param( &mut self, @@ -887,7 +887,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn list_u8_param( &mut self, @@ -1074,7 +1073,7 @@ pub mod exports { #[allow(clippy::all)] pub mod lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/lists_tracing_async.rs b/crates/component-macro/tests/expanded/lists_tracing_async.rs index dece512b8e0a..a1e470bea83f 100644 --- a/crates/component-macro/tests/expanded/lists_tracing_async.rs +++ b/crates/component-macro/tests/expanded/lists_tracing_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -373,7 +373,7 @@ pub mod foo { >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn list_u8_param( &mut self, @@ -1318,7 +1318,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn list_u8_param( &mut self, @@ -1505,7 +1504,7 @@ pub mod exports { #[allow(clippy::all)] pub mod lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/many-arguments.rs b/crates/component-macro/tests/expanded/many-arguments.rs index 86db694f8323..615876268b88 100644 --- a/crates/component-macro/tests/expanded/many-arguments.rs +++ b/crates/component-macro/tests/expanded/many-arguments.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod manyarg { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -444,7 +444,7 @@ pub mod exports { #[allow(clippy::all)] pub mod manyarg { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/many-arguments_async.rs b/crates/component-macro/tests/expanded/many-arguments_async.rs index 3a55a6565f58..1f454d623998 100644 --- a/crates/component-macro/tests/expanded/many-arguments_async.rs +++ b/crates/component-macro/tests/expanded/many-arguments_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod manyarg { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -274,7 +274,7 @@ pub mod foo { 4 == < BigStruct as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn many_args( &mut self, @@ -408,7 +408,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn many_args( &mut self, @@ -463,7 +462,7 @@ pub mod exports { #[allow(clippy::all)] pub mod manyarg { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs b/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs index ed87748a3f17..334616870f8a 100644 --- a/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs +++ b/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod manyarg { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -274,7 +274,7 @@ pub mod foo { 4 == < BigStruct as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn many_args( &mut self, @@ -451,7 +451,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn many_args( &mut self, @@ -506,7 +505,7 @@ pub mod exports { #[allow(clippy::all)] pub mod manyarg { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/multi-return.rs b/crates/component-macro/tests/expanded/multi-return.rs index 7b42ddcaeb3c..dd0637fbeb4b 100644 --- a/crates/component-macro/tests/expanded/multi-return.rs +++ b/crates/component-macro/tests/expanded/multi-return.rs @@ -187,7 +187,7 @@ pub mod foo { #[allow(clippy::all)] pub mod multi_return { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { fn mra(&mut self) -> (); fn mrb(&mut self) -> (); @@ -289,7 +289,7 @@ pub mod exports { #[allow(clippy::all)] pub mod multi_return { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { mra: wasmtime::component::Func, mrb: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/multi-return_async.rs b/crates/component-macro/tests/expanded/multi-return_async.rs index d0c44c782757..2b434520c89c 100644 --- a/crates/component-macro/tests/expanded/multi-return_async.rs +++ b/crates/component-macro/tests/expanded/multi-return_async.rs @@ -194,8 +194,8 @@ pub mod foo { #[allow(clippy::all)] pub mod multi_return { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn mra(&mut self) -> (); async fn mrb(&mut self) -> (); @@ -285,7 +285,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn mra(&mut self) -> () { Host::mra(*self).await @@ -312,7 +311,7 @@ pub mod exports { #[allow(clippy::all)] pub mod multi_return { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { mra: wasmtime::component::Func, mrb: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/multi-return_tracing_async.rs b/crates/component-macro/tests/expanded/multi-return_tracing_async.rs index f24b6a347d29..ca9c503e58b7 100644 --- a/crates/component-macro/tests/expanded/multi-return_tracing_async.rs +++ b/crates/component-macro/tests/expanded/multi-return_tracing_async.rs @@ -194,8 +194,8 @@ pub mod foo { #[allow(clippy::all)] pub mod multi_return { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn mra(&mut self) -> (); async fn mrb(&mut self) -> (); @@ -350,7 +350,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn mra(&mut self) -> () { Host::mra(*self).await @@ -377,7 +376,7 @@ pub mod exports { #[allow(clippy::all)] pub mod multi_return { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { mra: wasmtime::component::Func, mrb: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/multiversion.rs b/crates/component-macro/tests/expanded/multiversion.rs index 44d9e429237e..da50b12799ea 100644 --- a/crates/component-macro/tests/expanded/multiversion.rs +++ b/crates/component-macro/tests/expanded/multiversion.rs @@ -203,7 +203,7 @@ pub mod my { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { fn x(&mut self) -> (); } @@ -254,7 +254,7 @@ pub mod my { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { fn x(&mut self) -> (); } @@ -308,7 +308,7 @@ pub mod exports { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { x: wasmtime::component::Func, } @@ -408,7 +408,7 @@ pub mod exports { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { x: wasmtime::component::Func, } diff --git a/crates/component-macro/tests/expanded/multiversion_async.rs b/crates/component-macro/tests/expanded/multiversion_async.rs index 9d730e2f643c..885c0ce1b69b 100644 --- a/crates/component-macro/tests/expanded/multiversion_async.rs +++ b/crates/component-macro/tests/expanded/multiversion_async.rs @@ -210,8 +210,8 @@ pub mod my { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn x(&mut self) -> (); } @@ -257,7 +257,6 @@ pub mod my { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn x(&mut self) -> () { Host::x(*self).await @@ -269,8 +268,8 @@ pub mod my { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn x(&mut self) -> (); } @@ -316,7 +315,6 @@ pub mod my { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn x(&mut self) -> () { Host::x(*self).await @@ -331,7 +329,7 @@ pub mod exports { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { x: wasmtime::component::Func, } @@ -434,7 +432,7 @@ pub mod exports { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { x: wasmtime::component::Func, } diff --git a/crates/component-macro/tests/expanded/multiversion_tracing_async.rs b/crates/component-macro/tests/expanded/multiversion_tracing_async.rs index 11fa4d6cbbcc..76256e2fa92b 100644 --- a/crates/component-macro/tests/expanded/multiversion_tracing_async.rs +++ b/crates/component-macro/tests/expanded/multiversion_tracing_async.rs @@ -210,8 +210,8 @@ pub mod my { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn x(&mut self) -> (); } @@ -270,7 +270,6 @@ pub mod my { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn x(&mut self) -> () { Host::x(*self).await @@ -282,8 +281,8 @@ pub mod my { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn x(&mut self) -> (); } @@ -342,7 +341,6 @@ pub mod my { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn x(&mut self) -> () { Host::x(*self).await @@ -357,7 +355,7 @@ pub mod exports { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { x: wasmtime::component::Func, } @@ -471,7 +469,7 @@ pub mod exports { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { x: wasmtime::component::Func, } diff --git a/crates/component-macro/tests/expanded/path1.rs b/crates/component-macro/tests/expanded/path1.rs index a4ce53636f65..834a00afedb8 100644 --- a/crates/component-macro/tests/expanded/path1.rs +++ b/crates/component-macro/tests/expanded/path1.rs @@ -172,7 +172,7 @@ pub mod paths { #[allow(clippy::all)] pub mod test { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host {} pub trait GetHost< T, diff --git a/crates/component-macro/tests/expanded/path1_async.rs b/crates/component-macro/tests/expanded/path1_async.rs index 45f121cdd893..d4b1af2dee6d 100644 --- a/crates/component-macro/tests/expanded/path1_async.rs +++ b/crates/component-macro/tests/expanded/path1_async.rs @@ -179,8 +179,8 @@ pub mod paths { #[allow(clippy::all)] pub mod test { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -214,7 +214,6 @@ pub mod paths { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/component-macro/tests/expanded/path1_tracing_async.rs b/crates/component-macro/tests/expanded/path1_tracing_async.rs index 45f121cdd893..d4b1af2dee6d 100644 --- a/crates/component-macro/tests/expanded/path1_tracing_async.rs +++ b/crates/component-macro/tests/expanded/path1_tracing_async.rs @@ -179,8 +179,8 @@ pub mod paths { #[allow(clippy::all)] pub mod test { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -214,7 +214,6 @@ pub mod paths { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/component-macro/tests/expanded/path2.rs b/crates/component-macro/tests/expanded/path2.rs index 5d9fba7b1ba0..fd9b5460a9e8 100644 --- a/crates/component-macro/tests/expanded/path2.rs +++ b/crates/component-macro/tests/expanded/path2.rs @@ -172,7 +172,7 @@ pub mod paths { #[allow(clippy::all)] pub mod test { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host {} pub trait GetHost< T, diff --git a/crates/component-macro/tests/expanded/path2_async.rs b/crates/component-macro/tests/expanded/path2_async.rs index 0e07fe478658..45fdb5d811b5 100644 --- a/crates/component-macro/tests/expanded/path2_async.rs +++ b/crates/component-macro/tests/expanded/path2_async.rs @@ -179,8 +179,8 @@ pub mod paths { #[allow(clippy::all)] pub mod test { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -214,7 +214,6 @@ pub mod paths { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/component-macro/tests/expanded/path2_tracing_async.rs b/crates/component-macro/tests/expanded/path2_tracing_async.rs index 0e07fe478658..45fdb5d811b5 100644 --- a/crates/component-macro/tests/expanded/path2_tracing_async.rs +++ b/crates/component-macro/tests/expanded/path2_tracing_async.rs @@ -179,8 +179,8 @@ pub mod paths { #[allow(clippy::all)] pub mod test { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -214,7 +214,6 @@ pub mod paths { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/component-macro/tests/expanded/records.rs b/crates/component-macro/tests/expanded/records.rs index 5a6fed8dcbd3..edca81d63efb 100644 --- a/crates/component-macro/tests/expanded/records.rs +++ b/crates/component-macro/tests/expanded/records.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod records { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -523,7 +523,7 @@ pub mod exports { #[allow(clippy::all)] pub mod records { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/records_async.rs b/crates/component-macro/tests/expanded/records_async.rs index a7c2e82c405c..0c087de7ff66 100644 --- a/crates/component-macro/tests/expanded/records_async.rs +++ b/crates/component-macro/tests/expanded/records_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod records { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -339,7 +339,7 @@ pub mod foo { 4 == < TupleTypedef2 as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn tuple_arg(&mut self, x: (char, u32)) -> (); async fn tuple_result(&mut self) -> (char, u32); @@ -513,7 +513,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn tuple_arg(&mut self, x: (char, u32)) -> () { Host::tuple_arg(*self, x).await @@ -558,7 +557,7 @@ pub mod exports { #[allow(clippy::all)] pub mod records { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/records_tracing_async.rs b/crates/component-macro/tests/expanded/records_tracing_async.rs index 8bcfaffa0ea7..075b7dc57ae1 100644 --- a/crates/component-macro/tests/expanded/records_tracing_async.rs +++ b/crates/component-macro/tests/expanded/records_tracing_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod records { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -339,7 +339,7 @@ pub mod foo { 4 == < TupleTypedef2 as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn tuple_arg(&mut self, x: (char, u32)) -> (); async fn tuple_result(&mut self) -> (char, u32); @@ -674,7 +674,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn tuple_arg(&mut self, x: (char, u32)) -> () { Host::tuple_arg(*self, x).await @@ -719,7 +718,7 @@ pub mod exports { #[allow(clippy::all)] pub mod records { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/rename.rs b/crates/component-macro/tests/expanded/rename.rs index 40ad51574259..5870b202254f 100644 --- a/crates/component-macro/tests/expanded/rename.rs +++ b/crates/component-macro/tests/expanded/rename.rs @@ -173,7 +173,7 @@ pub mod foo { #[allow(clippy::all)] pub mod green { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Thing = i32; const _: () = { assert!(4 == < Thing as wasmtime::component::ComponentType >::SIZE32); @@ -213,7 +213,7 @@ pub mod foo { #[allow(clippy::all)] pub mod red { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Thing = super::super::super::foo::foo::green::Thing; const _: () = { assert!(4 == < Thing as wasmtime::component::ComponentType >::SIZE32); diff --git a/crates/component-macro/tests/expanded/rename_async.rs b/crates/component-macro/tests/expanded/rename_async.rs index e1966b08dc86..467bb6509fb6 100644 --- a/crates/component-macro/tests/expanded/rename_async.rs +++ b/crates/component-macro/tests/expanded/rename_async.rs @@ -180,13 +180,13 @@ pub mod foo { #[allow(clippy::all)] pub mod green { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Thing = i32; const _: () = { assert!(4 == < Thing as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Thing as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -220,19 +220,18 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } #[allow(clippy::all)] pub mod red { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Thing = super::super::super::foo::foo::green::Thing; const _: () = { assert!(4 == < Thing as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Thing as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn foo(&mut self) -> Thing; } @@ -278,7 +277,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn foo(&mut self) -> Thing { Host::foo(*self).await diff --git a/crates/component-macro/tests/expanded/rename_tracing_async.rs b/crates/component-macro/tests/expanded/rename_tracing_async.rs index f8bc4e5e606c..2adc67f4420c 100644 --- a/crates/component-macro/tests/expanded/rename_tracing_async.rs +++ b/crates/component-macro/tests/expanded/rename_tracing_async.rs @@ -180,13 +180,13 @@ pub mod foo { #[allow(clippy::all)] pub mod green { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Thing = i32; const _: () = { assert!(4 == < Thing as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Thing as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -220,19 +220,18 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } #[allow(clippy::all)] pub mod red { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Thing = super::super::super::foo::foo::green::Thing; const _: () = { assert!(4 == < Thing as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Thing as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn foo(&mut self) -> Thing; } @@ -291,7 +290,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn foo(&mut self) -> Thing { Host::foo(*self).await diff --git a/crates/component-macro/tests/expanded/resources-export.rs b/crates/component-macro/tests/expanded/resources-export.rs index 2df3c228fa37..4414d8344ee2 100644 --- a/crates/component-macro/tests/expanded/resources-export.rs +++ b/crates/component-macro/tests/expanded/resources-export.rs @@ -247,7 +247,7 @@ pub mod foo { #[allow(clippy::all)] pub mod transitive_import { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum Y {} pub trait HostY { fn drop( @@ -312,7 +312,7 @@ pub mod exports { #[allow(clippy::all)] pub mod simple_export { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = wasmtime::component::ResourceAny; pub struct GuestA<'a> { funcs: &'a Guest, @@ -477,7 +477,7 @@ pub mod exports { #[allow(clippy::all)] pub mod export_using_import { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Y = super::super::super::super::foo::foo::transitive_import::Y; pub type A = wasmtime::component::ResourceAny; pub struct GuestA<'a> { @@ -651,7 +651,7 @@ pub mod exports { #[allow(clippy::all)] pub mod export_using_export1 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = wasmtime::component::ResourceAny; pub struct GuestA<'a> { funcs: &'a Guest, @@ -763,7 +763,7 @@ pub mod exports { #[allow(clippy::all)] pub mod export_using_export2 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::super::exports::foo::foo::export_using_export1::A; pub type B = wasmtime::component::ResourceAny; pub struct GuestB<'a> { diff --git a/crates/component-macro/tests/expanded/resources-export_async.rs b/crates/component-macro/tests/expanded/resources-export_async.rs index 09a3766b8731..9a37b5488e67 100644 --- a/crates/component-macro/tests/expanded/resources-export_async.rs +++ b/crates/component-macro/tests/expanded/resources-export_async.rs @@ -254,16 +254,15 @@ pub mod foo { #[allow(clippy::all)] pub mod transitive_import { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum Y {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostY { async fn drop( &mut self, rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostY + ?Sized + Send> HostY for &mut _T { async fn drop( &mut self, @@ -272,7 +271,7 @@ pub mod foo { HostY::drop(*self, rep).await } } - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostY {} pub trait GetHost< T, @@ -298,7 +297,7 @@ pub mod foo { "y", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostY::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -319,7 +318,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } @@ -330,7 +328,7 @@ pub mod exports { #[allow(clippy::all)] pub mod simple_export { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = wasmtime::component::ResourceAny; pub struct GuestA<'a> { funcs: &'a Guest, @@ -510,7 +508,7 @@ pub mod exports { #[allow(clippy::all)] pub mod export_using_import { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Y = super::super::super::super::foo::foo::transitive_import::Y; pub type A = wasmtime::component::ResourceAny; pub struct GuestA<'a> { @@ -699,7 +697,7 @@ pub mod exports { #[allow(clippy::all)] pub mod export_using_export1 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = wasmtime::component::ResourceAny; pub struct GuestA<'a> { funcs: &'a Guest, @@ -816,7 +814,7 @@ pub mod exports { #[allow(clippy::all)] pub mod export_using_export2 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::super::exports::foo::foo::export_using_export1::A; pub type B = wasmtime::component::ResourceAny; pub struct GuestB<'a> { diff --git a/crates/component-macro/tests/expanded/resources-export_tracing_async.rs b/crates/component-macro/tests/expanded/resources-export_tracing_async.rs index e25bebe52015..7cf0ade0f577 100644 --- a/crates/component-macro/tests/expanded/resources-export_tracing_async.rs +++ b/crates/component-macro/tests/expanded/resources-export_tracing_async.rs @@ -254,16 +254,15 @@ pub mod foo { #[allow(clippy::all)] pub mod transitive_import { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum Y {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostY { async fn drop( &mut self, rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostY + ?Sized + Send> HostY for &mut _T { async fn drop( &mut self, @@ -272,7 +271,7 @@ pub mod foo { HostY::drop(*self, rep).await } } - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostY {} pub trait GetHost< T, @@ -298,7 +297,7 @@ pub mod foo { "y", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostY::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -319,7 +318,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } @@ -330,7 +328,7 @@ pub mod exports { #[allow(clippy::all)] pub mod simple_export { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = wasmtime::component::ResourceAny; pub struct GuestA<'a> { funcs: &'a Guest, @@ -537,7 +535,7 @@ pub mod exports { #[allow(clippy::all)] pub mod export_using_import { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Y = super::super::super::super::foo::foo::transitive_import::Y; pub type A = wasmtime::component::ResourceAny; pub struct GuestA<'a> { @@ -755,7 +753,7 @@ pub mod exports { #[allow(clippy::all)] pub mod export_using_export1 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = wasmtime::component::ResourceAny; pub struct GuestA<'a> { funcs: &'a Guest, @@ -881,7 +879,7 @@ pub mod exports { #[allow(clippy::all)] pub mod export_using_export2 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::super::exports::foo::foo::export_using_export1::A; pub type B = wasmtime::component::ResourceAny; pub struct GuestB<'a> { diff --git a/crates/component-macro/tests/expanded/resources-import.rs b/crates/component-macro/tests/expanded/resources-import.rs index cbea8b03f851..cd27d777f581 100644 --- a/crates/component-macro/tests/expanded/resources-import.rs +++ b/crates/component-macro/tests/expanded/resources-import.rs @@ -344,7 +344,7 @@ pub mod foo { #[allow(clippy::all)] pub mod resources { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum Bar {} pub trait HostBar { fn new(&mut self) -> wasmtime::component::Resource; @@ -860,7 +860,7 @@ pub mod foo { #[allow(clippy::all)] pub mod long_use_chain1 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum A {} pub trait HostA { fn drop( @@ -920,7 +920,7 @@ pub mod foo { #[allow(clippy::all)] pub mod long_use_chain2 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::foo::foo::long_use_chain1::A; pub trait Host {} pub trait GetHost< @@ -956,7 +956,7 @@ pub mod foo { #[allow(clippy::all)] pub mod long_use_chain3 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::foo::foo::long_use_chain2::A; pub trait Host {} pub trait GetHost< @@ -992,7 +992,7 @@ pub mod foo { #[allow(clippy::all)] pub mod long_use_chain4 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::foo::foo::long_use_chain3::A; pub trait Host { fn foo(&mut self) -> wasmtime::component::Resource; @@ -1042,7 +1042,7 @@ pub mod foo { #[allow(clippy::all)] pub mod transitive_interface_with_resource { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum Foo {} pub trait HostFoo { fn drop( @@ -1108,7 +1108,7 @@ pub mod exports { #[allow(clippy::all)] pub mod uses_resource_transitively { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::super::super::super::foo::foo::transitive_interface_with_resource::Foo; pub struct Guest { handle: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/resources-import_async.rs b/crates/component-macro/tests/expanded/resources-import_async.rs index b54d0c283fdf..99899d3254fc 100644 --- a/crates/component-macro/tests/expanded/resources-import_async.rs +++ b/crates/component-macro/tests/expanded/resources-import_async.rs @@ -1,5 +1,5 @@ pub enum WorldResource {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostWorldResource { async fn new(&mut self) -> wasmtime::component::Resource; async fn foo(&mut self, self_: wasmtime::component::Resource) -> (); @@ -9,7 +9,6 @@ pub trait HostWorldResource { rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } -#[wasmtime::component::__internal::async_trait] impl<_T: HostWorldResource + ?Sized + Send> HostWorldResource for &mut _T { async fn new(&mut self) -> wasmtime::component::Resource { HostWorldResource::new(*self).await @@ -130,7 +129,7 @@ pub struct TheWorld { interface1: exports::foo::foo::uses_resource_transitively::Guest, some_world_func2: wasmtime::component::Func, } -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait TheWorldImports: Send + HostWorldResource { async fn some_world_func(&mut self) -> wasmtime::component::Resource; } @@ -146,7 +145,6 @@ where { type Host = O; } -#[wasmtime::component::__internal::async_trait] impl<_T: TheWorldImports + ?Sized + Send> TheWorldImports for &mut _T { async fn some_world_func(&mut self) -> wasmtime::component::Resource { TheWorldImports::some_world_func(*self).await @@ -265,7 +263,7 @@ const _: () = { "world-resource", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostWorldResource::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -373,9 +371,9 @@ pub mod foo { #[allow(clippy::all)] pub mod resources { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum Bar {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostBar { async fn new(&mut self) -> wasmtime::component::Resource; async fn static_a(&mut self) -> u32; @@ -388,7 +386,6 @@ pub mod foo { rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostBar + ?Sized + Send> HostBar for &mut _T { async fn new(&mut self) -> wasmtime::component::Resource { HostBar::new(*self).await @@ -464,7 +461,7 @@ pub mod foo { 4 == < SomeHandle as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostBar { async fn bar_own_arg( &mut self, @@ -554,7 +551,7 @@ pub mod foo { "bar", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostBar::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -849,7 +846,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn bar_own_arg( &mut self, @@ -957,16 +953,15 @@ pub mod foo { #[allow(clippy::all)] pub mod long_use_chain1 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum A {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostA { async fn drop( &mut self, rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostA + ?Sized + Send> HostA for &mut _T { async fn drop( &mut self, @@ -975,7 +970,7 @@ pub mod foo { HostA::drop(*self, rep).await } } - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostA {} pub trait GetHost< T, @@ -1001,7 +996,7 @@ pub mod foo { "a", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostA::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -1022,15 +1017,14 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } #[allow(clippy::all)] pub mod long_use_chain2 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::foo::foo::long_use_chain1::A; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -1064,15 +1058,14 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } #[allow(clippy::all)] pub mod long_use_chain3 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::foo::foo::long_use_chain2::A; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -1106,15 +1099,14 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } #[allow(clippy::all)] pub mod long_use_chain4 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::foo::foo::long_use_chain3::A; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn foo(&mut self) -> wasmtime::component::Resource; } @@ -1160,7 +1152,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn foo(&mut self) -> wasmtime::component::Resource { Host::foo(*self).await @@ -1170,16 +1161,15 @@ pub mod foo { #[allow(clippy::all)] pub mod transitive_interface_with_resource { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum Foo {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostFoo { async fn drop( &mut self, rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostFoo + ?Sized + Send> HostFoo for &mut _T { async fn drop( &mut self, @@ -1188,7 +1178,7 @@ pub mod foo { HostFoo::drop(*self, rep).await } } - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostFoo {} pub trait GetHost< T, @@ -1215,7 +1205,7 @@ pub mod foo { "foo", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostFoo::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -1236,7 +1226,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } @@ -1247,7 +1236,7 @@ pub mod exports { #[allow(clippy::all)] pub mod uses_resource_transitively { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::super::super::super::foo::foo::transitive_interface_with_resource::Foo; pub struct Guest { handle: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/resources-import_tracing_async.rs b/crates/component-macro/tests/expanded/resources-import_tracing_async.rs index 3a5f6ed8aea2..5332127243bc 100644 --- a/crates/component-macro/tests/expanded/resources-import_tracing_async.rs +++ b/crates/component-macro/tests/expanded/resources-import_tracing_async.rs @@ -1,5 +1,5 @@ pub enum WorldResource {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostWorldResource { async fn new(&mut self) -> wasmtime::component::Resource; async fn foo(&mut self, self_: wasmtime::component::Resource) -> (); @@ -9,7 +9,6 @@ pub trait HostWorldResource { rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } -#[wasmtime::component::__internal::async_trait] impl<_T: HostWorldResource + ?Sized + Send> HostWorldResource for &mut _T { async fn new(&mut self) -> wasmtime::component::Resource { HostWorldResource::new(*self).await @@ -130,7 +129,7 @@ pub struct TheWorld { interface1: exports::foo::foo::uses_resource_transitively::Guest, some_world_func2: wasmtime::component::Func, } -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait TheWorldImports: Send + HostWorldResource { async fn some_world_func(&mut self) -> wasmtime::component::Resource; } @@ -146,7 +145,6 @@ where { type Host = O; } -#[wasmtime::component::__internal::async_trait] impl<_T: TheWorldImports + ?Sized + Send> TheWorldImports for &mut _T { async fn some_world_func(&mut self) -> wasmtime::component::Resource { TheWorldImports::some_world_func(*self).await @@ -265,7 +263,7 @@ const _: () = { "world-resource", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostWorldResource::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -436,9 +434,9 @@ pub mod foo { #[allow(clippy::all)] pub mod resources { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum Bar {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostBar { async fn new(&mut self) -> wasmtime::component::Resource; async fn static_a(&mut self) -> u32; @@ -451,7 +449,6 @@ pub mod foo { rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostBar + ?Sized + Send> HostBar for &mut _T { async fn new(&mut self) -> wasmtime::component::Resource { HostBar::new(*self).await @@ -527,7 +524,7 @@ pub mod foo { 4 == < SomeHandle as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostBar { async fn bar_own_arg( &mut self, @@ -617,7 +614,7 @@ pub mod foo { "bar", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostBar::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -1240,7 +1237,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn bar_own_arg( &mut self, @@ -1348,16 +1344,15 @@ pub mod foo { #[allow(clippy::all)] pub mod long_use_chain1 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum A {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostA { async fn drop( &mut self, rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostA + ?Sized + Send> HostA for &mut _T { async fn drop( &mut self, @@ -1366,7 +1361,7 @@ pub mod foo { HostA::drop(*self, rep).await } } - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostA {} pub trait GetHost< T, @@ -1392,7 +1387,7 @@ pub mod foo { "a", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostA::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -1413,15 +1408,14 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } #[allow(clippy::all)] pub mod long_use_chain2 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::foo::foo::long_use_chain1::A; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -1455,15 +1449,14 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } #[allow(clippy::all)] pub mod long_use_chain3 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::foo::foo::long_use_chain2::A; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -1497,15 +1490,14 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } #[allow(clippy::all)] pub mod long_use_chain4 { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type A = super::super::super::foo::foo::long_use_chain3::A; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn foo(&mut self) -> wasmtime::component::Resource; } @@ -1564,7 +1556,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn foo(&mut self) -> wasmtime::component::Resource { Host::foo(*self).await @@ -1574,16 +1565,15 @@ pub mod foo { #[allow(clippy::all)] pub mod transitive_interface_with_resource { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub enum Foo {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostFoo { async fn drop( &mut self, rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostFoo + ?Sized + Send> HostFoo for &mut _T { async fn drop( &mut self, @@ -1592,7 +1582,7 @@ pub mod foo { HostFoo::drop(*self, rep).await } } - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostFoo {} pub trait GetHost< T, @@ -1619,7 +1609,7 @@ pub mod foo { "foo", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostFoo::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -1640,7 +1630,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } @@ -1651,7 +1640,7 @@ pub mod exports { #[allow(clippy::all)] pub mod uses_resource_transitively { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::super::super::super::foo::foo::transitive_interface_with_resource::Foo; pub struct Guest { handle: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/share-types.rs b/crates/component-macro/tests/expanded/share-types.rs index 2e7bd33dfa35..7d3d2b33c093 100644 --- a/crates/component-macro/tests/expanded/share-types.rs +++ b/crates/component-macro/tests/expanded/share-types.rs @@ -186,7 +186,7 @@ pub mod foo { #[allow(clippy::all)] pub mod http_types { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -261,7 +261,7 @@ pub mod foo { #[allow(clippy::all)] pub mod http_fetch { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Request = super::foo::foo::http_types::Request; const _: () = { assert!(8 == < Request as wasmtime::component::ComponentType >::SIZE32); @@ -321,7 +321,7 @@ pub mod exports { #[allow(clippy::all)] pub mod http_handler { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Request = super::super::foo::foo::http_types::Request; const _: () = { assert!(8 == < Request as wasmtime::component::ComponentType >::SIZE32); diff --git a/crates/component-macro/tests/expanded/share-types_async.rs b/crates/component-macro/tests/expanded/share-types_async.rs index a622e2d7eb80..b6f3d4e9b6b5 100644 --- a/crates/component-macro/tests/expanded/share-types_async.rs +++ b/crates/component-macro/tests/expanded/share-types_async.rs @@ -193,7 +193,7 @@ pub mod foo { #[allow(clippy::all)] pub mod http_types { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -232,7 +232,7 @@ pub mod foo { 4 == < Response as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -266,7 +266,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } @@ -274,7 +273,7 @@ pub mod foo { #[allow(clippy::all)] pub mod http_fetch { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Request = super::foo::foo::http_types::Request; const _: () = { assert!(8 == < Request as wasmtime::component::ComponentType >::SIZE32); @@ -285,7 +284,7 @@ pub mod http_fetch { assert!(8 == < Response as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Response as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn fetch_request(&mut self, request: Request) -> Response; } @@ -331,7 +330,6 @@ pub mod http_fetch { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn fetch_request(&mut self, request: Request) -> Response { Host::fetch_request(*self, request).await @@ -342,7 +340,7 @@ pub mod exports { #[allow(clippy::all)] pub mod http_handler { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Request = super::super::foo::foo::http_types::Request; const _: () = { assert!(8 == < Request as wasmtime::component::ComponentType >::SIZE32); diff --git a/crates/component-macro/tests/expanded/share-types_tracing_async.rs b/crates/component-macro/tests/expanded/share-types_tracing_async.rs index 67c7eaf1646d..be08b82994fa 100644 --- a/crates/component-macro/tests/expanded/share-types_tracing_async.rs +++ b/crates/component-macro/tests/expanded/share-types_tracing_async.rs @@ -193,7 +193,7 @@ pub mod foo { #[allow(clippy::all)] pub mod http_types { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -232,7 +232,7 @@ pub mod foo { 4 == < Response as wasmtime::component::ComponentType >::ALIGN32 ); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -266,7 +266,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } @@ -274,7 +273,7 @@ pub mod foo { #[allow(clippy::all)] pub mod http_fetch { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Request = super::foo::foo::http_types::Request; const _: () = { assert!(8 == < Request as wasmtime::component::ComponentType >::SIZE32); @@ -285,7 +284,7 @@ pub mod http_fetch { assert!(8 == < Response as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Response as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn fetch_request(&mut self, request: Request) -> Response; } @@ -347,7 +346,6 @@ pub mod http_fetch { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn fetch_request(&mut self, request: Request) -> Response { Host::fetch_request(*self, request).await @@ -358,7 +356,7 @@ pub mod exports { #[allow(clippy::all)] pub mod http_handler { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Request = super::super::foo::foo::http_types::Request; const _: () = { assert!(8 == < Request as wasmtime::component::ComponentType >::SIZE32); diff --git a/crates/component-macro/tests/expanded/simple-functions.rs b/crates/component-macro/tests/expanded/simple-functions.rs index 16274afb8f98..9b4a809d9713 100644 --- a/crates/component-macro/tests/expanded/simple-functions.rs +++ b/crates/component-macro/tests/expanded/simple-functions.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod simple { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { fn f1(&mut self) -> (); fn f2(&mut self, a: u32) -> (); @@ -305,7 +305,7 @@ pub mod exports { #[allow(clippy::all)] pub mod simple { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { f1: wasmtime::component::Func, f2: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/simple-functions_async.rs b/crates/component-macro/tests/expanded/simple-functions_async.rs index eb10075d88c8..8f564e80ae1d 100644 --- a/crates/component-macro/tests/expanded/simple-functions_async.rs +++ b/crates/component-macro/tests/expanded/simple-functions_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod simple { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn f1(&mut self) -> (); async fn f2(&mut self, a: u32) -> (); @@ -300,7 +300,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn f1(&mut self) -> () { Host::f1(*self).await @@ -330,7 +329,7 @@ pub mod exports { #[allow(clippy::all)] pub mod simple { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { f1: wasmtime::component::Func, f2: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs b/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs index 16d28903eab0..d9771b87beae 100644 --- a/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs +++ b/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod simple { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn f1(&mut self) -> (); async fn f2(&mut self, a: u32) -> (); @@ -388,7 +388,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn f1(&mut self) -> () { Host::f1(*self).await @@ -418,7 +417,7 @@ pub mod exports { #[allow(clippy::all)] pub mod simple { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { f1: wasmtime::component::Func, f2: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/simple-lists.rs b/crates/component-macro/tests/expanded/simple-lists.rs index 0215d464ac38..ddd44d6cca17 100644 --- a/crates/component-macro/tests/expanded/simple-lists.rs +++ b/crates/component-macro/tests/expanded/simple-lists.rs @@ -187,7 +187,7 @@ pub mod foo { #[allow(clippy::all)] pub mod simple_lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { fn simple_list1( &mut self, @@ -332,7 +332,7 @@ pub mod exports { #[allow(clippy::all)] pub mod simple_lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { simple_list1: wasmtime::component::Func, simple_list2: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/simple-lists_async.rs b/crates/component-macro/tests/expanded/simple-lists_async.rs index e04e3e3299ff..d1ddd48e69dd 100644 --- a/crates/component-macro/tests/expanded/simple-lists_async.rs +++ b/crates/component-macro/tests/expanded/simple-lists_async.rs @@ -194,8 +194,8 @@ pub mod foo { #[allow(clippy::all)] pub mod simple_lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn simple_list1( &mut self, @@ -314,7 +314,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn simple_list1( &mut self, @@ -357,7 +356,7 @@ pub mod exports { #[allow(clippy::all)] pub mod simple_lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { simple_list1: wasmtime::component::Func, simple_list2: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs b/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs index 69fd96ffeba3..5170ff1563d6 100644 --- a/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs +++ b/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs @@ -194,8 +194,8 @@ pub mod foo { #[allow(clippy::all)] pub mod simple_lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn simple_list1( &mut self, @@ -375,7 +375,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn simple_list1( &mut self, @@ -418,7 +417,7 @@ pub mod exports { #[allow(clippy::all)] pub mod simple_lists { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { simple_list1: wasmtime::component::Func, simple_list2: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/simple-wasi.rs b/crates/component-macro/tests/expanded/simple-wasi.rs index 96d4a0bc2a94..2feddc5520e8 100644 --- a/crates/component-macro/tests/expanded/simple-wasi.rs +++ b/crates/component-macro/tests/expanded/simple-wasi.rs @@ -173,7 +173,7 @@ pub mod foo { #[allow(clippy::all)] pub mod wasi_filesystem { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -295,7 +295,7 @@ pub mod foo { #[allow(clippy::all)] pub mod wall_clock { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host {} pub trait GetHost< T, diff --git a/crates/component-macro/tests/expanded/simple-wasi_async.rs b/crates/component-macro/tests/expanded/simple-wasi_async.rs index 21f0e82575b3..5b95ff182556 100644 --- a/crates/component-macro/tests/expanded/simple-wasi_async.rs +++ b/crates/component-macro/tests/expanded/simple-wasi_async.rs @@ -180,7 +180,7 @@ pub mod foo { #[allow(clippy::all)] pub mod wasi_filesystem { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -242,7 +242,7 @@ pub mod foo { assert!(1 == < Errno as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Errno as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn create_directory_at(&mut self) -> Result<(), Errno>; async fn stat(&mut self) -> Result; @@ -299,7 +299,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn create_directory_at(&mut self) -> Result<(), Errno> { Host::create_directory_at(*self).await @@ -312,8 +311,8 @@ pub mod foo { #[allow(clippy::all)] pub mod wall_clock { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -347,7 +346,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/component-macro/tests/expanded/simple-wasi_tracing_async.rs b/crates/component-macro/tests/expanded/simple-wasi_tracing_async.rs index 6c6a92ca2eb4..17b68e5c2c0e 100644 --- a/crates/component-macro/tests/expanded/simple-wasi_tracing_async.rs +++ b/crates/component-macro/tests/expanded/simple-wasi_tracing_async.rs @@ -180,7 +180,7 @@ pub mod foo { #[allow(clippy::all)] pub mod wasi_filesystem { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -242,7 +242,7 @@ pub mod foo { assert!(1 == < Errno as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Errno as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn create_directory_at(&mut self) -> Result<(), Errno>; async fn stat(&mut self) -> Result; @@ -325,7 +325,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn create_directory_at(&mut self) -> Result<(), Errno> { Host::create_directory_at(*self).await @@ -338,8 +337,8 @@ pub mod foo { #[allow(clippy::all)] pub mod wall_clock { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -373,7 +372,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/component-macro/tests/expanded/small-anonymous.rs b/crates/component-macro/tests/expanded/small-anonymous.rs index baa6463b58e8..f14766767851 100644 --- a/crates/component-macro/tests/expanded/small-anonymous.rs +++ b/crates/component-macro/tests/expanded/small-anonymous.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod anon { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -288,7 +288,7 @@ pub mod exports { #[allow(clippy::all)] pub mod anon { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/small-anonymous_async.rs b/crates/component-macro/tests/expanded/small-anonymous_async.rs index 94a45355742e..239bca6be1e2 100644 --- a/crates/component-macro/tests/expanded/small-anonymous_async.rs +++ b/crates/component-macro/tests/expanded/small-anonymous_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod anon { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -238,7 +238,7 @@ pub mod foo { assert!(1 == < Error as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Error as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn option_test( &mut self, @@ -286,7 +286,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn option_test( &mut self, @@ -303,7 +302,7 @@ pub mod exports { #[allow(clippy::all)] pub mod anon { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs b/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs index 113ccf2700ae..1226081d5fad 100644 --- a/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs +++ b/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod anon { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -238,7 +238,7 @@ pub mod foo { assert!(1 == < Error as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Error as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn option_test( &mut self, @@ -299,7 +299,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn option_test( &mut self, @@ -316,7 +315,7 @@ pub mod exports { #[allow(clippy::all)] pub mod anon { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/smoke-export.rs b/crates/component-macro/tests/expanded/smoke-export.rs index 9a9f8a25b18e..498170dd624f 100644 --- a/crates/component-macro/tests/expanded/smoke-export.rs +++ b/crates/component-macro/tests/expanded/smoke-export.rs @@ -174,7 +174,7 @@ pub mod exports { #[allow(clippy::all)] pub mod the_name { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { y: wasmtime::component::Func, } diff --git a/crates/component-macro/tests/expanded/smoke-export_async.rs b/crates/component-macro/tests/expanded/smoke-export_async.rs index e21b8232c855..1fe656ec53d9 100644 --- a/crates/component-macro/tests/expanded/smoke-export_async.rs +++ b/crates/component-macro/tests/expanded/smoke-export_async.rs @@ -180,7 +180,7 @@ pub mod exports { #[allow(clippy::all)] pub mod the_name { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { y: wasmtime::component::Func, } diff --git a/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs b/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs index 9427cbcaa928..c4ef584cdc22 100644 --- a/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs +++ b/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs @@ -180,7 +180,7 @@ pub mod exports { #[allow(clippy::all)] pub mod the_name { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { y: wasmtime::component::Func, } diff --git a/crates/component-macro/tests/expanded/smoke.rs b/crates/component-macro/tests/expanded/smoke.rs index f455ece5d3f7..97e1b0fe51b6 100644 --- a/crates/component-macro/tests/expanded/smoke.rs +++ b/crates/component-macro/tests/expanded/smoke.rs @@ -170,7 +170,7 @@ const _: () = { #[allow(clippy::all)] pub mod imports { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { fn y(&mut self) -> (); } diff --git a/crates/component-macro/tests/expanded/smoke_async.rs b/crates/component-macro/tests/expanded/smoke_async.rs index bfc70a8646fb..441d2f7eb40a 100644 --- a/crates/component-macro/tests/expanded/smoke_async.rs +++ b/crates/component-macro/tests/expanded/smoke_async.rs @@ -177,8 +177,8 @@ const _: () = { #[allow(clippy::all)] pub mod imports { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn y(&mut self) -> (); } @@ -224,7 +224,6 @@ pub mod imports { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn y(&mut self) -> () { Host::y(*self).await diff --git a/crates/component-macro/tests/expanded/smoke_tracing_async.rs b/crates/component-macro/tests/expanded/smoke_tracing_async.rs index a3cd2582d13a..02b979f4a7bb 100644 --- a/crates/component-macro/tests/expanded/smoke_tracing_async.rs +++ b/crates/component-macro/tests/expanded/smoke_tracing_async.rs @@ -177,8 +177,8 @@ const _: () = { #[allow(clippy::all)] pub mod imports { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn y(&mut self) -> (); } @@ -237,7 +237,6 @@ pub mod imports { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn y(&mut self) -> () { Host::y(*self).await diff --git a/crates/component-macro/tests/expanded/strings.rs b/crates/component-macro/tests/expanded/strings.rs index 743d69f5044c..40b22082c941 100644 --- a/crates/component-macro/tests/expanded/strings.rs +++ b/crates/component-macro/tests/expanded/strings.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod strings { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub trait Host { fn a(&mut self, x: wasmtime::component::__internal::String) -> (); fn b(&mut self) -> wasmtime::component::__internal::String; @@ -283,7 +283,7 @@ pub mod exports { #[allow(clippy::all)] pub mod strings { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { a: wasmtime::component::Func, b: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/strings_async.rs b/crates/component-macro/tests/expanded/strings_async.rs index a597bb7f52ac..4d448ab0a345 100644 --- a/crates/component-macro/tests/expanded/strings_async.rs +++ b/crates/component-macro/tests/expanded/strings_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod strings { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a(&mut self, x: wasmtime::component::__internal::String) -> (); async fn b(&mut self) -> wasmtime::component::__internal::String; @@ -277,7 +277,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a(&mut self, x: wasmtime::component::__internal::String) -> () { Host::a(*self, x).await @@ -302,7 +301,7 @@ pub mod exports { #[allow(clippy::all)] pub mod strings { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { a: wasmtime::component::Func, b: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/strings_tracing_async.rs b/crates/component-macro/tests/expanded/strings_tracing_async.rs index c7d2ae7f767f..6e19b15240a3 100644 --- a/crates/component-macro/tests/expanded/strings_tracing_async.rs +++ b/crates/component-macro/tests/expanded/strings_tracing_async.rs @@ -192,8 +192,8 @@ pub mod foo { #[allow(clippy::all)] pub mod strings { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - #[wasmtime::component::__internal::async_trait] + use wasmtime::component::__internal::{anyhow, Box}; + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a(&mut self, x: wasmtime::component::__internal::String) -> (); async fn b(&mut self) -> wasmtime::component::__internal::String; @@ -322,7 +322,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a(&mut self, x: wasmtime::component::__internal::String) -> () { Host::a(*self, x).await @@ -347,7 +346,7 @@ pub mod exports { #[allow(clippy::all)] pub mod strings { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub struct Guest { a: wasmtime::component::Func, b: wasmtime::component::Func, diff --git a/crates/component-macro/tests/expanded/unstable-features.rs b/crates/component-macro/tests/expanded/unstable-features.rs index c252a541394d..9ac28a24a454 100644 --- a/crates/component-macro/tests/expanded/unstable-features.rs +++ b/crates/component-macro/tests/expanded/unstable-features.rs @@ -343,7 +343,7 @@ pub mod foo { #[allow(clippy::all)] pub mod the_interface { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; /// Link-time configurations. #[derive(Clone, Debug, Default)] pub struct LinkOptions { diff --git a/crates/component-macro/tests/expanded/unstable-features_async.rs b/crates/component-macro/tests/expanded/unstable-features_async.rs index 1b0da66840b2..23686a38346e 100644 --- a/crates/component-macro/tests/expanded/unstable-features_async.rs +++ b/crates/component-macro/tests/expanded/unstable-features_async.rs @@ -62,7 +62,7 @@ impl LinkOptions { } } pub enum Baz {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostBaz { async fn foo(&mut self, self_: wasmtime::component::Resource) -> (); async fn drop( @@ -70,7 +70,6 @@ pub trait HostBaz { rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } -#[wasmtime::component::__internal::async_trait] impl<_T: HostBaz + ?Sized + Send> HostBaz for &mut _T { async fn foo(&mut self, self_: wasmtime::component::Resource) -> () { HostBaz::foo(*self, self_).await @@ -196,7 +195,7 @@ pub struct TheWorldIndices {} /// [`Component`]: wasmtime::component::Component /// [`Linker`]: wasmtime::component::Linker pub struct TheWorld {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait TheWorldImports: Send + HostBaz { async fn foo(&mut self) -> (); } @@ -212,7 +211,6 @@ where { type Host = O; } -#[wasmtime::component::__internal::async_trait] impl<_T: TheWorldImports + ?Sized + Send> TheWorldImports for &mut _T { async fn foo(&mut self) -> () { TheWorldImports::foo(*self).await @@ -300,7 +298,7 @@ const _: () = { "baz", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostBaz::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -370,7 +368,7 @@ pub mod foo { #[allow(clippy::all)] pub mod the_interface { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; /// Link-time configurations. #[derive(Clone, Debug, Default)] pub struct LinkOptions { @@ -411,7 +409,7 @@ pub mod foo { } } pub enum Bar {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostBar { async fn foo(&mut self, self_: wasmtime::component::Resource) -> (); async fn drop( @@ -419,7 +417,6 @@ pub mod foo { rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostBar + ?Sized + Send> HostBar for &mut _T { async fn foo( &mut self, @@ -434,7 +431,7 @@ pub mod foo { HostBar::drop(*self, rep).await } } - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostBar { async fn foo(&mut self) -> (); } @@ -465,7 +462,7 @@ pub mod foo { "bar", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostBar::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -516,7 +513,6 @@ pub mod foo { { add_to_linker_get_host(linker, options, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn foo(&mut self) -> () { Host::foo(*self).await diff --git a/crates/component-macro/tests/expanded/unstable-features_tracing_async.rs b/crates/component-macro/tests/expanded/unstable-features_tracing_async.rs index d718adca7140..500bc93d285b 100644 --- a/crates/component-macro/tests/expanded/unstable-features_tracing_async.rs +++ b/crates/component-macro/tests/expanded/unstable-features_tracing_async.rs @@ -62,7 +62,7 @@ impl LinkOptions { } } pub enum Baz {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostBaz { async fn foo(&mut self, self_: wasmtime::component::Resource) -> (); async fn drop( @@ -70,7 +70,6 @@ pub trait HostBaz { rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } -#[wasmtime::component::__internal::async_trait] impl<_T: HostBaz + ?Sized + Send> HostBaz for &mut _T { async fn foo(&mut self, self_: wasmtime::component::Resource) -> () { HostBaz::foo(*self, self_).await @@ -196,7 +195,7 @@ pub struct TheWorldIndices {} /// [`Component`]: wasmtime::component::Component /// [`Linker`]: wasmtime::component::Linker pub struct TheWorld {} -#[wasmtime::component::__internal::async_trait] +#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait TheWorldImports: Send + HostBaz { async fn foo(&mut self) -> (); } @@ -212,7 +211,6 @@ where { type Host = O; } -#[wasmtime::component::__internal::async_trait] impl<_T: TheWorldImports + ?Sized + Send> TheWorldImports for &mut _T { async fn foo(&mut self) -> () { TheWorldImports::foo(*self).await @@ -300,7 +298,7 @@ const _: () = { "baz", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostBaz::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -399,7 +397,7 @@ pub mod foo { #[allow(clippy::all)] pub mod the_interface { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; /// Link-time configurations. #[derive(Clone, Debug, Default)] pub struct LinkOptions { @@ -440,7 +438,7 @@ pub mod foo { } } pub enum Bar {} - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait HostBar { async fn foo(&mut self, self_: wasmtime::component::Resource) -> (); async fn drop( @@ -448,7 +446,6 @@ pub mod foo { rep: wasmtime::component::Resource, ) -> wasmtime::Result<()>; } - #[wasmtime::component::__internal::async_trait] impl<_T: HostBar + ?Sized + Send> HostBar for &mut _T { async fn foo( &mut self, @@ -463,7 +460,7 @@ pub mod foo { HostBar::drop(*self, rep).await } } - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send + HostBar { async fn foo(&mut self) -> (); } @@ -494,7 +491,7 @@ pub mod foo { "bar", wasmtime::component::ResourceType::host::(), move |mut store, rep| { - std::boxed::Box::new(async move { + wasmtime::component::__internal::Box::new(async move { HostBar::drop( &mut host_getter(store.data_mut()), wasmtime::component::Resource::new_own(rep), @@ -574,7 +571,6 @@ pub mod foo { { add_to_linker_get_host(linker, options, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn foo(&mut self) -> () { Host::foo(*self).await diff --git a/crates/component-macro/tests/expanded/unversioned-foo.rs b/crates/component-macro/tests/expanded/unversioned-foo.rs index 20b394cf1bfb..bec71942c97c 100644 --- a/crates/component-macro/tests/expanded/unversioned-foo.rs +++ b/crates/component-macro/tests/expanded/unversioned-foo.rs @@ -172,7 +172,7 @@ pub mod foo { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/unversioned-foo_async.rs b/crates/component-macro/tests/expanded/unversioned-foo_async.rs index fc83094285b6..c7c5c8d9d53a 100644 --- a/crates/component-macro/tests/expanded/unversioned-foo_async.rs +++ b/crates/component-macro/tests/expanded/unversioned-foo_async.rs @@ -179,7 +179,7 @@ pub mod foo { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -208,7 +208,7 @@ pub mod foo { assert!(12 == < Error as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Error as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn g(&mut self) -> Result<(), Error>; } @@ -254,7 +254,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn g(&mut self) -> Result<(), Error> { Host::g(*self).await diff --git a/crates/component-macro/tests/expanded/unversioned-foo_tracing_async.rs b/crates/component-macro/tests/expanded/unversioned-foo_tracing_async.rs index 062ca5b258f7..489b1855dd81 100644 --- a/crates/component-macro/tests/expanded/unversioned-foo_tracing_async.rs +++ b/crates/component-macro/tests/expanded/unversioned-foo_tracing_async.rs @@ -179,7 +179,7 @@ pub mod foo { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -208,7 +208,7 @@ pub mod foo { assert!(12 == < Error as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < Error as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn g(&mut self) -> Result<(), Error>; } @@ -267,7 +267,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn g(&mut self) -> Result<(), Error> { Host::g(*self).await diff --git a/crates/component-macro/tests/expanded/use-paths.rs b/crates/component-macro/tests/expanded/use-paths.rs index 42e5e053aebc..10b39e821120 100644 --- a/crates/component-macro/tests/expanded/use-paths.rs +++ b/crates/component-macro/tests/expanded/use-paths.rs @@ -175,7 +175,7 @@ pub mod foo { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -239,7 +239,7 @@ pub mod foo { #[allow(clippy::all)] pub mod b { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::super::super::foo::foo::a::Foo; const _: () = { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); @@ -293,7 +293,7 @@ pub mod foo { #[allow(clippy::all)] pub mod c { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::super::super::foo::foo::b::Foo; const _: () = { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); @@ -349,7 +349,7 @@ pub mod foo { #[allow(clippy::all)] pub mod d { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::foo::foo::c::Foo; const _: () = { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); diff --git a/crates/component-macro/tests/expanded/use-paths_async.rs b/crates/component-macro/tests/expanded/use-paths_async.rs index 0aaae7b509aa..43033c158764 100644 --- a/crates/component-macro/tests/expanded/use-paths_async.rs +++ b/crates/component-macro/tests/expanded/use-paths_async.rs @@ -183,7 +183,7 @@ pub mod foo { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -199,7 +199,7 @@ pub mod foo { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Foo as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a(&mut self) -> Foo; } @@ -245,7 +245,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a(&mut self) -> Foo { Host::a(*self).await @@ -255,13 +254,13 @@ pub mod foo { #[allow(clippy::all)] pub mod b { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::super::super::foo::foo::a::Foo; const _: () = { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Foo as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a(&mut self) -> Foo; } @@ -307,7 +306,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a(&mut self) -> Foo { Host::a(*self).await @@ -317,13 +315,13 @@ pub mod foo { #[allow(clippy::all)] pub mod c { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::super::super::foo::foo::b::Foo; const _: () = { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Foo as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a(&mut self) -> Foo; } @@ -369,7 +367,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a(&mut self) -> Foo { Host::a(*self).await @@ -381,13 +378,13 @@ pub mod foo { #[allow(clippy::all)] pub mod d { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::foo::foo::c::Foo; const _: () = { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Foo as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn b(&mut self) -> Foo; } @@ -433,7 +430,6 @@ pub mod d { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn b(&mut self) -> Foo { Host::b(*self).await diff --git a/crates/component-macro/tests/expanded/use-paths_tracing_async.rs b/crates/component-macro/tests/expanded/use-paths_tracing_async.rs index 3affa9c4cbf7..6f5f5a69608c 100644 --- a/crates/component-macro/tests/expanded/use-paths_tracing_async.rs +++ b/crates/component-macro/tests/expanded/use-paths_tracing_async.rs @@ -183,7 +183,7 @@ pub mod foo { #[allow(clippy::all)] pub mod a { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -199,7 +199,7 @@ pub mod foo { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Foo as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a(&mut self) -> Foo; } @@ -258,7 +258,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a(&mut self) -> Foo { Host::a(*self).await @@ -268,13 +267,13 @@ pub mod foo { #[allow(clippy::all)] pub mod b { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::super::super::foo::foo::a::Foo; const _: () = { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Foo as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a(&mut self) -> Foo; } @@ -333,7 +332,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a(&mut self) -> Foo { Host::a(*self).await @@ -343,13 +341,13 @@ pub mod foo { #[allow(clippy::all)] pub mod c { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::super::super::foo::foo::b::Foo; const _: () = { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Foo as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn a(&mut self) -> Foo; } @@ -408,7 +406,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn a(&mut self) -> Foo { Host::a(*self).await @@ -420,13 +417,13 @@ pub mod foo { #[allow(clippy::all)] pub mod d { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type Foo = super::foo::foo::c::Foo; const _: () = { assert!(0 == < Foo as wasmtime::component::ComponentType >::SIZE32); assert!(1 == < Foo as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn b(&mut self) -> Foo; } @@ -485,7 +482,6 @@ pub mod d { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn b(&mut self) -> Foo { Host::b(*self).await diff --git a/crates/component-macro/tests/expanded/variants.rs b/crates/component-macro/tests/expanded/variants.rs index 3e67dc0d976d..86e8d659eae5 100644 --- a/crates/component-macro/tests/expanded/variants.rs +++ b/crates/component-macro/tests/expanded/variants.rs @@ -185,7 +185,7 @@ pub mod foo { #[allow(clippy::all)] pub mod variants { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -928,7 +928,7 @@ pub mod exports { #[allow(clippy::all)] pub mod variants { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/variants_async.rs b/crates/component-macro/tests/expanded/variants_async.rs index 36cf76daa580..bf9403156018 100644 --- a/crates/component-macro/tests/expanded/variants_async.rs +++ b/crates/component-macro/tests/expanded/variants_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod variants { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -465,7 +465,7 @@ pub mod foo { assert!(12 == < IsClone as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < IsClone as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn e1_arg(&mut self, x: E1) -> (); async fn e1_result(&mut self) -> E1; @@ -862,7 +862,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn e1_arg(&mut self, x: E1) -> () { Host::e1_arg(*self, x).await @@ -988,7 +987,7 @@ pub mod exports { #[allow(clippy::all)] pub mod variants { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/variants_tracing_async.rs b/crates/component-macro/tests/expanded/variants_tracing_async.rs index 792fd5815987..089de949b552 100644 --- a/crates/component-macro/tests/expanded/variants_tracing_async.rs +++ b/crates/component-macro/tests/expanded/variants_tracing_async.rs @@ -192,7 +192,7 @@ pub mod foo { #[allow(clippy::all)] pub mod variants { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] @@ -465,7 +465,7 @@ pub mod foo { assert!(12 == < IsClone as wasmtime::component::ComponentType >::SIZE32); assert!(4 == < IsClone as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send { async fn e1_arg(&mut self, x: E1) -> (); async fn e1_result(&mut self) -> E1; @@ -1186,7 +1186,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T { async fn e1_arg(&mut self, x: E1) -> () { Host::e1_arg(*self, x).await @@ -1312,7 +1311,7 @@ pub mod exports { #[allow(clippy::all)] pub mod variants { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; #[derive(wasmtime::component::ComponentType)] #[derive(wasmtime::component::Lift)] #[derive(wasmtime::component::Lower)] diff --git a/crates/component-macro/tests/expanded/wat.rs b/crates/component-macro/tests/expanded/wat.rs index 14da6ff9efb6..de05578b9da7 100644 --- a/crates/component-macro/tests/expanded/wat.rs +++ b/crates/component-macro/tests/expanded/wat.rs @@ -180,7 +180,7 @@ pub mod exports { #[allow(clippy::all)] pub mod this_name_is_duplicated { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type ThisNameIsDuplicated = wasmtime::component::ResourceAny; pub struct GuestThisNameIsDuplicated<'a> { funcs: &'a Guest, diff --git a/crates/component-macro/tests/expanded/wat_async.rs b/crates/component-macro/tests/expanded/wat_async.rs index cad73611fe21..17864d24d90c 100644 --- a/crates/component-macro/tests/expanded/wat_async.rs +++ b/crates/component-macro/tests/expanded/wat_async.rs @@ -186,7 +186,7 @@ pub mod exports { #[allow(clippy::all)] pub mod this_name_is_duplicated { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type ThisNameIsDuplicated = wasmtime::component::ResourceAny; pub struct GuestThisNameIsDuplicated<'a> { funcs: &'a Guest, diff --git a/crates/component-macro/tests/expanded/wat_tracing_async.rs b/crates/component-macro/tests/expanded/wat_tracing_async.rs index cad73611fe21..17864d24d90c 100644 --- a/crates/component-macro/tests/expanded/wat_tracing_async.rs +++ b/crates/component-macro/tests/expanded/wat_tracing_async.rs @@ -186,7 +186,7 @@ pub mod exports { #[allow(clippy::all)] pub mod this_name_is_duplicated { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type ThisNameIsDuplicated = wasmtime::component::ResourceAny; pub struct GuestThisNameIsDuplicated<'a> { funcs: &'a Guest, diff --git a/crates/component-macro/tests/expanded/worlds-with-types.rs b/crates/component-macro/tests/expanded/worlds-with-types.rs index 2fd790395a13..216976fd4272 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types.rs @@ -222,7 +222,7 @@ pub mod foo { #[allow(clippy::all)] pub mod i { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type T = u16; const _: () = { assert!(2 == < T as wasmtime::component::ComponentType >::SIZE32); diff --git a/crates/component-macro/tests/expanded/worlds-with-types_async.rs b/crates/component-macro/tests/expanded/worlds-with-types_async.rs index 48f42f3a99b6..c5c1b0f3f6c0 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types_async.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types_async.rs @@ -232,13 +232,13 @@ pub mod foo { #[allow(clippy::all)] pub mod i { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type T = u16; const _: () = { assert!(2 == < T as wasmtime::component::ComponentType >::SIZE32); assert!(2 == < T as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -272,7 +272,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs b/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs index 63ed3ffff6e4..6970a67b8721 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs @@ -240,13 +240,13 @@ pub mod foo { #[allow(clippy::all)] pub mod i { #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; + use wasmtime::component::__internal::{anyhow, Box}; pub type T = u16; const _: () = { assert!(2 == < T as wasmtime::component::ComponentType >::SIZE32); assert!(2 == < T as wasmtime::component::ComponentType >::ALIGN32); }; - #[wasmtime::component::__internal::async_trait] + #[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)] pub trait Host: Send {} pub trait GetHost< T, @@ -280,7 +280,6 @@ pub mod foo { { add_to_linker_get_host(linker, get) } - #[wasmtime::component::__internal::async_trait] impl<_T: Host + ?Sized + Send> Host for &mut _T {} } } diff --git a/crates/cranelift/src/debug/transform/attr.rs b/crates/cranelift/src/debug/transform/attr.rs index f3de8a301045..4b753e175a3a 100644 --- a/crates/cranelift/src/debug/transform/attr.rs +++ b/crates/cranelift/src/debug/transform/attr.rs @@ -1,22 +1,36 @@ +use crate::debug::transform::utils::resolve_die_ref; +use crate::debug::Reader; + use super::address_transform::AddressTransform; use super::expression::{compile_expression, CompiledExpression, FunctionFrameInfo}; use super::range_info_builder::RangeInfoBuilder; use super::refs::{PendingDebugInfoRefs, PendingUnitRefs}; -use super::{Reader, TransformError}; +use super::unit::InheritedAttr; +use super::{dbi_log, TransformError}; use anyhow::{bail, Error}; use cranelift_codegen::isa::TargetIsa; -use gimli::{write, AttributeValue, DebugLineOffset, DebuggingInformationEntry, Unit}; +use gimli::{ + write, AttributeValue, DebugLineOffset, DebuggingInformationEntry, Dwarf, Unit, UnitOffset, +}; #[derive(Debug)] -pub(crate) enum FileAttributeContext<'a> { +pub(crate) enum EntryAttributesContext<'a> { Root(Option), Children { + depth: usize, + subprograms: &'a mut InheritedAttr, file_map: &'a [write::FileId], file_index_base: u64, frame_base: Option<&'a CompiledExpression>, }, } +#[derive(Debug)] +pub struct SubprogramContext { + pub obj_ptr: UnitOffset, + pub param_num: isize, +} + fn is_exprloc_to_loclist_allowed(attr_name: gimli::constants::DwAt) -> bool { match attr_name { gimli::DW_AT_location @@ -32,25 +46,22 @@ fn is_exprloc_to_loclist_allowed(attr_name: gimli::constants::DwAt) -> bool { } } -pub(crate) fn clone_die_attributes<'a, R>( - dwarf: &gimli::Dwarf, - unit: &Unit, - entry: &DebuggingInformationEntry, +pub(crate) fn clone_die_attributes<'a>( + dwarf: &gimli::Dwarf>, + unit: &Unit>, + entry: &DebuggingInformationEntry>, addr_tr: &'a AddressTransform, frame_info: Option<&FunctionFrameInfo>, out_unit: &mut write::Unit, - current_scope_id: write::UnitEntryId, + out_entry_id: write::UnitEntryId, subprogram_range_builder: Option, scope_ranges: Option<&Vec<(u64, u64)>>, out_strings: &mut write::StringTable, pending_die_refs: &mut PendingUnitRefs, pending_di_refs: &mut PendingDebugInfoRefs, - file_context: FileAttributeContext<'a>, + mut attr_context: EntryAttributesContext<'a>, isa: &dyn TargetIsa, -) -> Result<(), Error> -where - R: Reader, -{ +) -> Result<(), Error> { let unit_encoding = unit.encoding(); let range_info = if let Some(subprogram_range_builder) = subprogram_range_builder { @@ -61,7 +72,10 @@ where // transformation may be incomplete. RangeInfoBuilder::from(dwarf, unit, entry)? }; - range_info.build(addr_tr, out_unit, current_scope_id); + range_info.build(addr_tr, out_unit, out_entry_id); + + let mut is_obj_ptr = false; + prepare_die_context(dwarf, unit, entry, &mut attr_context, &mut is_obj_ptr)?; let mut attrs = entry.attrs(); while let Some(attr) = attrs.next()? { @@ -70,6 +84,33 @@ where // Handled by RangeInfoBuilder. continue; } + gimli::DW_AT_object_pointer => { + // Our consumers cannot handle 'this' typed as a non-pointer (recall + // we translate all pointers to wrapper types), making it unusable. + // To remedy this, we 'strip' instance-ness off of methods by removing + // DW_AT_object_pointer and renaming 'this' to '__this'. + if let EntryAttributesContext::Children { + depth, + ref mut subprograms, + .. + } = attr_context + { + if let Some(ref mut subprogram) = subprograms.top_with_depth_mut(depth) { + // We expect this to reference a child entry in the same unit. + if let Some(unit_offs) = match attr.value() { + AttributeValue::DebugInfoRef(di_ref) => { + di_ref.to_unit_offset(&unit.header) + } + AttributeValue::UnitRef(unit_ref) => Some(unit_ref), + _ => None, + } { + subprogram.obj_ptr = unit_offs; + dbi_log!("Stripped DW_AT_object_pointer"); + continue; + } + } + } + } gimli::DW_AT_str_offsets_base | gimli::DW_AT_addr_base | gimli::DW_AT_rnglists_base @@ -84,6 +125,32 @@ where } _ => {} } + + if is_obj_ptr { + match attr.name() { + gimli::DW_AT_artificial => { + dbi_log!("Object pointer: stripped DW_AT_artificial"); + continue; + } + gimli::DW_AT_name => { + let old_name: &str = &dwarf.attr_string(unit, attr.value())?.to_string_lossy(); + let new_name = format!("__{old_name}"); + dbi_log!( + "Object pointer: renamed '{}' -> '{}'", + old_name, + new_name.as_str() + ); + + let attr_value = write::AttributeValue::StringRef(out_strings.add(new_name)); + out_unit + .get_mut(out_entry_id) + .set(gimli::DW_AT_name, attr_value); + continue; + } + _ => {} + } + } + let attr_value = attr.value(); let out_attr_value = match attr_value { AttributeValue::Addr(u) => { @@ -95,7 +162,7 @@ where let addr = addr_tr.translate(u).unwrap_or(write::Address::Constant(0)); write::AttributeValue::Address(addr) } - AttributeValue::Block(d) => write::AttributeValue::Block(d.to_slice()?.into_owned()), + AttributeValue::Block(d) => write::AttributeValue::Block(d.to_vec()), AttributeValue::Udata(u) => write::AttributeValue::Udata(u), AttributeValue::Data1(d) => write::AttributeValue::Data1(d), AttributeValue::Data2(d) => write::AttributeValue::Data2(d), @@ -104,7 +171,7 @@ where AttributeValue::Sdata(d) => write::AttributeValue::Sdata(d), AttributeValue::Flag(f) => write::AttributeValue::Flag(f), AttributeValue::DebugLineRef(line_program_offset) => { - if let FileAttributeContext::Root(o) = file_context { + if let EntryAttributesContext::Root(o) = attr_context { if o != Some(line_program_offset) { return Err(TransformError("invalid debug_line offset").into()); } @@ -114,11 +181,11 @@ where } } AttributeValue::FileIndex(i) => { - if let FileAttributeContext::Children { + if let EntryAttributesContext::Children { file_map, file_index_base, .. - } = file_context + } = attr_context { let index = usize::try_from(i - file_index_base) .ok() @@ -133,10 +200,11 @@ where return Err(TransformError("unexpected file index attribute").into()); } } + AttributeValue::String(d) => write::AttributeValue::String(d.to_vec()), AttributeValue::DebugStrRef(_) | AttributeValue::DebugStrOffsetsIndex(_) => { let s = dwarf .attr_string(unit, attr_value)? - .to_string_lossy()? + .to_string_lossy() .into_owned(); write::AttributeValue::StringRef(out_strings.add(s)) } @@ -157,7 +225,7 @@ where unit.addr_base, )?; let frame_base = - if let FileAttributeContext::Children { frame_base, .. } = file_context { + if let EntryAttributesContext::Children { frame_base, .. } = attr_context { frame_base } else { None @@ -213,7 +281,7 @@ where } AttributeValue::Exprloc(ref expr) => { let frame_base = - if let FileAttributeContext::Children { frame_base, .. } = file_context { + if let EntryAttributesContext::Children { frame_base, .. } = attr_context { frame_base } else { None @@ -292,18 +360,94 @@ where AttributeValue::Inline(e) => write::AttributeValue::Inline(e), AttributeValue::Ordering(e) => write::AttributeValue::Ordering(e), AttributeValue::UnitRef(offset) => { - pending_die_refs.insert(current_scope_id, attr.name(), offset); + pending_die_refs.insert(out_entry_id, attr.name(), offset); continue; } AttributeValue::DebugInfoRef(offset) => { - pending_di_refs.insert(current_scope_id, attr.name(), offset); + pending_di_refs.insert(out_entry_id, attr.name(), offset); continue; } - AttributeValue::String(d) => write::AttributeValue::String(d.to_slice()?.into_owned()), a => bail!("Unexpected attribute: {:?}", a), }; - let current_scope = out_unit.get_mut(current_scope_id); - current_scope.set(attr.name(), out_attr_value); + let out_entry: &mut write::DebuggingInformationEntry = out_unit.get_mut(out_entry_id); + out_entry.set(attr.name(), out_attr_value); } Ok(()) } + +fn prepare_die_context( + dwarf: &Dwarf>, + unit: &Unit>, + entry: &DebuggingInformationEntry>, + attr_context: &mut EntryAttributesContext<'_>, + is_obj_ptr: &mut bool, +) -> Result<(), Error> { + let EntryAttributesContext::Children { + depth, subprograms, .. + } = attr_context + else { + return Ok(()); + }; + + // Update the current context based on what kind of entry this is. + match entry.tag() { + gimli::DW_TAG_subprogram | gimli::DW_TAG_inlined_subroutine | gimli::DW_TAG_entry_point => { + // Push the 'context' of there being no parameters (yet). + subprograms.push( + *depth, + SubprogramContext { + obj_ptr: UnitOffset { 0: 0 }, + param_num: -1, + }, + ); + } + gimli::DW_TAG_formal_parameter => { + // Formal parameter tags can be parented by catch blocks + // and such - not just subprogram DIEs. So we need to check + // that this DIE is indeed a direct child of a subprogram. + if let Some(subprogram) = subprograms.top_with_depth_mut(*depth - 1) { + subprogram.param_num += 1; + + if subprogram.obj_ptr == entry.offset() + || is_obj_ptr_param(dwarf, unit, entry, subprogram.param_num)? + { + *is_obj_ptr = true; + } + } + } + _ => {} + } + Ok(()) +} + +fn is_obj_ptr_param( + dwarf: &Dwarf>, + unit: &Unit>, + entry: &DebuggingInformationEntry>, + param_num: isize, +) -> Result { + debug_assert!(entry.tag() == gimli::DW_TAG_formal_parameter); + + // This logic was taken loosely from LLDB. It is known + // that it is not fully correct (doesn't handle 'deduced + // this', for example). + // Q: DWARF includes DW_AT_object_pointer as we use it, + // why do we need this heuristic as well? + // A: Declarations do not include DW_AT_object_pointer. + if param_num == 0 + && entry.attr_value(gimli::DW_AT_artificial)? == Some(AttributeValue::Flag(true)) + { + // Either this has no name (declarations omit them), or its explicitly "this". + let name = entry.attr_value(gimli::DW_AT_name)?; + if name.is_none() || dwarf.attr_string(unit, name.unwrap())?.slice().eq(b"this") { + // Finally, a type check. We expect a pointer. + if let Some(type_attr) = entry.attr_value(gimli::DW_AT_type)? { + if let Some(type_die) = resolve_die_ref(unit, &type_attr)? { + return Ok(type_die.tag() == gimli::DW_TAG_pointer_type); + } + } + } + }; + + return Ok(false); +} diff --git a/crates/cranelift/src/debug/transform/debug_transform_logging.rs b/crates/cranelift/src/debug/transform/debug_transform_logging.rs index 7caee32ce798..1a56eb70a1bc 100644 --- a/crates/cranelift/src/debug/transform/debug_transform_logging.rs +++ b/crates/cranelift/src/debug/transform/debug_transform_logging.rs @@ -1,7 +1,8 @@ use crate::debug::Reader; use core::fmt; use gimli::{ - write, AttributeValue, DebuggingInformationEntry, Dwarf, LittleEndian, Unit, UnitSectionOffset, + write, AttributeValue, DebuggingInformationEntry, Dwarf, LittleEndian, Unit, UnitOffset, + UnitSectionOffset, }; macro_rules! dbi_log { @@ -39,6 +40,26 @@ pub fn log_get_cu_summary<'a>(unit: &'a Unit, usize>) -> CompileUnitS CompileUnitSummary { unit } } +pub struct DieRefSummary<'a> { + unit: &'a Unit, usize>, + unit_ref: UnitOffset, +} + +impl<'a> fmt::Debug for DieRefSummary<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let section_offs = self.unit_ref.to_unit_section_offset(self.unit); + let offs = get_offset_value(section_offs); + write!(f, "0x{offs:08x}") + } +} + +pub fn log_get_die_ref<'a>( + unit: &'a Unit, usize>, + unit_ref: UnitOffset, +) -> DieRefSummary<'a> { + DieRefSummary { unit, unit_ref } +} + struct DieDetailedSummary<'a> { dwarf: &'a Dwarf>, unit: &'a Unit, usize>, @@ -52,8 +73,8 @@ pub fn log_begin_input_die( depth: isize, ) { dbi_log!( - "=== Begin DIE at 0x{:08x} (depth = {}):\n{:?}", - get_offset_value(die.offset().to_unit_section_offset(unit)), + "=== Begin DIE at {:?} (depth = {}):\n{:?}", + log_get_die_ref(unit, die.offset()), depth, DieDetailedSummary { dwarf, unit, die } ); @@ -123,7 +144,10 @@ impl<'a> fmt::Debug for DieDetailedSummary<'a> { AttributeValue::CallingConvention(value) => write!(f, "{value}"), AttributeValue::Inline(value) => write!(f, "{value}"), AttributeValue::Ordering(value) => write!(f, "{value}"), - AttributeValue::UnitRef(offset) => write!(f, "0x{:08x}", offset.0), + AttributeValue::UnitRef(offset) => { + let section_offset = offset.to_unit_section_offset(unit); + write!(f, "0x{:08x}", get_offset_value(section_offset)) + } AttributeValue::DebugInfoRef(offset) => write!(f, "0x{:08x}", offset.0), unexpected_attr => write!(f, ""), }?; @@ -219,8 +243,8 @@ pub fn log_end_output_die( depth: isize, ) { dbi_log!( - "=== End DIE at 0x{:08x} (depth = {}):\n{:?}", - get_offset_value(input_die.offset().to_unit_section_offset(input_unit)), + "=== End DIE at {:?} (depth = {}):\n{:?}", + log_get_die_ref(input_unit, input_die.offset()), depth, OutDieDetailedSummary { die_id, @@ -237,8 +261,8 @@ pub fn log_end_output_die_skipped( depth: isize, ) { dbi_log!( - "=== End DIE at 0x{:08x} (depth = {}):\n Skipped as {}\n", - get_offset_value(input_die.offset().to_unit_section_offset(input_unit)), + "=== End DIE at {:?} (depth = {}):\n Skipped as {}\n", + log_get_die_ref(input_unit, input_die.offset()), depth, reason ); diff --git a/crates/cranelift/src/debug/transform/mod.rs b/crates/cranelift/src/debug/transform/mod.rs index 22966cd213ea..5f3deb7c7b9c 100644 --- a/crates/cranelift/src/debug/transform/mod.rs +++ b/crates/cranelift/src/debug/transform/mod.rs @@ -195,7 +195,7 @@ pub fn transform_dwarf( &mut out_units, &mut out_strings, ); - // TODO-LLVM-DI-Cleanup: move the simulation code to be per-module and delete this map. + // TODO-DebugInfo-Cleanup: move the simulation code to be per-module and delete this map. vmctx_ptr_die_refs.push(out_module_synthetic_unit.vmctx_ptr_die_ref()); let mut iter = di.dwarf.debug_info.units(); diff --git a/crates/cranelift/src/debug/transform/unit.rs b/crates/cranelift/src/debug/transform/unit.rs index 106758d7b310..491a669dfa15 100644 --- a/crates/cranelift/src/debug/transform/unit.rs +++ b/crates/cranelift/src/debug/transform/unit.rs @@ -1,5 +1,5 @@ use super::address_transform::AddressTransform; -use super::attr::{clone_die_attributes, FileAttributeContext}; +use super::attr::{clone_die_attributes, EntryAttributesContext}; use super::debug_transform_logging::{ dbi_log, log_begin_input_die, log_end_output_die, log_end_output_die_skipped, log_get_cu_summary, @@ -9,7 +9,7 @@ use super::line_program::clone_line_program; use super::range_info_builder::RangeInfoBuilder; use super::refs::{PendingDebugInfoRefs, PendingUnitRefs, UnitRefsMap}; use super::synthetic::ModuleSyntheticUnit; -use super::utils::append_vmctx_info; +use super::utils::{append_vmctx_info, resolve_die_ref}; use super::DebugInputContext; use crate::debug::{Compilation, Reader}; use anyhow::{Context, Error}; @@ -21,7 +21,8 @@ use std::collections::HashSet; use wasmtime_environ::StaticModuleIndex; use wasmtime_versioned_export_macros::versioned_stringify_ident; -struct InheritedAttr { +#[derive(Debug)] +pub struct InheritedAttr { stack: Vec<(usize, T)>, } @@ -36,14 +37,21 @@ impl InheritedAttr { } } - fn push(&mut self, depth: usize, value: T) { + pub fn push(&mut self, depth: usize, value: T) { self.stack.push((depth, value)); } - fn top(&self) -> Option<&T> { + pub fn top(&self) -> Option<&T> { self.stack.last().map(|entry| &entry.1) } + pub fn top_with_depth_mut(&mut self, depth: usize) -> Option<&mut T> { + self.stack + .last_mut() + .filter(|entry| entry.0 == depth) + .map(|entry| &mut entry.1) + } + fn is_empty(&self) -> bool { self.stack.is_empty() } @@ -51,14 +59,12 @@ impl InheritedAttr { fn get_base_type_name( type_entry: &DebuggingInformationEntry>, - unit: &Unit, usize>, + unit: &Unit>, dwarf: &Dwarf>, ) -> Result { // FIXME remove recursion. - if let Some(AttributeValue::UnitRef(ref offset)) = type_entry.attr_value(gimli::DW_AT_type)? { - let mut entries = unit.entries_at_offset(*offset)?; - entries.next_entry()?; - if let Some(die) = entries.current() { + if let Some(die_ref) = type_entry.attr_value(gimli::DW_AT_type)? { + if let Some(ref die) = resolve_die_ref(unit, &die_ref)? { if let Some(value) = die.attr_value(gimli::DW_AT_name)? { return Ok(String::from(dwarf.attr_string(unit, value)?.to_string()?)); } @@ -251,8 +257,8 @@ fn is_dead_code(entry: &DebuggingInformationEntry>) -> bool { pub(crate) fn clone_unit( compilation: &mut Compilation<'_>, module: StaticModuleIndex, - skeleton_unit: &Unit, usize>, - split_unit: Option<&Unit, usize>>, + skeleton_unit: &Unit>, + split_unit: Option<&Unit>>, split_dwarf: Option<&Dwarf>>, context: &DebugInputContext, addr_tr: &AddressTransform, @@ -310,7 +316,7 @@ pub(crate) fn clone_unit( out_strings, &mut pending_die_refs, &mut pending_di_refs, - FileAttributeContext::Root(Some(debug_line_offset)), + EntryAttributesContext::Root(Some(debug_line_offset)), isa, )?; if split_unit.is_some() { @@ -328,7 +334,7 @@ pub(crate) fn clone_unit( out_strings, &mut pending_die_refs, &mut pending_di_refs, - FileAttributeContext::Root(Some(debug_line_offset)), + EntryAttributesContext::Root(Some(debug_line_offset)), isa, )?; } @@ -352,6 +358,7 @@ pub(crate) fn clone_unit( let mut current_frame_base = InheritedAttr::new(); let mut current_value_range = InheritedAttr::new(); let mut current_scope_ranges = InheritedAttr::new(); + let mut current_subprogram = InheritedAttr::new(); while let Some((depth_delta, entry)) = entries.next_dfs()? { current_depth += depth_delta; log_begin_input_die(dwarf, unit, entry, current_depth); @@ -394,6 +401,7 @@ pub(crate) fn clone_unit( current_frame_base.update(new_stack_len); current_scope_ranges.update(new_stack_len); current_value_range.update(new_stack_len); + current_subprogram.update(new_stack_len); let range_builder = if entry.tag() == gimli::DW_TAG_subprogram { let range_builder = RangeInfoBuilder::from_subprogram_die(dwarf, &unit, entry, addr_tr)?; @@ -481,7 +489,9 @@ pub(crate) fn clone_unit( out_strings, &mut pending_die_refs, &mut pending_di_refs, - FileAttributeContext::Children { + EntryAttributesContext::Children { + depth: current_depth as usize, + subprograms: &mut current_subprogram, file_map: &file_map, file_index_base, frame_base: current_frame_base.top(), diff --git a/crates/cranelift/src/debug/transform/utils.rs b/crates/cranelift/src/debug/transform/utils.rs index 5fb576bc6dca..c23e98b4d47c 100644 --- a/crates/cranelift/src/debug/transform/utils.rs +++ b/crates/cranelift/src/debug/transform/utils.rs @@ -1,8 +1,10 @@ +use crate::debug::Reader; + use super::address_transform::AddressTransform; use super::expression::{CompiledExpression, FunctionFrameInfo}; use anyhow::Error; use cranelift_codegen::isa::TargetIsa; -use gimli::write; +use gimli::{write, AttributeValue, DebuggingInformationEntry, Unit}; pub(crate) fn append_vmctx_info( comp_unit: &mut write::Unit, @@ -44,3 +46,17 @@ pub(crate) fn append_vmctx_info( Ok(()) } + +pub fn resolve_die_ref<'a>( + unit: &'a Unit>, + die_ref: &'a AttributeValue>, +) -> Result>>, Error> { + let die = match die_ref { + AttributeValue::UnitRef(unit_offs) => Some(unit.entry(*unit_offs)?), + // TODO-DebugInfo: support AttributeValue::DebugInfoRef. The trouble is that we don't have + // a fast way to go from a DI offset to a unit offset (which is needed to parse the DIE). + // We would likely need to maintain a cache. + _ => None, + }; + Ok(die) +} diff --git a/crates/cranelift/src/func_environ.rs b/crates/cranelift/src/func_environ.rs index 39311a2f247a..cba5b1656014 100644 --- a/crates/cranelift/src/func_environ.rs +++ b/crates/cranelift/src/func_environ.rs @@ -3589,7 +3589,7 @@ impl FuncEnvironment<'_> { /// /// This is enabled if `signals_based_traps` is `true` since signal handlers /// are available, but this is additionally forcibly disabled if Pulley is - /// being targetted since the Pulley runtime doesn't catch segfaults for + /// being targeted since the Pulley runtime doesn't catch segfaults for /// itself. pub fn clif_memory_traps_enabled(&self) -> bool { self.tunables.signals_based_traps && !self.isa.triple().is_pulley() diff --git a/crates/cranelift/src/obj.rs b/crates/cranelift/src/obj.rs index e64be78367a3..2fe5b314f887 100644 --- a/crates/cranelift/src/obj.rs +++ b/crates/cranelift/src/obj.rs @@ -85,7 +85,7 @@ impl<'a> ModuleTextBuilder<'a> { // If this target is Pulley then flag the text section as not needing the // executable bit in virtual memory which means that the runtime won't - // try to call `Mmap::make_exectuable`, which makes Pulley more + // try to call `Mmap::make_executable`, which makes Pulley more // portable. if compiler.triple().is_pulley() { let section = obj.section_mut(text_section); diff --git a/crates/cranelift/src/translate/code_translator/bounds_checks.rs b/crates/cranelift/src/translate/code_translator/bounds_checks.rs index ab15e4a1ac00..b45699ca3415 100644 --- a/crates/cranelift/src/translate/code_translator/bounds_checks.rs +++ b/crates/cranelift/src/translate/code_translator/bounds_checks.rs @@ -510,7 +510,7 @@ fn cast_index_to_pointer_ty( // If the index size is larger than the pointer, that means that this is a // 32-bit host platform with a 64-bit wasm linear memory. If the index is - // larger than 2**32 then that's guranteed to be out-of-bounds, otherwise we + // larger than 2**32 then that's guaranteed to be out-of-bounds, otherwise we // `ireduce` the index. // // Also note that at this time this branch doesn't support pcc nor the diff --git a/crates/wasi-common/witx/preview0/wasi_unstable.witx b/crates/wasi-common/witx/preview0/wasi_unstable.witx index dbece2641c49..ee01abcfedc2 100644 --- a/crates/wasi-common/witx/preview0/wasi_unstable.witx +++ b/crates/wasi-common/witx/preview0/wasi_unstable.witx @@ -3,7 +3,7 @@ ;; ;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi). ;; -;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md) +;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/blob/main/legacy/tools/witx-docs.md) ;; for an explanation of what that means. (use "typenames.witx") diff --git a/crates/wasi-common/witx/preview1/typenames.witx b/crates/wasi-common/witx/preview1/typenames.witx index e87239127c07..82ea27645624 100644 --- a/crates/wasi-common/witx/preview1/typenames.witx +++ b/crates/wasi-common/witx/preview1/typenames.witx @@ -2,7 +2,7 @@ ;; ;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi). ;; -;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md) +;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/blob/main/legacy/tools/witx-docs.md) ;; for an explanation of what that means. (typename $size u32) diff --git a/crates/wasi-common/witx/preview1/wasi_snapshot_preview1.witx b/crates/wasi-common/witx/preview1/wasi_snapshot_preview1.witx index 100d852b3ec8..f9e2aa2c6783 100644 --- a/crates/wasi-common/witx/preview1/wasi_snapshot_preview1.witx +++ b/crates/wasi-common/witx/preview1/wasi_snapshot_preview1.witx @@ -3,7 +3,7 @@ ;; ;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi). ;; -;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md) +;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/blob/main/legacy/tools/witx-docs.md) ;; for an explanation of what that means. (use "typenames.witx") diff --git a/crates/wasi/Cargo.toml b/crates/wasi/Cargo.toml index 2f903e6a0b4f..4853cb16dcd3 100644 --- a/crates/wasi/Cargo.toml +++ b/crates/wasi/Cargo.toml @@ -32,6 +32,7 @@ io-lifetimes = { workspace = true } fs-set-times = { workspace = true } bitflags = { workspace = true } async-trait = { workspace = true } +trait-variant = {workspace = true} system-interface = { workspace = true} futures = { workspace = true } url = { workspace = true } diff --git a/crates/wasi/src/bindings.rs b/crates/wasi/src/bindings.rs index 64bcb072818f..cefeec980ce3 100644 --- a/crates/wasi/src/bindings.rs +++ b/crates/wasi/src/bindings.rs @@ -47,7 +47,6 @@ //! ctx: WasiCtx, //! } //! -//! #[async_trait::async_trait] //! impl example::wasi::custom_host::Host for MyState { //! async fn my_custom_function(&mut self) { //! // .. diff --git a/crates/wasi/src/host/filesystem.rs b/crates/wasi/src/host/filesystem.rs index 04cc8670c4ad..2d31e5c53fc4 100644 --- a/crates/wasi/src/host/filesystem.rs +++ b/crates/wasi/src/host/filesystem.rs @@ -32,7 +32,6 @@ where } } -#[async_trait::async_trait] impl types::Host for WasiImpl where T: WasiView, @@ -57,7 +56,6 @@ where } } -#[async_trait::async_trait] impl HostDescriptor for WasiImpl where T: WasiView, @@ -854,7 +852,6 @@ where } } -#[async_trait::async_trait] impl HostDirectoryEntryStream for WasiImpl where T: WasiView, diff --git a/crates/wasi/src/host/io.rs b/crates/wasi/src/host/io.rs index b5cecca8132c..35a2e8e63aa9 100644 --- a/crates/wasi/src/host/io.rs +++ b/crates/wasi/src/host/io.rs @@ -37,7 +37,6 @@ where } } -#[async_trait::async_trait] impl streams::HostOutputStream for WasiImpl where T: WasiView, @@ -171,7 +170,6 @@ where } } -#[async_trait::async_trait] impl streams::HostInputStream for WasiImpl where T: WasiView, diff --git a/crates/wasi/src/host/tcp.rs b/crates/wasi/src/host/tcp.rs index 143ea607eb1c..160cb8a757c0 100644 --- a/crates/wasi/src/host/tcp.rs +++ b/crates/wasi/src/host/tcp.rs @@ -14,7 +14,6 @@ use wasmtime::component::Resource; impl tcp::Host for WasiImpl where T: WasiView {} -#[async_trait::async_trait] impl crate::host::tcp::tcp::HostTcpSocket for WasiImpl where T: WasiView, diff --git a/crates/wasi/src/host/udp.rs b/crates/wasi/src/host/udp.rs index d1ea5d204b6b..3dd73ff6ffe3 100644 --- a/crates/wasi/src/host/udp.rs +++ b/crates/wasi/src/host/udp.rs @@ -24,7 +24,6 @@ const MAX_UDP_DATAGRAM_SIZE: usize = u16::MAX as usize; impl udp::Host for WasiImpl where T: WasiView {} -#[async_trait::async_trait] impl udp::HostUdpSocket for WasiImpl where T: WasiView, @@ -398,7 +397,6 @@ impl Subscribe for IncomingDatagramStream { } } -#[async_trait::async_trait] impl udp::HostOutgoingDatagramStream for WasiImpl where T: WasiView, diff --git a/crates/wasi/src/ip_name_lookup.rs b/crates/wasi/src/ip_name_lookup.rs index 900d90800265..e013cefb01fc 100644 --- a/crates/wasi/src/ip_name_lookup.rs +++ b/crates/wasi/src/ip_name_lookup.rs @@ -19,7 +19,6 @@ pub enum ResolveAddressStream { Done(Result, SocketError>), } -#[async_trait::async_trait] impl Host for WasiImpl where T: WasiView, @@ -43,7 +42,6 @@ where } } -#[async_trait::async_trait] impl HostResolveAddressStream for WasiImpl where T: WasiView, diff --git a/crates/wasi/src/pipe.rs b/crates/wasi/src/pipe.rs index 83a389d90232..e1fe36ce5217 100644 --- a/crates/wasi/src/pipe.rs +++ b/crates/wasi/src/pipe.rs @@ -75,6 +75,7 @@ impl MemoryOutputPipe { } } +#[async_trait::async_trait] impl HostOutputStream for MemoryOutputPipe { fn write(&mut self, bytes: Bytes) -> Result<(), StreamError> { let mut buf = self.buffer.lock().unwrap(); @@ -217,6 +218,7 @@ impl Subscribe for AsyncReadStream { #[derive(Copy, Clone)] pub struct SinkOutputStream; +#[async_trait::async_trait] impl HostOutputStream for SinkOutputStream { fn write(&mut self, _buf: Bytes) -> Result<(), StreamError> { Ok(()) @@ -257,6 +259,7 @@ impl Subscribe for ClosedInputStream { #[derive(Copy, Clone)] pub struct ClosedOutputStream; +#[async_trait::async_trait] impl HostOutputStream for ClosedOutputStream { fn write(&mut self, _: Bytes) -> Result<(), StreamError> { Err(StreamError::Closed) diff --git a/crates/wasi/src/poll.rs b/crates/wasi/src/poll.rs index 8bb51ce2878c..ea494a1dcc85 100644 --- a/crates/wasi/src/poll.rs +++ b/crates/wasi/src/poll.rs @@ -116,7 +116,6 @@ where Ok(table.push_child(pollable, &resource)?) } -#[async_trait::async_trait] impl poll::Host for WasiImpl where T: WasiView, @@ -178,7 +177,6 @@ where } } -#[async_trait::async_trait] impl crate::bindings::io::poll::HostPollable for WasiImpl where T: WasiView, diff --git a/crates/wasi/witx/preview0/wasi_unstable.witx b/crates/wasi/witx/preview0/wasi_unstable.witx index dbece2641c49..ee01abcfedc2 100644 --- a/crates/wasi/witx/preview0/wasi_unstable.witx +++ b/crates/wasi/witx/preview0/wasi_unstable.witx @@ -3,7 +3,7 @@ ;; ;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi). ;; -;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md) +;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/blob/main/legacy/tools/witx-docs.md) ;; for an explanation of what that means. (use "typenames.witx") diff --git a/crates/wasi/witx/preview1/typenames.witx b/crates/wasi/witx/preview1/typenames.witx index e87239127c07..82ea27645624 100644 --- a/crates/wasi/witx/preview1/typenames.witx +++ b/crates/wasi/witx/preview1/typenames.witx @@ -2,7 +2,7 @@ ;; ;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi). ;; -;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md) +;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/blob/main/legacy/tools/witx-docs.md) ;; for an explanation of what that means. (typename $size u32) diff --git a/crates/wasi/witx/preview1/wasi_snapshot_preview1.witx b/crates/wasi/witx/preview1/wasi_snapshot_preview1.witx index 100d852b3ec8..f9e2aa2c6783 100644 --- a/crates/wasi/witx/preview1/wasi_snapshot_preview1.witx +++ b/crates/wasi/witx/preview1/wasi_snapshot_preview1.witx @@ -3,7 +3,7 @@ ;; ;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi). ;; -;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md) +;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/blob/main/legacy/tools/witx-docs.md) ;; for an explanation of what that means. (use "typenames.witx") diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index 4c6783fc5d83..a337cb0e2879 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -53,6 +53,7 @@ once_cell = { version = "1.12.0", optional = true } rayon = { version = "1.0", optional = true } object = { workspace = true } async-trait = { workspace = true, optional = true } +trait-variant = { workspace = true, optional = true } encoding_rs = { version = "0.8.31", optional = true } bumpalo = "3.11.0" fxprof-processed-profile = { version = "0.6.0", optional = true } @@ -184,6 +185,7 @@ cache = ["dep:wasmtime-cache", "std"] async = [ "dep:wasmtime-fiber", "dep:async-trait", + "dep:trait-variant", "wasmtime-component-macro?/async", "runtime", ] diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs index e650e942b819..217e1eb7a117 100644 --- a/crates/wasmtime/src/config.rs +++ b/crates/wasmtime/src/config.rs @@ -2708,7 +2708,7 @@ pub enum Collector { /// over-approximation of all objects that are currently on the stack, trace /// the stack during collection to find the precise set of on-stack roots, /// and decrement the reference count of any object that was in the - /// over-approximation but not the precise set. This improves throughtput, + /// over-approximation but not the precise set. This improves throughput, /// compared to "pure" reference counting, by performing many fewer /// refcount-increment and -decrement operations. The cost is the increased /// latency associated with tracing the stack. diff --git a/crates/wasmtime/src/runtime/component/bindgen_examples/_7_async.rs b/crates/wasmtime/src/runtime/component/bindgen_examples/_7_async.rs new file mode 100644 index 000000000000..d9e798791fce --- /dev/null +++ b/crates/wasmtime/src/runtime/component/bindgen_examples/_7_async.rs @@ -0,0 +1,47 @@ +bindgen!({ + inline: r#" + package example:imported-resources; + + interface logging { + enum level { + debug, + info, + warn, + error, + } + + resource logger { + constructor(max-level: level); + + get-max-level: func() -> level; + set-max-level: func(level: level); + + log: func(level: level, msg: string); + } + } + + world import-some-resources { + import logging; + } + "#, + + async: true, // NEW + + with: { + // Specify that our host resource is going to point to the `MyLogger` + // which is defined just below this macro. + "example:imported-resources/logging/logger": MyLogger, + }, + + // Interactions with `ResourceTable` can possibly trap so enable the ability + // to return traps from generated functions. + trappable_imports: true, +}); + +/// A sample host-defined type which contains arbitrary host-defined data. +/// +/// In this case this is relatively simple but there's no restrictions on what +/// this type can hold other than that it must be `'static + Send`. +pub struct MyLogger { + pub max_level: example::imported_resources::logging::Level, +} diff --git a/crates/wasmtime/src/runtime/component/bindgen_examples/mod.rs b/crates/wasmtime/src/runtime/component/bindgen_examples/mod.rs index 638431c4506d..c8a756cd3de8 100644 --- a/crates/wasmtime/src/runtime/component/bindgen_examples/mod.rs +++ b/crates/wasmtime/src/runtime/component/bindgen_examples/mod.rs @@ -486,3 +486,72 @@ pub mod _5_all_world_export_kinds; /// } /// ``` pub mod _6_exported_resources; + +/// Example of generating **async** bindings for imported resources in a world. +/// +/// Notable differences from [`_4_imported_resources`] are: +/// * async functions are used +/// * enabled async in bindgen! macro +/// +/// See [wasi_async_example](https://github.com/bytecodealliance/wasmtime/tree/main/examples/wasi-async) for async function calls on a host. +/// +/// ```rust +/// use wasmtime::Result; +/// use wasmtime::component::{bindgen, ResourceTable, Resource}; +/// use example::imported_resources::logging::{Level, Host, HostLogger}; +/// +#[doc = include_str!("./_7_async.rs")] +/// +/// #[derive(Default)] +/// struct MyState { +/// // Manages the mapping of `MyLogger` structures to `Resource`. +/// table: ResourceTable, +/// } +/// +/// // There are no free-functions on `interface logging`, so this is an empty +/// // impl. +/// impl Host for MyState {} +/// +/// // This separate `HostLogger` trait serves to act as a namespace for just +/// // the `logger`-related resource methods. +/// impl HostLogger for MyState { +/// // A `constructor` in WIT maps to a `new` function in Rust. +/// async fn new(&mut self, max_level: Level) -> Result> { +/// let id = self.table.push(MyLogger { max_level })?; +/// Ok(id) +/// } +/// +/// async fn get_max_level(&mut self, logger: Resource) -> Result { +/// debug_assert!(!logger.owned()); +/// let logger = self.table.get(&logger)?; +/// Ok(logger.max_level) +/// } +/// +/// async fn set_max_level(&mut self, logger: Resource, level: Level) -> Result<()> { +/// debug_assert!(!logger.owned()); +/// let logger = self.table.get_mut(&logger)?; +/// logger.max_level = level; +/// Ok(()) +/// } +/// +/// async fn log(&mut self, logger: Resource, level: Level, msg: String) -> Result<()> { +/// debug_assert!(!logger.owned()); +/// let logger = self.table.get_mut(&logger)?; +/// if (level as u32) <= (logger.max_level as u32) { +/// println!("{msg}"); +/// } +/// Ok(()) +/// } +/// +/// async fn drop(&mut self, logger: Resource) -> Result<()> { +/// debug_assert!(logger.owned()); +/// let _logger: MyLogger = self.table.delete(logger)?; +/// // ... custom destruction logic here if necessary, otherwise +/// // a `Drop for MyLogger` would also work. +/// Ok(()) +/// } +/// } +/// +/// # fn main() {} +/// ``` +pub mod _7_async; diff --git a/crates/wasmtime/src/runtime/component/func/typed.rs b/crates/wasmtime/src/runtime/component/func/typed.rs index 4dd5050e000d..95fb52186c2a 100644 --- a/crates/wasmtime/src/runtime/component/func/typed.rs +++ b/crates/wasmtime/src/runtime/component/func/typed.rs @@ -875,19 +875,6 @@ integers! { macro_rules! floats { ($($float:ident/$get_float:ident = $ty:ident with abi:$abi:ident)*) => ($(const _: () = { - /// All floats in-and-out of the canonical abi always have their nan - /// payloads canonicalized. conveniently the `NAN` constant in rust has - /// the same representation as canonical nan, so we can use that for the - /// nan value. - #[inline] - fn canonicalize(float: $float) -> $float { - if float.is_nan() { - $float::NAN - } else { - float - } - } - unsafe impl ComponentType for $float { type Lower = ValRaw; @@ -910,7 +897,7 @@ macro_rules! floats { dst: &mut MaybeUninit, ) -> Result<()> { debug_assert!(matches!(ty, InterfaceType::$ty)); - dst.write(ValRaw::$float(canonicalize(*self).to_bits())); + dst.write(ValRaw::$float(self.to_bits())); Ok(()) } @@ -924,7 +911,7 @@ macro_rules! floats { debug_assert!(matches!(ty, InterfaceType::$ty)); debug_assert!(offset % Self::SIZE32 == 0); let ptr = cx.get(offset); - *ptr = canonicalize(*self).to_bits().to_le_bytes(); + *ptr = self.to_bits().to_le_bytes(); Ok(()) } } @@ -933,14 +920,14 @@ macro_rules! floats { #[inline] fn lift(_cx: &mut LiftContext<'_>, ty: InterfaceType, src: &Self::Lower) -> Result { debug_assert!(matches!(ty, InterfaceType::$ty)); - Ok(canonicalize($float::from_bits(src.$get_float()))) + Ok($float::from_bits(src.$get_float())) } #[inline] fn load(_cx: &mut LiftContext<'_>, ty: InterfaceType, bytes: &[u8]) -> Result { debug_assert!(matches!(ty, InterfaceType::$ty)); debug_assert!((bytes.as_ptr() as usize) % Self::SIZE32 == 0); - Ok(canonicalize($float::from_le_bytes(bytes.try_into().unwrap()))) + Ok($float::from_le_bytes(bytes.try_into().unwrap())) } } };)*) diff --git a/crates/wasmtime/src/runtime/component/mod.rs b/crates/wasmtime/src/runtime/component/mod.rs index 153f357c17ca..5c347102903a 100644 --- a/crates/wasmtime/src/runtime/component/mod.rs +++ b/crates/wasmtime/src/runtime/component/mod.rs @@ -145,9 +145,9 @@ pub mod __internal { pub use alloc::string::String; pub use alloc::vec::Vec; pub use anyhow; - #[cfg(feature = "async")] - pub use async_trait::async_trait; pub use core::mem::transmute; + #[cfg(feature = "async")] + pub use trait_variant::make as trait_variant_make; pub use wasmtime_environ; pub use wasmtime_environ::component::{CanonicalAbiInfo, ComponentTypes, InterfaceType}; } @@ -258,7 +258,7 @@ pub(crate) use self::store::ComponentStoreData; /// // This option defaults to `false`. /// verbose_tracing: false, /// -/// // Imports will be async functions through #[async_trait] and exports +/// // Imports will be async functions and exports /// // are also invoked as async functions. Requires `Config::async_support` /// // to be `true`. /// // diff --git a/crates/wasmtime/src/runtime/vm/instance/allocator/pooling/memory_pool.rs b/crates/wasmtime/src/runtime/vm/instance/allocator/pooling/memory_pool.rs index 26f7ef764ad4..720deb7c5e54 100644 --- a/crates/wasmtime/src/runtime/vm/instance/allocator/pooling/memory_pool.rs +++ b/crates/wasmtime/src/runtime/vm/instance/allocator/pooling/memory_pool.rs @@ -888,7 +888,7 @@ mod tests { Err(e) => { // Only allow failure on 32-bit // platforms where the calculation - // exceeded the size of the addres + // exceeded the size of the address // space assert!( cfg!(target_pointer_width = "32") diff --git a/crates/wasmtime/src/runtime/vm/sys/windows/mod.rs b/crates/wasmtime/src/runtime/vm/sys/windows/mod.rs index 0ecc7295c99b..90af767f30be 100644 --- a/crates/wasmtime/src/runtime/vm/sys/windows/mod.rs +++ b/crates/wasmtime/src/runtime/vm/sys/windows/mod.rs @@ -2,11 +2,20 @@ use std::cell::Cell; +#[cfg(feature = "signals-based-traps")] pub mod mmap; pub mod traphandlers; -pub mod unwind; pub mod vm; +#[cfg(target_pointer_width = "32")] +pub mod unwind32; +#[cfg(target_pointer_width = "32")] +pub use unwind32 as unwind; +#[cfg(target_pointer_width = "64")] +pub mod unwind64; +#[cfg(target_pointer_width = "64")] +pub use unwind64 as unwind; + std::thread_local!(static TLS: Cell<*mut u8> = const { Cell::new(std::ptr::null_mut()) }); #[inline] diff --git a/crates/wasmtime/src/runtime/vm/sys/windows/traphandlers.rs b/crates/wasmtime/src/runtime/vm/sys/windows/traphandlers.rs index e107763a45b9..6af1a6369402 100644 --- a/crates/wasmtime/src/runtime/vm/sys/windows/traphandlers.rs +++ b/crates/wasmtime/src/runtime/vm/sys/windows/traphandlers.rs @@ -109,6 +109,11 @@ unsafe extern "system" fn exception_handler(exception_info: *mut EXCEPTION_POINT pc: context.Pc as usize, fp: context.Anonymous.Anonymous.Fp as usize, }; + } else if #[cfg(target_arch = "x86")] { + let regs = TrapRegisters { + pc: context.Eip as usize, + fp: context.Ebp as usize, + }; } else { compile_error!("unsupported platform"); } diff --git a/crates/wasmtime/src/runtime/vm/sys/windows/unwind32.rs b/crates/wasmtime/src/runtime/vm/sys/windows/unwind32.rs new file mode 100644 index 000000000000..041bbfded32a --- /dev/null +++ b/crates/wasmtime/src/runtime/vm/sys/windows/unwind32.rs @@ -0,0 +1,23 @@ +//! Module for Windows x86 ABI unwind registry. +//! +//! Note that this is not implemented at this time because there is no Cranelift +//! backend foR windows. + +use crate::prelude::*; +use std::mem; + +pub enum UnwindRegistration {} + +impl UnwindRegistration { + #[allow(missing_docs)] + pub const SECTION_NAME: &'static str = ".pdata"; + + #[allow(missing_docs)] + pub unsafe fn new( + _base_address: *const u8, + _unwind_info: *const u8, + _unwind_len: usize, + ) -> Result { + bail!("unwind registration unimplemented on i686 windows") + } +} diff --git a/crates/wasmtime/src/runtime/vm/sys/windows/unwind.rs b/crates/wasmtime/src/runtime/vm/sys/windows/unwind64.rs similarity index 100% rename from crates/wasmtime/src/runtime/vm/sys/windows/unwind.rs rename to crates/wasmtime/src/runtime/vm/sys/windows/unwind64.rs diff --git a/crates/wast-util/src/lib.rs b/crates/wast-util/src/lib.rs index e72dcaf7b7a5..8b66e83a8ee0 100644 --- a/crates/wast-util/src/lib.rs +++ b/crates/wast-util/src/lib.rs @@ -321,7 +321,7 @@ impl Compiler { false } - /// Returns whether this complier configuration supports the current host + /// Returns whether this compiler configuration supports the current host /// architecture. pub fn supports_host(&self) -> bool { match self { @@ -430,37 +430,24 @@ impl WastTest { "misc_testsuite/simd/issue_3327_bnot_lowering.wast", "misc_testsuite/simd/v128-select.wast", "spec_testsuite/proposals/annotations/simd_lane.wast", - "spec_testsuite/proposals/relaxed-simd/i16x8_relaxed_q15mulr_s.wast", "spec_testsuite/proposals/relaxed-simd/i32x4_relaxed_trunc.wast", - "spec_testsuite/proposals/relaxed-simd/i8x16_relaxed_swizzle.wast", "spec_testsuite/proposals/relaxed-simd/relaxed_dot_product.wast", "spec_testsuite/proposals/relaxed-simd/relaxed_madd_nmadd.wast", "spec_testsuite/proposals/memory64/simd_lane.wast", "spec_testsuite/proposals/memory64/relaxed_madd_nmadd.wast", "spec_testsuite/proposals/memory64/relaxed_dot_product.wast", - "spec_testsuite/proposals/memory64/i16x8_relaxed_q15mulr_s.wast", "spec_testsuite/proposals/memory64/i32x4_relaxed_trunc.wast", - "spec_testsuite/proposals/memory64/i8x16_relaxed_swizzle.wast", "spec_testsuite/simd_f32x4_arith.wast", "spec_testsuite/simd_f32x4_cmp.wast", "spec_testsuite/simd_f32x4_pmin_pmax.wast", - "spec_testsuite/simd_f32x4_rounding.wast", "spec_testsuite/simd_f64x2_arith.wast", "spec_testsuite/simd_f64x2_cmp.wast", "spec_testsuite/simd_f64x2_pmin_pmax.wast", - "spec_testsuite/simd_f64x2_rounding.wast", - "spec_testsuite/simd_i16x8_arith2.wast", "spec_testsuite/simd_i16x8_extadd_pairwise_i8x16.wast", - "spec_testsuite/simd_i16x8_q15mulr_sat_s.wast", - "spec_testsuite/simd_i16x8_sat_arith.wast", - "spec_testsuite/simd_i32x4_arith2.wast", "spec_testsuite/simd_i32x4_dot_i16x8.wast", "spec_testsuite/simd_i32x4_extadd_pairwise_i16x8.wast", "spec_testsuite/simd_i32x4_trunc_sat_f32x4.wast", "spec_testsuite/simd_i32x4_trunc_sat_f64x2.wast", - "spec_testsuite/simd_i64x2_arith2.wast", - "spec_testsuite/simd_i8x16_arith2.wast", - "spec_testsuite/simd_i8x16_sat_arith.wast", "spec_testsuite/simd_lane.wast", "spec_testsuite/simd_load.wast", "spec_testsuite/simd_splat.wast", diff --git a/crates/wiggle/tests/typenames.witx b/crates/wiggle/tests/typenames.witx index 5cb1c0a13028..dfbea3efa68f 100644 --- a/crates/wiggle/tests/typenames.witx +++ b/crates/wiggle/tests/typenames.witx @@ -2,7 +2,7 @@ ;; ;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi). ;; -;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md) +;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/blob/main/legacy/tools/witx-docs.md) ;; for an explanation of what that means. (typename $size u32) diff --git a/crates/wiggle/tests/wasi.witx b/crates/wiggle/tests/wasi.witx index df3c670f3eee..5a89e2dba6e7 100644 --- a/crates/wiggle/tests/wasi.witx +++ b/crates/wiggle/tests/wasi.witx @@ -3,7 +3,7 @@ ;; ;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi). ;; -;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md) +;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/blob/main/legacy/tools/witx-docs.md) ;; for an explanation of what that means. (use "typenames.witx") diff --git a/crates/wit-bindgen/src/lib.rs b/crates/wit-bindgen/src/lib.rs index 74687f9d673c..6fd73b7efc4f 100644 --- a/crates/wit-bindgen/src/lib.rs +++ b/crates/wit-bindgen/src/lib.rs @@ -516,7 +516,7 @@ impl Wasmtime { #[allow(clippy::all)] pub mod {snake} {{ #[allow(unused_imports)] - use {wt}::component::__internal::anyhow; + use {wt}::component::__internal::{{anyhow, Box}}; {module} }} @@ -742,7 +742,7 @@ fn _new( #[allow(clippy::all)] pub mod {snake} {{ #[allow(unused_imports)] - use {wt}::component::__internal::anyhow; + use {wt}::component::__internal::{{anyhow, Box}}; {module} }} @@ -1358,7 +1358,10 @@ impl Wasmtime { let wt = self.wasmtime_path(); let world_camel = to_rust_upper_camel_case(&resolve.worlds[world].name); if self.opts.async_.maybe_async() { - uwriteln!(self.src, "#[{wt}::component::__internal::async_trait]") + uwriteln!( + self.src, + "#[{wt}::component::__internal::trait_variant_make(::core::marker::Send)]" + ) } uwrite!(self.src, "pub trait {world_camel}Imports"); let mut supertraits = vec![]; @@ -1404,18 +1407,15 @@ impl Wasmtime { ); // Generate impl WorldImports for &mut WorldImports - let (async_trait, maybe_send) = if self.opts.async_.maybe_async() { - ( - format!("#[{wt}::component::__internal::async_trait]\n"), - "+ Send", - ) + let maybe_send = if self.opts.async_.maybe_async() { + "+ Send" } else { - (String::new(), "") + "" }; if !self.opts.skip_mut_forwarding_impls { uwriteln!( self.src, - "{async_trait}impl<_T: {world_camel}Imports + ?Sized {maybe_send}> {world_camel}Imports for &mut _T {{" + "impl<_T: {world_camel}Imports + ?Sized {maybe_send}> {world_camel}Imports for &mut _T {{" ); // Forward each method call to &mut T for f in self.import_functions.iter() { @@ -1600,7 +1600,7 @@ impl Wasmtime { \"{name}\", {wt}::component::ResourceType::host::<{camel}>(), move |mut store, rep| {{ - std::boxed::Box::new(async move {{ + {wt}::component::__internal::Box::new(async move {{ Host{camel}::drop(&mut host_getter(store.data_mut()), {wt}::component::Resource::new_own(rep)).await }}) }}, @@ -1710,7 +1710,10 @@ impl<'a> InterfaceGenerator<'a> { // Generate resource trait if self.gen.opts.async_.maybe_async() { - uwriteln!(self.src, "#[{wt}::component::__internal::async_trait]") + uwriteln!( + self.src, + "#[{wt}::component::__internal::trait_variant_make(::core::marker::Send)]" + ) } uwriteln!(self.src, "pub trait Host{camel} {{"); @@ -1756,17 +1759,14 @@ impl<'a> InterfaceGenerator<'a> { // Generate impl HostResource for &mut HostResource if !self.gen.opts.skip_mut_forwarding_impls { - let (async_trait, maybe_send) = if self.gen.opts.async_.maybe_async() { - ( - format!("#[{wt}::component::__internal::async_trait]\n"), - "+ Send", - ) + let maybe_send = if self.gen.opts.async_.maybe_async() { + "+ Send" } else { - (String::new(), "") + "" }; uwriteln!( self.src, - "{async_trait}impl <_T: Host{camel} + ?Sized {maybe_send}> Host{camel} for &mut _T {{" + "impl <_T: Host{camel} + ?Sized {maybe_send}> Host{camel} for &mut _T {{" ); for func in &functions { self.generate_function_trait_sig(func); @@ -2386,7 +2386,10 @@ impl<'a> InterfaceGenerator<'a> { let is_maybe_async = self.gen.opts.async_.maybe_async(); if is_maybe_async { - uwriteln!(self.src, "#[{wt}::component::__internal::async_trait]") + uwriteln!( + self.src, + "#[{wt}::component::__internal::trait_variant_make(::core::marker::Send)]" + ) } // Generate the `pub trait` which represents the host functionality for // this import which additionally inherits from all resource traits @@ -2541,18 +2544,11 @@ impl<'a> InterfaceGenerator<'a> { ); // Generate impl Host for &mut Host - let (async_trait, maybe_send) = if is_maybe_async { - ( - format!("#[{wt}::component::__internal::async_trait]"), - "+ Send", - ) - } else { - (String::new(), "") - }; + let maybe_send = if is_maybe_async { "+ Send" } else { "" }; uwriteln!( self.src, - "{async_trait}impl<_T: Host + ?Sized {maybe_send}> Host for &mut _T {{" + "impl<_T: Host + ?Sized {maybe_send}> Host for &mut _T {{" ); // Forward each method call to &mut T for (_, func) in iface.functions.iter() { diff --git a/docs/cli-logging.md b/docs/cli-logging.md index 7d0b1ba0c575..8f47fa634a48 100644 --- a/docs/cli-logging.md +++ b/docs/cli-logging.md @@ -23,6 +23,9 @@ Wasmtime can also redirect the log messages into log files, with the `-D log-to-files` option. It creates one file per thread within Wasmtime, with the files named `wasmtime.dbg.*`. +Additional environment variables that work with `WASMTIME_LOG` (__not__ `-D log-to-files`): + - `WASMTIME_LOG_NO_CONTEXT`: if set to `1`, removes the time, level and target from output. + [`log`]: https://crates.io/crates/log [`tracing-subscriber`]: https://crates.io/crates/tracing-subscriber [tracing-subscriber's EnvFilter docs]: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 84a02e46fb56..660edf07532a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -14,6 +14,8 @@ function(CREATE_TARGET TARGET TARGET_PATH) target_compile_options(wasmtime-${TARGET} PRIVATE /W3) endif() + target_compile_definitions(wasmtime-${TARGET} PRIVATE WASMTIME_TEST_ONLY) + set_target_properties(wasmtime-${TARGET} PROPERTIES OUTPUT_NAME wasmtime-${TARGET} RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<0:> diff --git a/examples/fib-debug/main.c b/examples/fib-debug/main.c index 8633fb030129..0d901caffa2a 100644 --- a/examples/fib-debug/main.c +++ b/examples/fib-debug/main.c @@ -5,6 +5,41 @@ #include #include +#ifdef WASMTIME_TEST_ONLY +// These are the declarations provided from GDB documentation, used to validate +// that we actually added some DWARF info: +// https://sourceware.org/gdb/current/onlinedocs/gdb.html/Declarations.html#Declarations +// +// NOTE: These are not required in your code, rather they are used for wasmtime +// testing only. +typedef enum { + JIT_NOACTION = 0, + JIT_REGISTER_FN, + JIT_UNREGISTER_FN +} jit_actions_t; + +struct jit_code_entry { + struct jit_code_entry *next_entry; + struct jit_code_entry *prev_entry; + const char *symfile_addr; + uint64_t symfile_size; +}; + +struct jit_descriptor { + uint32_t version; + /* This type should be jit_actions_t, but we use uint32_t + to be explicit about the bitwidth. */ + uint32_t action_flag; + struct jit_code_entry *relevant_entry; + struct jit_code_entry *first_entry; +}; + +/* + * Import the descriptor, defined elsewhere in wasmtime + */ +extern struct jit_descriptor __jit_debug_descriptor; +#endif + #define own static void exit_with_error(const char *message, wasmtime_error_t *error, @@ -24,6 +59,15 @@ int main(int argc, const char *argv[]) { wasmtime_store_t *store = wasmtime_store_new(engine, NULL, NULL); wasmtime_context_t *context = wasmtime_store_context(store); +#ifdef WASMTIME_TEST_ONLY + // NOTE: This validation is for wasmtime testing and should not be included in + // your code. + if (__jit_debug_descriptor.first_entry != NULL) { + fprintf(stderr, "FAIL: JIT descriptor is already initialized\n"); + return 1; + } +#endif + // Load binary. printf("Loading binary...\n"); FILE *file = fopen("target/wasm32-unknown-unknown/debug/fib.wasm", "rb"); @@ -60,6 +104,15 @@ int main(int argc, const char *argv[]) { exit_with_error("failed to instantiate", error, trap); wasmtime_module_delete(module); +#ifdef WASMTIME_TEST_ONLY + // NOTE: This validation is for wasmtime testing and should not be included in + // your code. + if (__jit_debug_descriptor.first_entry == NULL) { + fprintf(stderr, "FAIL: JIT descriptor is NOT initialized\n"); + return 1; + } +#endif + // Extract export. wasmtime_extern_t fib; bool ok = wasmtime_instance_export_get(context, &instance, "fib", 3, &fib); diff --git a/pulley/src/interp.rs b/pulley/src/interp.rs index 4bcd46a766fe..8c965bbad1c6 100644 --- a/pulley/src/interp.rs +++ b/pulley/src/interp.rs @@ -13,7 +13,6 @@ use core::ops::{Index, IndexMut}; use core::ptr::NonNull; use sptr::Strict; use wasmtime_math::WasmFloat; - mod debug; #[cfg(all(not(pulley_tail_calls), not(pulley_assume_llvm_makes_tail_calls)))] mod match_loop; @@ -1065,6 +1064,65 @@ impl OpVisitor for Interpreter<'_> { ControlFlow::Continue(()) } + fn call1(&mut self, arg1: XReg, offset: PcRelOffset) -> ControlFlow { + let return_addr = self.pc.as_ptr(); + self.state.lr = return_addr.as_ptr(); + self.state[XReg::x0] = self.state[arg1]; + self.pc_rel_jump::(offset); + ControlFlow::Continue(()) + } + + fn call2(&mut self, arg1: XReg, arg2: XReg, offset: PcRelOffset) -> ControlFlow { + let return_addr = self.pc.as_ptr(); + self.state.lr = return_addr.as_ptr(); + let (x0, x1) = (self.state[arg1], self.state[arg2]); + self.state[XReg::x0] = x0; + self.state[XReg::x1] = x1; + self.pc_rel_jump::(offset); + ControlFlow::Continue(()) + } + + fn call3( + &mut self, + arg1: XReg, + arg2: XReg, + arg3: XReg, + offset: PcRelOffset, + ) -> ControlFlow { + let return_addr = self.pc.as_ptr(); + self.state.lr = return_addr.as_ptr(); + let (x0, x1, x2) = (self.state[arg1], self.state[arg2], self.state[arg3]); + self.state[XReg::x0] = x0; + self.state[XReg::x1] = x1; + self.state[XReg::x2] = x2; + self.pc_rel_jump::(offset); + ControlFlow::Continue(()) + } + + fn call4( + &mut self, + arg1: XReg, + arg2: XReg, + arg3: XReg, + arg4: XReg, + offset: PcRelOffset, + ) -> ControlFlow { + let return_addr = self.pc.as_ptr(); + self.state.lr = return_addr.as_ptr(); + let (x0, x1, x2, x3) = ( + self.state[arg1], + self.state[arg2], + self.state[arg3], + self.state[arg4], + ); + self.state[XReg::x0] = x0; + self.state[XReg::x1] = x1; + self.state[XReg::x2] = x2; + self.state[XReg::x3] = x3; + self.pc_rel_jump::(offset); + ControlFlow::Continue(()) + } + fn call_indirect(&mut self, dst: XReg) -> ControlFlow { let return_addr = self.pc.as_ptr(); self.state.lr = return_addr.as_ptr(); @@ -2936,6 +2994,19 @@ impl ExtendedOpVisitor for Interpreter<'_> { ControlFlow::Continue(()) } + fn vdivf32x4(&mut self, operands: BinaryOperands) -> ControlFlow { + let a = self.state[operands.src1].get_f32x4(); + let b = self.state[operands.src2].get_f32x4(); + let mut result = [0.0f32; 4]; + + for i in 0..4 { + result[i] = a[i] / b[i]; + } + + self.state[operands.dst].set_f32x4(result); + ControlFlow::Continue(()) + } + fn fmaximum32(&mut self, operands: BinaryOperands) -> ControlFlow { let a = self.state[operands.src1].get_f32(); let b = self.state[operands.src2].get_f32(); @@ -2956,30 +3027,122 @@ impl ExtendedOpVisitor for Interpreter<'_> { ControlFlow::Continue(()) } + fn vtrunc32x4(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f32x4(); + for elem in a.iter_mut() { + *elem = elem.wasm_trunc(); + } + self.state[dst].set_f32x4(a); + ControlFlow::Continue(()) + } + + fn vtrunc64x2(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f64x2(); + for elem in a.iter_mut() { + *elem = elem.wasm_trunc(); + } + self.state[dst].set_f64x2(a); + ControlFlow::Continue(()) + } + fn ffloor32(&mut self, dst: FReg, src: FReg) -> ControlFlow { let a = self.state[src].get_f32(); self.state[dst].set_f32(a.wasm_floor()); ControlFlow::Continue(()) } + fn vfloor32x4(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f32x4(); + for elem in a.iter_mut() { + *elem = elem.wasm_floor(); + } + self.state[dst].set_f32x4(a); + ControlFlow::Continue(()) + } + + fn vfloor64x2(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f64x2(); + for elem in a.iter_mut() { + *elem = elem.wasm_floor(); + } + self.state[dst].set_f64x2(a); + ControlFlow::Continue(()) + } + fn fceil32(&mut self, dst: FReg, src: FReg) -> ControlFlow { let a = self.state[src].get_f32(); self.state[dst].set_f32(a.wasm_ceil()); ControlFlow::Continue(()) } + fn vceil32x4(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f32x4(); + for elem in a.iter_mut() { + *elem = elem.wasm_ceil(); + } + self.state[dst].set_f32x4(a); + + ControlFlow::Continue(()) + } + + fn vceil64x2(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f64x2(); + for elem in a.iter_mut() { + *elem = elem.wasm_ceil(); + } + self.state[dst].set_f64x2(a); + + ControlFlow::Continue(()) + } + fn fnearest32(&mut self, dst: FReg, src: FReg) -> ControlFlow { let a = self.state[src].get_f32(); self.state[dst].set_f32(a.wasm_nearest()); ControlFlow::Continue(()) } + fn vnearest32x4(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f32x4(); + for elem in a.iter_mut() { + *elem = elem.wasm_nearest(); + } + self.state[dst].set_f32x4(a); + ControlFlow::Continue(()) + } + + fn vnearest64x2(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f64x2(); + for elem in a.iter_mut() { + *elem = elem.wasm_nearest(); + } + self.state[dst].set_f64x2(a); + ControlFlow::Continue(()) + } + fn fsqrt32(&mut self, dst: FReg, src: FReg) -> ControlFlow { let a = self.state[src].get_f32(); self.state[dst].set_f32(a.wasm_sqrt()); ControlFlow::Continue(()) } + fn vsqrt32x4(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f32x4(); + for elem in a.iter_mut() { + *elem = elem.wasm_sqrt(); + } + self.state[dst].set_f32x4(a); + ControlFlow::Continue(()) + } + + fn vsqrt64x2(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let mut a = self.state[src].get_f64x2(); + for elem in a.iter_mut() { + *elem = elem.wasm_sqrt(); + } + self.state[dst].set_f64x2(a); + ControlFlow::Continue(()) + } + fn fneg32(&mut self, dst: FReg, src: FReg) -> ControlFlow { let a = self.state[src].get_f32(); self.state[dst].set_f32(-a); @@ -3136,6 +3299,46 @@ impl ExtendedOpVisitor for Interpreter<'_> { ControlFlow::Continue(()) } + fn vaddi8x16_sat(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i8x16(); + let b = self.state[operands.src2].get_i8x16(); + for (a, b) in a.iter_mut().zip(b) { + *a = (*a).saturating_add(b); + } + self.state[operands.dst].set_i8x16(a); + ControlFlow::Continue(()) + } + + fn vaddu8x16_sat(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u8x16(); + let b = self.state[operands.src2].get_u8x16(); + for (a, b) in a.iter_mut().zip(b) { + *a = (*a).saturating_add(b); + } + self.state[operands.dst].set_u8x16(a); + ControlFlow::Continue(()) + } + + fn vaddi16x8_sat(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i16x8(); + let b = self.state[operands.src2].get_i16x8(); + for (a, b) in a.iter_mut().zip(b) { + *a = (*a).saturating_add(b); + } + self.state[operands.dst].set_i16x8(a); + ControlFlow::Continue(()) + } + + fn vaddu16x8_sat(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u16x8(); + let b = self.state[operands.src2].get_u16x8(); + for (a, b) in a.iter_mut().zip(b) { + *a = (*a).saturating_add(b); + } + self.state[operands.dst].set_u16x8(a); + ControlFlow::Continue(()) + } + fn vshli8x16(&mut self, operands: BinaryOperands) -> ControlFlow { let a = self.state[operands.src1].get_i8x16(); let b = self.state[operands.src2].get_u32(); @@ -3632,6 +3835,46 @@ impl ExtendedOpVisitor for Interpreter<'_> { ControlFlow::Continue(()) } + fn vsubi8x16_sat(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i8x16(); + let b = self.state[operands.src2].get_i8x16(); + for (a, b) in a.iter_mut().zip(b) { + *a = a.saturating_sub(b); + } + self.state[operands.dst].set_i8x16(a); + ControlFlow::Continue(()) + } + + fn vsubu8x16_sat(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u8x16(); + let b = self.state[operands.src2].get_u8x16(); + for (a, b) in a.iter_mut().zip(b) { + *a = a.saturating_sub(b); + } + self.state[operands.dst].set_u8x16(a); + ControlFlow::Continue(()) + } + + fn vsubi16x8_sat(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i16x8(); + let b = self.state[operands.src2].get_i16x8(); + for (a, b) in a.iter_mut().zip(b) { + *a = a.saturating_sub(b); + } + self.state[operands.dst].set_i16x8(a); + ControlFlow::Continue(()) + } + + fn vsubu16x8_sat(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u16x8(); + let b = self.state[operands.src2].get_u16x8(); + for (a, b) in a.iter_mut().zip(b) { + *a = a.saturating_sub(b); + } + self.state[operands.dst].set_u16x8(a); + ControlFlow::Continue(()) + } + fn vmuli8x16(&mut self, operands: BinaryOperands) -> ControlFlow { let mut a = self.state[operands.src1].get_i8x16(); let b = self.state[operands.src2].get_i8x16(); @@ -3672,6 +3915,25 @@ impl ExtendedOpVisitor for Interpreter<'_> { ControlFlow::Continue(()) } + fn vqmulrsi16x8(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i16x8(); + let b = self.state[operands.src2].get_i16x8(); + const MIN: i32 = i16::MIN as i32; + const MAX: i32 = i16::MAX as i32; + for (a, b) in a.iter_mut().zip(b) { + let r = (i32::from(*a) * i32::from(b) + (1 << 14)) >> 15; + *a = r.clamp(MIN, MAX) as i16; + } + self.state[operands.dst].set_i16x8(a); + ControlFlow::Continue(()) + } + + fn vpopcnt8x16(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let a = self.state[src].get_u8x16(); + self.state[dst].set_u8x16(a.map(|i| i.count_ones() as u8)); + ControlFlow::Continue(()) + } + fn xextractv8x16(&mut self, dst: XReg, src: VReg, lane: u8) -> ControlFlow { let a = unsafe { *self.state[src].get_u8x16().get_unchecked(usize::from(lane)) }; self.state[dst].set_u32(u32::from(a)); @@ -4080,6 +4342,150 @@ impl ExtendedOpVisitor for Interpreter<'_> { ControlFlow::Continue(()) } + fn vmin8x16_s(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i8x16(); + let b = self.state[operands.src2].get_i8x16(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).min(*b); + } + self.state[operands.dst].set_i8x16(a); + ControlFlow::Continue(()) + } + + fn vmin8x16_u(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u8x16(); + let b = self.state[operands.src2].get_u8x16(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).min(*b); + } + self.state[operands.dst].set_u8x16(a); + ControlFlow::Continue(()) + } + + fn vmin16x8_s(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i16x8(); + let b = self.state[operands.src2].get_i16x8(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).min(*b); + } + self.state[operands.dst].set_i16x8(a); + ControlFlow::Continue(()) + } + + fn vmin16x8_u(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u16x8(); + let b = self.state[operands.src2].get_u16x8(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).min(*b); + } + self.state[operands.dst].set_u16x8(a); + ControlFlow::Continue(()) + } + + fn vmin32x4_s(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i32x4(); + let b = self.state[operands.src2].get_i32x4(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).min(*b); + } + self.state[operands.dst].set_i32x4(a); + ControlFlow::Continue(()) + } + + fn vmin32x4_u(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u32x4(); + let b = self.state[operands.src2].get_u32x4(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).min(*b); + } + self.state[operands.dst].set_u32x4(a); + ControlFlow::Continue(()) + } + + fn vmax8x16_s(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i8x16(); + let b = self.state[operands.src2].get_i8x16(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).max(*b); + } + self.state[operands.dst].set_i8x16(a); + ControlFlow::Continue(()) + } + + fn vmax8x16_u(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u8x16(); + let b = self.state[operands.src2].get_u8x16(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).max(*b); + } + self.state[operands.dst].set_u8x16(a); + ControlFlow::Continue(()) + } + + fn vmax16x8_s(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i16x8(); + let b = self.state[operands.src2].get_i16x8(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).max(*b); + } + self.state[operands.dst].set_i16x8(a); + ControlFlow::Continue(()) + } + + fn vmax16x8_u(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u16x8(); + let b = self.state[operands.src2].get_u16x8(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).max(*b); + } + self.state[operands.dst].set_u16x8(a); + ControlFlow::Continue(()) + } + + fn vmax32x4_s(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_i32x4(); + let b = self.state[operands.src2].get_i32x4(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).max(*b); + } + self.state[operands.dst].set_i32x4(a); + ControlFlow::Continue(()) + } + + fn vmax32x4_u(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u32x4(); + let b = self.state[operands.src2].get_u32x4(); + for (a, b) in a.iter_mut().zip(&b) { + *a = (*a).max(*b); + } + self.state[operands.dst].set_u32x4(a); + ControlFlow::Continue(()) + } + + fn vabs8x16(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let a = self.state[src].get_i8x16(); + self.state[dst].set_i8x16(a.map(|i| i.wrapping_abs())); + ControlFlow::Continue(()) + } + + fn vabs16x8(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let a = self.state[src].get_i16x8(); + self.state[dst].set_i16x8(a.map(|i| i.wrapping_abs())); + ControlFlow::Continue(()) + } + + fn vabs32x4(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let a = self.state[src].get_i32x4(); + self.state[dst].set_i32x4(a.map(|i| i.wrapping_abs())); + ControlFlow::Continue(()) + } + + fn vabs64x2(&mut self, dst: VReg, src: VReg) -> ControlFlow { + let a = self.state[src].get_i64x2(); + self.state[dst].set_i64x2(a.map(|i| i.wrapping_abs())); + ControlFlow::Continue(()) + } + fn vabsf32x4(&mut self, dst: VReg, src: VReg) -> ControlFlow { let a = self.state[src].get_f32x4(); self.state[dst].set_f32x4(a.map(|i| i.wasm_abs())); @@ -4131,4 +4537,41 @@ impl ExtendedOpVisitor for Interpreter<'_> { self.state[operands.dst].set_f64x2(a); ControlFlow::Continue(()) } + + fn vswizzlei8x16(&mut self, operands: BinaryOperands) -> ControlFlow { + let src1 = self.state[operands.src1].get_i8x16(); + let src2 = self.state[operands.src2].get_i8x16(); + let mut dst = [0i8; 16]; + for (i, &idx) in src2.iter().enumerate() { + if (idx as usize) < 16 { + dst[i] = src1[idx as usize]; + } else { + dst[i] = 0 + } + } + self.state[operands.dst].set_i8x16(dst); + ControlFlow::Continue(()) + } + + fn vavground8x16(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u8x16(); + let b = self.state[operands.src2].get_u8x16(); + for (a, b) in a.iter_mut().zip(&b) { + // use wider precision to avoid overflow + *a = ((u32::from(*a) + u32::from(*b) + 1) / 2) as u8; + } + self.state[operands.dst].set_u8x16(a); + ControlFlow::Continue(()) + } + + fn vavground16x8(&mut self, operands: BinaryOperands) -> ControlFlow { + let mut a = self.state[operands.src1].get_u16x8(); + let b = self.state[operands.src2].get_u16x8(); + for (a, b) in a.iter_mut().zip(&b) { + // use wider precision to avoid overflow + *a = ((u32::from(*a) + u32::from(*b) + 1) / 2) as u16; + } + self.state[operands.dst].set_u16x8(a); + ControlFlow::Continue(()) + } } diff --git a/pulley/src/lib.rs b/pulley/src/lib.rs index 15ee315095c1..1bbbd7f5b3c8 100644 --- a/pulley/src/lib.rs +++ b/pulley/src/lib.rs @@ -92,7 +92,23 @@ macro_rules! for_each_op { /// Transfer control to the PC at the given offset and set the `lr` /// register to the PC just after this instruction. + /// + /// This instruction generally assumes that the Pulley ABI is being + /// respected where arguments are in argument registers (starting at + /// x0 for integer arguments) and results are in result registers. + /// This instruction itself assume that all arguments are already in + /// their registers. Subsequent instructions below enable moving + /// arguments into the correct registers as part of the same call + /// instruction. call = Call { offset: PcRelOffset }; + /// Like `call`, but also `x0 = arg1` + call1 = Call1 { arg1: XReg, offset: PcRelOffset }; + /// Like `call`, but also `x0, x1 = arg1, arg2` + call2 = Call2 { arg1: XReg, arg2: XReg, offset: PcRelOffset }; + /// Like `call`, but also `x0, x1, x2 = arg1, arg2, arg3` + call3 = Call3 { arg1: XReg, arg2: XReg, arg3: XReg, offset: PcRelOffset }; + /// Like `call`, but also `x0, x1, x2, x3 = arg1, arg2, arg3, arg4` + call4 = Call4 { arg1: XReg, arg2: XReg, arg3: XReg, arg4: XReg, offset: PcRelOffset }; /// Transfer control to the PC in `reg` and set `lr` to the PC just /// after this instruction. @@ -799,20 +815,38 @@ macro_rules! for_each_extended_op { fmul32 = Fmul32 { operands: BinaryOperands }; /// `low32(dst) = low32(src1) / low32(src2)` fdiv32 = Fdiv32 { operands: BinaryOperands }; + /// `low128(dst) = low128(src1) / low128(src2)` + vdivf32x4 = Vdivf32x4 { operands: BinaryOperands }; /// `low32(dst) = ieee_maximum(low32(src1), low32(src2))` fmaximum32 = Fmaximum32 { operands: BinaryOperands }; /// `low32(dst) = ieee_minimum(low32(src1), low32(src2))` fminimum32 = Fminimum32 { operands: BinaryOperands }; /// `low32(dst) = ieee_trunc(low32(src))` ftrunc32 = Ftrunc32 { dst: FReg, src: FReg }; + /// `low128(dst) = ieee_trunc(low128(src))` + vtrunc32x4 = Vtrunc32x4 { dst: VReg, src: VReg }; + /// `low128(dst) = ieee_trunc(low128(src))` + vtrunc64x2 = Vtrunc64x2 { dst: VReg, src: VReg }; /// `low32(dst) = ieee_floor(low32(src))` ffloor32 = Ffloor32 { dst: FReg, src: FReg }; + /// `low128(dst) = ieee_floor(low128(src))` + vfloor32x4 = Vfloor32x4 { dst: VReg, src: VReg }; + /// `low128(dst) = ieee_floor(low128(src))` + vfloor64x2 = Vfloor64x2 { dst: VReg, src: VReg }; /// `low32(dst) = ieee_ceil(low32(src))` fceil32 = Fceil32 { dst: FReg, src: FReg }; + /// `low128(dst) = ieee_ceil(low128(src))` + vceil32x4 = Vceil32x4 { dst: VReg, src: VReg }; + /// `low128(dst) = ieee_ceil(low128(src))` + vceil64x2 = Vceil64x2 { dst: VReg, src: VReg }; /// `low32(dst) = ieee_nearest(low32(src))` fnearest32 = Fnearest32 { dst: FReg, src: FReg }; /// `low32(dst) = ieee_sqrt(low32(src))` fsqrt32 = Fsqrt32 { dst: FReg, src: FReg }; + /// `low32(dst) = ieee_sqrt(low32(src))` + vsqrt32x4 = Vsqrt32x4 { dst: VReg, src: VReg }; + /// `low32(dst) = ieee_sqrt(low32(src))` + vsqrt64x2 = Vsqrt64x2 { dst: VReg, src: VReg }; /// `low32(dst) = -low32(src)` fneg32 = Fneg32 { dst: FReg, src: FReg }; /// `low32(dst) = |low32(src)|` @@ -838,6 +872,10 @@ macro_rules! for_each_extended_op { fceil64 = Fceil64 { dst: FReg, src: FReg }; /// `dst = ieee_nearest(src)` fnearest64 = Fnearest64 { dst: FReg, src: FReg }; + /// `low128(dst) = ieee_nearest(low128(src))` + vnearest32x4 = Vnearest32x4 { dst: VReg, src: VReg }; + /// `low128(dst) = ieee_nearest(low128(src))` + vnearest64x2 = Vnearest64x2 { dst: VReg, src: VReg }; /// `dst = ieee_sqrt(src)` fsqrt64 = Fsqrt64 { dst: FReg, src: FReg }; /// `dst = -src` @@ -861,6 +899,15 @@ macro_rules! for_each_extended_op { /// `dst = src1 + src2` vaddf64x2 = VAddF64x2 { operands: BinaryOperands }; + /// `dst = satruating_add(src1, src2)` + vaddi8x16_sat = VAddI8x16Sat { operands: BinaryOperands }; + /// `dst = satruating_add(src1, src2)` + vaddu8x16_sat = VAddU8x16Sat { operands: BinaryOperands }; + /// `dst = satruating_add(src1, src2)` + vaddi16x8_sat = VAddI16x8Sat { operands: BinaryOperands }; + /// `dst = satruating_add(src1, src2)` + vaddu16x8_sat = VAddU16x8Sat { operands: BinaryOperands }; + /// `dst = src1 << src2` vshli8x16 = VShlI8x16 { operands: BinaryOperands }; /// `dst = src1 << src2` @@ -1024,6 +1071,15 @@ macro_rules! for_each_extended_op { /// `dst = src1 - src2` vsubi64x2 = VSubI64x2 { operands: BinaryOperands }; + /// `dst = saturating_sub(src1, src2)` + vsubi8x16_sat = VSubI8x16Sat { operands: BinaryOperands }; + /// `dst = saturating_sub(src1, src2)` + vsubu8x16_sat = VSubU8x16Sat { operands: BinaryOperands }; + /// `dst = saturating_sub(src1, src2)` + vsubi16x8_sat = VSubI16x8Sat { operands: BinaryOperands }; + /// `dst = saturating_sub(src1, src2)` + vsubu16x8_sat = VSubU16x8Sat { operands: BinaryOperands }; + /// `dst = src1 * src2` vmuli8x16 = VMulI8x16 { operands: BinaryOperands }; /// `dst = src1 * src2` @@ -1033,6 +1089,12 @@ macro_rules! for_each_extended_op { /// `dst = src1 * src2` vmuli64x2 = VMulI64x2 { operands: BinaryOperands }; + /// `dst = signed_saturate(src1 * src2 + (1 << (Q - 1)) >> Q)` + vqmulrsi16x8 = VQmulrsI16x8 { operands: BinaryOperands }; + + /// `dst = count_ones(src)` + vpopcnt8x16 = VPopcnt8x16 { dst: VReg, src: VReg }; + /// `low32(dst) = zext(src[lane])` xextractv8x16 = XExtractV8x16 { dst: XReg, src: VReg, lane: u8 }; /// `low32(dst) = zext(src[lane])` @@ -1117,6 +1179,41 @@ macro_rules! for_each_extended_op { /// `dst = -src` vneg64x2 = Vneg64x2 { dst: VReg, src: VReg }; + /// `dst = min(src1, src2)` (signed) + vmin8x16_s = Vmin8x16S { operands: BinaryOperands }; + /// `dst = min(src1, src2)` (unsigned) + vmin8x16_u = Vmin8x16U { operands: BinaryOperands }; + /// `dst = min(src1, src2)` (signed) + vmin16x8_s = Vmin16x8S { operands: BinaryOperands }; + /// `dst = min(src1, src2)` (unsigned) + vmin16x8_u = Vmin16x8U { operands: BinaryOperands }; + /// `dst = max(src1, src2)` (signed) + vmax8x16_s = Vmax8x16S { operands: BinaryOperands }; + /// `dst = max(src1, src2)` (unsigned) + vmax8x16_u = Vmax8x16U { operands: BinaryOperands }; + /// `dst = max(src1, src2)` (signed) + vmax16x8_s = Vmax16x8S { operands: BinaryOperands }; + /// `dst = max(src1, src2)` (unsigned) + vmax16x8_u = Vmax16x8U { operands: BinaryOperands }; + + /// `dst = min(src1, src2)` (signed) + vmin32x4_s = Vmin32x4S { operands: BinaryOperands }; + /// `dst = min(src1, src2)` (unsigned) + vmin32x4_u = Vmin32x4U { operands: BinaryOperands }; + /// `dst = max(src1, src2)` (signed) + vmax32x4_s = Vmax32x4S { operands: BinaryOperands }; + /// `dst = max(src1, src2)` (unsigned) + vmax32x4_u = Vmax32x4U { operands: BinaryOperands }; + + /// `dst = |src|` + vabs8x16 = Vabs8x16 { dst: VReg, src: VReg }; + /// `dst = |src|` + vabs16x8 = Vabs16x8 { dst: VReg, src: VReg }; + /// `dst = |src|` + vabs32x4 = Vabs32x4 { dst: VReg, src: VReg }; + /// `dst = |src|` + vabs64x2 = Vabs64x2 { dst: VReg, src: VReg }; + /// `dst = |src|` vabsf32x4 = Vabsf32x4 { dst: VReg, src: VReg }; /// `dst = |src|` @@ -1129,6 +1226,14 @@ macro_rules! for_each_extended_op { vminimumf32x4 = Vminimumf32x4 { operands: BinaryOperands }; /// `dst = ieee_minimum(src1, src2)` vminimumf64x2 = Vminimumf64x2 { operands: BinaryOperands }; + + /// `dst = swizzle(src1, src2)` + vswizzlei8x16 = Vswizzlei8x16 { operands: BinaryOperands }; + + /// `dst = (src1 + src2 + 1) // 2` + vavground8x16 = Vavground8x16 { operands: BinaryOperands }; + /// `dst = (src1 + src2 + 1) // 2` + vavground16x8 = Vavground16x8 { operands: BinaryOperands }; } }; } diff --git a/supply-chain/config.toml b/supply-chain/config.toml index 38745c06b73a..847a391e4f39 100644 --- a/supply-chain/config.toml +++ b/supply-chain/config.toml @@ -586,6 +586,11 @@ criteria = "safe-to-deploy" version = "0.1.28" criteria = "safe-to-deploy" +[[exemptions.trait-variant]] +version = "0.1.2" +criteria = "safe-to-deploy" +notes = "This crate is maintained by the `rust-lang` maintainers and is [officially recommended](https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html) by the Rust project." + [[exemptions.typenum]] version = "1.15.0" criteria = "safe-to-deploy" diff --git a/tests/all/component_model/bindgen.rs b/tests/all/component_model/bindgen.rs index be329eea5088..e89b04f0ca09 100644 --- a/tests/all/component_model/bindgen.rs +++ b/tests/all/component_model/bindgen.rs @@ -338,7 +338,6 @@ mod async_config { struct T; - #[async_trait::async_trait] impl T1Imports for T { async fn x(&mut self) {} @@ -364,7 +363,6 @@ mod async_config { }, }); - #[async_trait::async_trait] impl T2Imports for T { fn x(&mut self) {} @@ -390,7 +388,6 @@ mod async_config { }, }); - #[async_trait::async_trait] impl T3Imports for T { async fn x(&mut self) {} diff --git a/tests/all/component_model/func.rs b/tests/all/component_model/func.rs index 36ddfe015e5c..2632a830b348 100644 --- a/tests/all/component_model/func.rs +++ b/tests/all/component_model/func.rs @@ -503,7 +503,7 @@ fn floats() -> Result<()> { .call(&mut store, (CANON_32BIT_NAN | 1,))? .0 .to_bits(), - CANON_32BIT_NAN + CANON_32BIT_NAN | 1 ); u32_to_f32.post_return(&mut store)?; assert_eq!( @@ -511,18 +511,18 @@ fn floats() -> Result<()> { .call(&mut store, (CANON_64BIT_NAN | 1,))? .0 .to_bits(), - CANON_64BIT_NAN, + CANON_64BIT_NAN | 1, ); u64_to_f64.post_return(&mut store)?; assert_eq!( f32_to_u32.call(&mut store, (f32::from_bits(CANON_32BIT_NAN | 1),))?, - (CANON_32BIT_NAN,) + (CANON_32BIT_NAN | 1,) ); f32_to_u32.post_return(&mut store)?; assert_eq!( f64_to_u64.call(&mut store, (f64::from_bits(CANON_64BIT_NAN | 1),))?, - (CANON_64BIT_NAN,) + (CANON_64BIT_NAN | 1,) ); f64_to_u64.post_return(&mut store)?; @@ -937,7 +937,10 @@ fn many_parameters() -> Result<()> { assert_eq!(i8::from_le_bytes(*actual.take_n::<1>()), input.0); actual.skip::<7>(); assert_eq!(u64::from_le_bytes(*actual.take_n::<8>()), input.1); - assert_eq!(u32::from_le_bytes(*actual.take_n::<4>()), CANON_32BIT_NAN); + assert_eq!( + u32::from_le_bytes(*actual.take_n::<4>()), + CANON_32BIT_NAN | 1 + ); assert_eq!(u8::from_le_bytes(*actual.take_n::<1>()), input.3); actual.skip::<1>(); assert_eq!(i16::from_le_bytes(*actual.take_n::<2>()), input.4); @@ -1703,7 +1706,7 @@ fn expected() -> Result<()> { let ret = to_expected_s16_f32 .call(&mut store, (1, CANON_32BIT_NAN | 1))? .0; - assert_eq!(ret.unwrap_err().to_bits(), CANON_32BIT_NAN); + assert_eq!(ret.unwrap_err().to_bits(), CANON_32BIT_NAN | 1); to_expected_s16_f32.post_return(&mut store)?; assert!(to_expected_s16_f32.call(&mut store, (2, 0)).is_err()); diff --git a/tests/all/debug/lldb.rs b/tests/all/debug/lldb.rs index a35e9762c844..68339e556a73 100644 --- a/tests/all/debug/lldb.rs +++ b/tests/all/debug/lldb.rs @@ -179,6 +179,7 @@ pub fn test_debug_dwarf_generic_lldb() -> Result<()> { &[ "-Ccache=n", "-Ddebug-info", + "-Oopt-level=0", "tests/all/debug/testsuite/generic.wasm", ], r#"br set -n debug_break -C up @@ -189,6 +190,14 @@ c p (x + x) c p inst.BaseValue + inst.DerivedValue +c +type lookup DerivedType +c +p __this->BaseValue + __this->DerivedValue +c +p __this->BaseValue + __this->DerivedValue +c +p __this->BaseValue + __this->DerivedValue c"#, )?; @@ -201,6 +210,15 @@ check: stop reason = breakpoint 1.1 check: 4 check: stop reason = breakpoint 1.1 check: 3 +check: stop reason = breakpoint 1.1 +check: static int InstanceMethod +check: static int ConstInstanceMethod +check: stop reason = breakpoint 1.1 +check: 6 +check: stop reason = breakpoint 1.1 +check: 7 +check: stop reason = breakpoint 1.1 +check: 8 check: exited with status = 0 "#, )?; diff --git a/tests/all/debug/testsuite/generic.cpp b/tests/all/debug/testsuite/generic.cpp index 68f3da5314d3..150157aa33ee 100644 --- a/tests/all/debug/testsuite/generic.cpp +++ b/tests/all/debug/testsuite/generic.cpp @@ -21,6 +21,16 @@ struct BaseType { }; struct DerivedType : BaseType { long long DerivedValue = 2; + + int InstanceMethod() { + debug_break(); + return BaseValue + DerivedValue; + } + + int ConstInstanceMethod() const { + debug_break(); + return BaseValue + DerivedValue; + } }; int TestInheritance() { @@ -29,9 +39,32 @@ int TestInheritance() { return inst.BaseValue + inst.DerivedValue != 3 ? 1 : 0; } +int TestInstanceMethod() { + debug_break(); + + DerivedType inst; + inst.BaseValue = 2; + inst.DerivedValue = 4; + if (inst.InstanceMethod() != 6) + return 1; + + inst.BaseValue++; + volatile DerivedType volatileInst = inst; + if (inst.InstanceMethod() != 7) + return 2; + + inst.DerivedValue++; + const DerivedType constInst = inst; + if (inst.ConstInstanceMethod() != 8) + return 3; + + return 0; +} + int main() { int exitCode = 0; exitCode += TestClassDefinitionSpreadAcrossCompileUnits(); exitCode += TestInheritance(); + exitCode += TestInstanceMethod(); return exitCode; } diff --git a/tests/all/debug/testsuite/generic.wasm b/tests/all/debug/testsuite/generic.wasm index 93ae43c1157d..108e5d88bc5d 100644 Binary files a/tests/all/debug/testsuite/generic.wasm and b/tests/all/debug/testsuite/generic.wasm differ diff --git a/tests/all/relocs.rs b/tests/all/relocs.rs index f04472efe146..8b54b83852b4 100644 --- a/tests/all/relocs.rs +++ b/tests/all/relocs.rs @@ -1,6 +1,6 @@ //! These tests are intended to exercise various relocation-based logic of //! Wasmtime, especially the "jump veneer" insertion in the object-file-assembly -//! for when platform-specific relative call instructios can't always reach +//! for when platform-specific relative call instructors can't always reach //! their destination within the platform-specific limits. //! //! Note that the limits of AArch64 are primarily what's being stressed here diff --git a/winch/README.md b/winch/README.md index 1b47d1eb282c..c37be40e211f 100644 --- a/winch/README.md +++ b/winch/README.md @@ -25,7 +25,7 @@ Winch's primary goal is compilation performance, therefore only certain, very limited peephole optimations are applied. For more details on the original motivation and goals, refer to the [Bytecode -Alliance RFC for Baseline Compilation in Wasmtime.](rfc). +Alliance RFC for Baseline Compilation in Wasmtime.][rfc]. [rfc]: https://github.com/bytecodealliance/rfcs/blob/main/accepted/wasmtime-baseline-compilation.md diff --git a/winch/codegen/src/codegen/mod.rs b/winch/codegen/src/codegen/mod.rs index b540f1649fc7..2bcb1aaabe02 100644 --- a/winch/codegen/src/codegen/mod.rs +++ b/winch/codegen/src/codegen/mod.rs @@ -1043,7 +1043,7 @@ where let new_epoch = self.env.builtins.new_epoch::(); // Checks for runtime limits (e.g., fuel, epoch) are special since they - // require inserting abritrary function calls and control flow. + // require inserting arbitrary function calls and control flow. // Special care must be taken to ensure that all invariants are met. In // this case, since `new_epoch` takes an argument and returns a value, // we must ensure that any registers used to hold the current epoch