Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasmtime: Misc optimizations #7102

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/jit/src/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ impl CompiledModule {
/// Returns the text section of the ELF image for this compiled module.
///
/// This memory should have the read/execute permissions.
#[inline]
pub fn text(&self) -> &[u8] {
self.code_memory.text()
}
Expand Down Expand Up @@ -575,6 +576,7 @@ impl CompiledModule {
///
/// These trampolines are used for native callers (e.g. `Func::wrap`)
/// calling Wasm callees.
#[inline]
pub fn native_to_wasm_trampoline(&self, index: DefinedFuncIndex) -> Option<&[u8]> {
let loc = self.funcs[index].native_to_wasm_trampoline?;
Some(&self.text()[loc.start as usize..][..loc.length as usize])
Expand Down
1 change: 1 addition & 0 deletions crates/runtime/src/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl Mmap {
/// # Panics
///
/// Panics of the `range` provided is outside of the limits of this mmap.
#[inline]
pub unsafe fn slice(&self, range: Range<usize>) -> &[u8] {
assert!(range.start <= range.end);
assert!(range.end <= self.len());
Expand Down
1 change: 1 addition & 0 deletions crates/runtime/src/mmap_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl MmapVec {
impl Deref for MmapVec {
type Target = [u8];

#[inline]
fn deref(&self) -> &[u8] {
// SAFETY: this mmap owns its own range of the underlying mmap so it
// should be all good-to-read.
Expand Down
5 changes: 4 additions & 1 deletion crates/wasi/src/preview2/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ impl WasiCtxBuilder {
pub fn new() -> Self {
// For the insecure random API, use `SmallRng`, which is fast. It's
// also insecure, but that's the deal here.
let insecure_random = Box::new(cap_rand::rngs::SmallRng::from_entropy());
let insecure_random = Box::new(
cap_rand::rngs::SmallRng::from_rng(cap_rand::thread_rng(cap_rand::ambient_authority()))
.unwrap(),
);

// For the insecure random seed, use a `u128` generated from
// `thread_rng()`, so that it's not guessable from the insecure_random
Expand Down
1 change: 1 addition & 0 deletions crates/wasmtime/src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl SignatureCollection {
}

/// Gets the shared signature index given a module signature index.
#[inline]
pub fn shared_signature(&self, index: SignatureIndex) -> Option<VMSharedSignatureIndex> {
self.signatures.get(index).copied()
}
Expand Down