From 3dee07f648c98aa7dd259a65b9e6e134bdadde54 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Thu, 13 Mar 2025 12:33:37 -0700 Subject: [PATCH] some fixes in response to miri --- src/lib/builtins.pl | 1 - src/machine/heap.rs | 14 ++++++++++++++ src/machine/machine_state_impl.rs | 10 ---------- src/machine/stack.rs | 2 +- src/types.rs | 12 +++++------- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/lib/builtins.pl b/src/lib/builtins.pl index 31b40a3a..bc78b711 100644 --- a/src/lib/builtins.pl +++ b/src/lib/builtins.pl @@ -568,7 +568,6 @@ parse_options_list(Options, Selector, DefaultPairs, OptionValues, Stub) :- % maplist isn't % declared as a % meta-predicate yet - '$debug_hook', catch(lists:maplist(Selector, Options, OptionPairs0), error(E, _), builtins:throw(error(E, Stub))) -> diff --git a/src/machine/heap.rs b/src/machine/heap.rs index b753809d..d628391c 100644 --- a/src/machine/heap.rs +++ b/src/machine/heap.rs @@ -1281,3 +1281,17 @@ pub(crate) fn to_local_code_ptr(heap: &Heap, addr: HeapCellValue) -> Option *mut u8 { - let addr: u64 = self.ptr(); - addr as usize as *mut _ + unsafe { mem::transmute::<_, *mut u8>(self.ptr()) } } #[inline(always)] @@ -676,23 +675,22 @@ impl UntypedArenaPtr { } #[inline] - pub fn get_ptr(self) -> *const u8 { - let addr: u64 = self.ptr(); - addr as usize as *const u8 + pub fn get_ptr(self) -> *const ArenaHeader { + unsafe { mem::transmute::<_, *const ArenaHeader>(self.ptr()) } } #[inline] pub fn get_tag(self) -> ArenaHeaderTag { unsafe { debug_assert!(!self.get_ptr().is_null()); - let header = *(self.get_ptr() as *const ArenaHeader); + let header = *self.get_ptr(); header.get_tag() } } #[inline] pub fn payload_offset(self) -> *const u8 { - unsafe { self.get_ptr().add(mem::size_of::()) } + unsafe { self.get_ptr().byte_add(mem::size_of::()) as *const _ } } /// # Safety -- 2.54.0