some fixes in response to miri
This commit is contained in:
@@ -568,7 +568,6 @@ parse_options_list(Options, Selector, DefaultPairs, OptionValues, Stub) :-
|
|||||||
% maplist isn't
|
% maplist isn't
|
||||||
% declared as a
|
% declared as a
|
||||||
% meta-predicate yet
|
% meta-predicate yet
|
||||||
'$debug_hook',
|
|
||||||
catch(lists:maplist(Selector, Options, OptionPairs0),
|
catch(lists:maplist(Selector, Options, OptionPairs0),
|
||||||
error(E, _),
|
error(E, _),
|
||||||
builtins:throw(error(E, Stub))) ->
|
builtins:throw(error(E, Stub))) ->
|
||||||
|
|||||||
@@ -1281,3 +1281,17 @@ pub(crate) fn to_local_code_ptr(heap: &Heap, addr: HeapCellValue) -> Option<usiz
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn heap_manipulation() {
|
||||||
|
let mut heap = Heap::new();
|
||||||
|
|
||||||
|
for idx in 0 .. 10 {
|
||||||
|
heap.push_cell(heap_loc_as_cell!(idx)).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -267,16 +267,6 @@ impl MachineState {
|
|||||||
unifier.unify_atom(atom, value);
|
unifier.unify_atom(atom, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unify_list(&mut self, l1: usize, value: HeapCellValue) {
|
|
||||||
let mut unifier = DefaultUnifier::from(self);
|
|
||||||
unifier.unify_list(l1, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unify_partial_string(&mut self, pstr_loc: usize, value: HeapCellValue) {
|
|
||||||
let mut unifier = DefaultUnifier::from(self);
|
|
||||||
unifier.unify_partial_string(pstr_loc, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unify_char(&mut self, c: char, value: HeapCellValue) {
|
pub fn unify_char(&mut self, c: char, value: HeapCellValue) {
|
||||||
let mut unifier = DefaultUnifier::from(self);
|
let mut unifier = DefaultUnifier::from(self);
|
||||||
unifier.unify_char(c, value);
|
unifier.unify_char(c, value);
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ impl Stack {
|
|||||||
|
|
||||||
for idx in 0..num_cells {
|
for idx in 0..num_cells {
|
||||||
ptr::write(
|
ptr::write(
|
||||||
(new_ptr as usize + offset) as *mut HeapCellValue,
|
new_ptr.byte_add(offset) as *mut HeapCellValue,
|
||||||
stack_loc_as_cell!(OrFrame, b, idx),
|
stack_loc_as_cell!(OrFrame, b, idx),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
12
src/types.rs
12
src/types.rs
@@ -97,8 +97,7 @@ impl ConsPtr {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn as_ptr(self) -> *mut u8 {
|
pub fn as_ptr(self) -> *mut u8 {
|
||||||
let addr: u64 = self.ptr();
|
unsafe { mem::transmute::<_, *mut u8>(self.ptr()) }
|
||||||
addr as usize as *mut _
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
@@ -676,23 +675,22 @@ impl UntypedArenaPtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_ptr(self) -> *const u8 {
|
pub fn get_ptr(self) -> *const ArenaHeader {
|
||||||
let addr: u64 = self.ptr();
|
unsafe { mem::transmute::<_, *const ArenaHeader>(self.ptr()) }
|
||||||
addr as usize as *const u8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_tag(self) -> ArenaHeaderTag {
|
pub fn get_tag(self) -> ArenaHeaderTag {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug_assert!(!self.get_ptr().is_null());
|
debug_assert!(!self.get_ptr().is_null());
|
||||||
let header = *(self.get_ptr() as *const ArenaHeader);
|
let header = *self.get_ptr();
|
||||||
header.get_tag()
|
header.get_tag()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn payload_offset(self) -> *const u8 {
|
pub fn payload_offset(self) -> *const u8 {
|
||||||
unsafe { self.get_ptr().add(mem::size_of::<ArenaHeader>()) }
|
unsafe { self.get_ptr().byte_add(mem::size_of::<ArenaHeader>()) as *const _ }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
|
|||||||
Reference in New Issue
Block a user