Misc cleanups (#5014)
* Replace resize+copy_from_slice with extend_from_slice Vec::resize initializes the new space, which is wasted effort if we're just going to call `copy_from_slice` on it immediately afterward. Using `extend_from_slice` is simpler, and very slightly faster. If the new size were bigger than the buffer we're copying from, then it would make sense to initialize the excess. But it isn't: it's always exactly the same size. * Move helpers from Context to CompiledCode These methods only use information from Context::compiled_code, so they should live on CompiledCode instead. * Remove an unnecessary #[cfg_attr] There are other uses of `#[allow(clippy::too_many_arguments)]` in this file, so apparently it doesn't need to be guarded by the "cargo-clippy" feature. * Fix a few comments Two of these were wrong/misleading: - `FunctionBuilder::new` does not clear the provided func_ctx. It does debug-assert that the context is already clear, but I don't think that's worth a comment. - `switch_to_block` does not "create values for the arguments." That's done by the combination of `append_block_params_for_function_params` and `declare_wasm_parameters`. * wasmtime-cranelift: Misc cleanups The main change is to use the `CompiledCode` reference we already had instead of getting it out of `Context` repeatedly. This removes a bunch of `unwrap()` calls. * wasmtime-cranelift: Factor out uncached compile
This commit is contained in:
@@ -56,7 +56,7 @@ use crate::CodegenResult;
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use core::fmt;
|
||||
use core::fmt::{Debug, Formatter};
|
||||
use target_lexicon::{triple, Architecture, OperatingSystem, PointerWidth, Triple};
|
||||
use target_lexicon::{triple, Architecture, PointerWidth, Triple};
|
||||
|
||||
// This module is made public here for benchmarking purposes. No guarantees are
|
||||
// made regarding API stability.
|
||||
@@ -360,18 +360,6 @@ impl<'a> dyn TargetIsa + 'a {
|
||||
pointer_width: self.pointer_width(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the flavor of unwind information emitted for this target.
|
||||
pub(crate) fn unwind_info_kind(&self) -> UnwindInfoKind {
|
||||
match self.triple().operating_system {
|
||||
#[cfg(feature = "unwind")]
|
||||
OperatingSystem::Windows => UnwindInfoKind::Windows,
|
||||
#[cfg(feature = "unwind")]
|
||||
_ => UnwindInfoKind::SystemV,
|
||||
#[cfg(not(feature = "unwind"))]
|
||||
_ => UnwindInfoKind::None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for &dyn TargetIsa {
|
||||
|
||||
Reference in New Issue
Block a user