Skip to content
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
7 changes: 6 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ jobs:
toolchain: nightly
override: true
components: miri
- name: Clippy (default features)
- name: Clippy (--lib)
uses: actions-rs/cargo@v1
with:
command: miri
args: test --lib --workspace
- name: Clippy (--doc)
uses: actions-rs/cargo@v1
with:
command: miri
args: test --doc --workspace

clippy:
name: Clippy
Expand Down
17 changes: 7 additions & 10 deletions crates/wasmi/src/engine/code_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use super::Instruction;
use alloc::vec::Vec;
use core::ptr::NonNull;
use wasmi_arena::Index;

/// A reference to a Wasm function body stored in the [`CodeMap`].
Expand Down Expand Up @@ -102,7 +101,7 @@ impl CodeMap {
/// Returns an [`InstructionPtr`] to the instruction at [`InstructionsRef`].
#[inline]
pub fn instr_ptr(&self, iref: InstructionsRef) -> InstructionPtr {
InstructionPtr::new(&self.insts[iref.start])
InstructionPtr::new(self.insts[iref.start..].as_ptr())
}

/// Returns the [`FuncHeader`] of the [`FuncBody`].
Expand Down Expand Up @@ -137,15 +136,14 @@ impl CodeMap {
#[derive(Debug, Copy, Clone)]
pub struct InstructionPtr {
/// The pointer to the instruction.
ptr: NonNull<Instruction>,
ptr: *const Instruction,
}

impl InstructionPtr {
/// Creates a new [`InstructionPtr`] for `instr`.
pub fn new(instr: &Instruction) -> Self {
Self {
ptr: NonNull::from(instr),
}
#[inline]
pub fn new(ptr: *const Instruction) -> Self {
Self { ptr }
}

/// Offset the [`InstructionPtr`] by the given value.
Expand All @@ -157,8 +155,7 @@ impl InstructionPtr {
/// bounds of the instructions of the same compiled Wasm function.
#[inline(always)]
pub unsafe fn offset(&mut self, by: isize) {
let new_ptr = &*self.ptr.as_ptr().offset(by);
self.ptr = NonNull::from(new_ptr);
self.ptr = self.ptr.offset(by);
}

/// Returns a shared reference to the currently pointed at [`Instruction`].
Expand All @@ -170,6 +167,6 @@ impl InstructionPtr {
/// the boundaries of its associated compiled Wasm function.
#[inline(always)]
pub unsafe fn get(&self) -> &Instruction {
self.ptr.as_ref()
&*self.ptr
}
}